PageRenderTime 31ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/js/lib/Socket.IO-node/support/socket.io-client/lib/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/MD2Test.as

http://github.com/onedayitwillmake/RealtimeMultiplayerNodeJs
ActionScript | 56 lines | 41 code | 3 blank | 12 comment | 2 complexity | 511779e99fcbcf657586d9fca60a6615 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, MPL-2.0-no-copyleft-exception, BSD-3-Clause
  1. /**
  2. * MD2Test
  3. *
  4. * A test class for MD2
  5. * Copyright (c) 2007 Henri Torgemane
  6. *
  7. * See LICENSE.txt for full license information.
  8. */
  9. package com.hurlant.crypto.tests
  10. {
  11. import com.hurlant.crypto.hash.MD2;
  12. import com.hurlant.util.Hex;
  13. import flash.utils.ByteArray;
  14. public class MD2Test extends TestCase
  15. {
  16. public function MD2Test(h:ITestHarness)
  17. {
  18. super(h, "MD2 Test");
  19. runTest(testMd2, "MD2 Test Vectors");
  20. h.endTestCase();
  21. }
  22. /**
  23. * Test Vectors grabbed from
  24. * http://www.faqs.org/rfcs/rfc1319.html
  25. */
  26. public function testMd2():void {
  27. var srcs:Array = [
  28. "",
  29. Hex.fromString("a"),
  30. Hex.fromString("abc"),
  31. Hex.fromString("message digest"),
  32. Hex.fromString("abcdefghijklmnopqrstuvwxyz"),
  33. Hex.fromString("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"),
  34. Hex.fromString("12345678901234567890123456789012345678901234567890123456789012345678901234567890")
  35. ];
  36. var hashes:Array = [
  37. "8350e5a3e24c153df2275c9f80692773",
  38. "32ec01ec4a6dac72c0ab96fb34c0b5d1",
  39. "da853b0d3f88d99b30283a69e6ded6bb",
  40. "ab4f496bfb2a530b219ff33031fe06b0",
  41. "4e8ddff3650292ab5a4108c3aa47940b",
  42. "da33def2a42df13975352846c30338cd",
  43. "d5976f79d83d3a0dc9806c3c66f3efd8"
  44. ];
  45. var md2:MD2 = new MD2;
  46. for (var i:uint=0;i<srcs.length;i++) {
  47. var src:ByteArray = Hex.toArray(srcs[i]);
  48. var digest:ByteArray = md2.hash(src);
  49. assert("MD2 Test "+i, Hex.fromArray(digest) == hashes[i]);
  50. }
  51. }
  52. }
  53. }