as3corelib 0.1.0 → 0.85.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. data/Gemfile +1 -4
  2. data/Gemfile.lock +7 -4
  3. data/README.textile +20 -10
  4. data/Rakefile +32 -2
  5. data/as3corelib.gemspec +13 -11
  6. data/lib/as3corelib.rb +10 -4
  7. data/lib/as3corelib/version.rb +4 -0
  8. metadata +31 -121
  9. data/build/build.properties +0 -48
  10. data/build/build.xml +0 -104
  11. data/examples/JSONExample/JSONExample.mxml +0 -73
  12. data/src/com/adobe/air/crypto/EncryptionKeyGenerator.as +0 -313
  13. data/src/com/adobe/air/filesystem/FileMonitor.as +0 -245
  14. data/src/com/adobe/air/filesystem/FileUtil.as +0 -63
  15. data/src/com/adobe/air/filesystem/VolumeMonitor.as +0 -184
  16. data/src/com/adobe/air/filesystem/events/FileMonitorEvent.as +0 -61
  17. data/src/com/adobe/air/logging/FileTarget.as +0 -95
  18. data/src/com/adobe/air/net/ResourceCache.as +0 -165
  19. data/src/com/adobe/air/net/events/ResourceCacheEvent.as +0 -70
  20. data/src/com/adobe/crypto/HMAC.as +0 -127
  21. data/src/com/adobe/crypto/MD5.as +0 -281
  22. data/src/com/adobe/crypto/MD5Stream.as +0 -402
  23. data/src/com/adobe/crypto/SHA1.as +0 -289
  24. data/src/com/adobe/crypto/SHA224.as +0 -257
  25. data/src/com/adobe/crypto/SHA256.as +0 -261
  26. data/src/com/adobe/crypto/WSSEUsernameToken.as +0 -114
  27. data/src/com/adobe/errors/IllegalStateError.as +0 -63
  28. data/src/com/adobe/fileformats/vcard/Address.as +0 -47
  29. data/src/com/adobe/fileformats/vcard/Email.as +0 -39
  30. data/src/com/adobe/fileformats/vcard/Phone.as +0 -39
  31. data/src/com/adobe/fileformats/vcard/VCard.as +0 -54
  32. data/src/com/adobe/fileformats/vcard/VCardParser.as +0 -246
  33. data/src/com/adobe/images/BitString.as +0 -39
  34. data/src/com/adobe/images/JPGEncoder.as +0 -648
  35. data/src/com/adobe/images/PNGEncoder.as +0 -141
  36. data/src/com/adobe/net/DynamicURLLoader.as +0 -55
  37. data/src/com/adobe/net/IURIResolver.as +0 -76
  38. data/src/com/adobe/net/MimeTypeMap.as +0 -200
  39. data/src/com/adobe/net/URI.as +0 -2466
  40. data/src/com/adobe/net/URIEncodingBitmap.as +0 -139
  41. data/src/com/adobe/net/proxies/RFC2817Socket.as +0 -198
  42. data/src/com/adobe/protocols/dict/Database.as +0 -66
  43. data/src/com/adobe/protocols/dict/Definition.as +0 -71
  44. data/src/com/adobe/protocols/dict/Dict.as +0 -360
  45. data/src/com/adobe/protocols/dict/DictionaryServer.as +0 -60
  46. data/src/com/adobe/protocols/dict/MatchStrategy.as +0 -66
  47. data/src/com/adobe/protocols/dict/Response.as +0 -71
  48. data/src/com/adobe/protocols/dict/events/ConnectedEvent.as +0 -53
  49. data/src/com/adobe/protocols/dict/events/DatabaseEvent.as +0 -67
  50. data/src/com/adobe/protocols/dict/events/DefinitionEvent.as +0 -70
  51. data/src/com/adobe/protocols/dict/events/DefinitionHeaderEvent.as +0 -69
  52. data/src/com/adobe/protocols/dict/events/DictionaryServerEvent.as +0 -69
  53. data/src/com/adobe/protocols/dict/events/DisconnectedEvent.as +0 -55
  54. data/src/com/adobe/protocols/dict/events/ErrorEvent.as +0 -80
  55. data/src/com/adobe/protocols/dict/events/MatchEvent.as +0 -67
  56. data/src/com/adobe/protocols/dict/events/MatchStrategiesEvent.as +0 -70
  57. data/src/com/adobe/protocols/dict/events/NoMatchEvent.as +0 -54
  58. data/src/com/adobe/protocols/dict/util/CompleteResponseEvent.as +0 -68
  59. data/src/com/adobe/protocols/dict/util/SocketHelper.as +0 -81
  60. data/src/com/adobe/serialization/json/JSON.as +0 -86
  61. data/src/com/adobe/serialization/json/JSONDecoder.as +0 -327
  62. data/src/com/adobe/serialization/json/JSONEncoder.as +0 -312
  63. data/src/com/adobe/serialization/json/JSONParseError.as +0 -87
  64. data/src/com/adobe/serialization/json/JSONToken.as +0 -104
  65. data/src/com/adobe/serialization/json/JSONTokenType.as +0 -69
  66. data/src/com/adobe/serialization/json/JSONTokenizer.as +0 -702
  67. data/src/com/adobe/utils/ArrayUtil.as +0 -187
  68. data/src/com/adobe/utils/DateUtil.as +0 -701
  69. data/src/com/adobe/utils/DictionaryUtil.as +0 -87
  70. data/src/com/adobe/utils/IntUtil.as +0 -99
  71. data/src/com/adobe/utils/NumberFormatter.as +0 -74
  72. data/src/com/adobe/utils/StringUtil.as +0 -239
  73. data/src/com/adobe/utils/XMLUtil.as +0 -168
  74. data/src/com/adobe/webapis/ServiceBase.as +0 -48
  75. data/src/com/adobe/webapis/URLLoaderBase.as +0 -108
  76. data/src/com/adobe/webapis/events/ServiceEvent.as +0 -82
  77. data/tests/src/CoreLibTestRunner-app.xml +0 -135
  78. data/tests/src/CoreLibTestRunner.as +0 -138
  79. data/tests/src/CoreLibTestRunner.mxml +0 -46
  80. data/tests/src/com/adobe/air/crypto/EncryptionKeyGeneratorTest.as +0 -176
  81. data/tests/src/com/adobe/air/filesystem/FileMonitorTest.as +0 -63
  82. data/tests/src/com/adobe/air/filesystem/VolumeMonitorTest.as +0 -57
  83. data/tests/src/com/adobe/air/filesystem/events/FileMonitorEventTest.as +0 -59
  84. data/tests/src/com/adobe/air/net/events/ResourceCacheEventTest.as +0 -72
  85. data/tests/src/com/adobe/crypto/HMACMD5Test.as +0 -134
  86. data/tests/src/com/adobe/crypto/HMACSHA1Test.as +0 -138
  87. data/tests/src/com/adobe/crypto/MD5Test.as +0 -82
  88. data/tests/src/com/adobe/crypto/SHA1Test.as +0 -151
  89. data/tests/src/com/adobe/crypto/SHA224Test.as +0 -104
  90. data/tests/src/com/adobe/crypto/SHA256Test.as +0 -116
  91. data/tests/src/com/adobe/crypto/WSSEUsernameTokenTest.as +0 -87
  92. data/tests/src/com/adobe/images/JPGEncoderTest.as +0 -54
  93. data/tests/src/com/adobe/images/PNGEncoderTest.as +0 -54
  94. data/tests/src/com/adobe/net/URITest.as +0 -589
  95. data/tests/src/com/adobe/protocols/events/ConnectedEventTest.as +0 -59
  96. data/tests/src/com/adobe/protocols/events/DatabaseEventTest.as +0 -62
  97. data/tests/src/com/adobe/protocols/events/DefinitionEventTest.as +0 -61
  98. data/tests/src/com/adobe/protocols/events/DefinitionHeaderEventTest.as +0 -61
  99. data/tests/src/com/adobe/protocols/events/DictionaryServerEventTest.as +0 -61
  100. data/tests/src/com/adobe/protocols/events/DisconnectedEventTest.as +0 -59
  101. data/tests/src/com/adobe/protocols/events/ErrorEventTest.as +0 -63
  102. data/tests/src/com/adobe/protocols/events/MatchEventTest.as +0 -61
  103. data/tests/src/com/adobe/protocols/events/MatchStrategiesEventTest.as +0 -61
  104. data/tests/src/com/adobe/protocols/events/NoMatchEventTest.as +0 -58
  105. data/tests/src/com/adobe/protocols/util/CompletedResponseEventTest.as +0 -60
  106. data/tests/src/com/adobe/serialization/json/JSONTest.as +0 -522
  107. data/tests/src/com/adobe/serialization/json/SimpleClass.as +0 -85
  108. data/tests/src/com/adobe/utils/ArrayUtilTest.as +0 -173
  109. data/tests/src/com/adobe/utils/DateUtilTest.as +0 -436
  110. data/tests/src/com/adobe/utils/DictionaryUtilTest.as +0 -93
  111. data/tests/src/com/adobe/utils/IntUtilTest.as +0 -73
  112. data/tests/src/com/adobe/utils/NumberFormatterTest.as +0 -70
  113. data/tests/src/com/adobe/utils/StringUtilTest.as +0 -304
  114. data/tests/src/com/adobe/utils/XMLUtilTest.as +0 -101
  115. data/tests/src/com/adobe/webapis/events/ServiceEventTest.as +0 -66
@@ -1,59 +0,0 @@
1
- /*
2
- Copyright (c) 2009, Adobe Systems Incorporated
3
- All rights reserved.
4
-
5
- Redistribution and use in source and binary forms, with or without
6
- modification, are permitted provided that the following conditions are
7
- met:
8
-
9
- * Redistributions of source code must retain the above copyright notice,
10
- this list of conditions and the following disclaimer.
11
-
12
- * Redistributions in binary form must reproduce the above copyright
13
- notice, this list of conditions and the following disclaimer in the
14
- documentation and/or other materials provided with the distribution.
15
-
16
- * Neither the name of Adobe Systems Incorporated nor the names of its
17
- contributors may be used to endorse or promote products derived from
18
- this software without specific prior written permission.
19
-
20
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
21
- IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22
- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23
- PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
- */
32
-
33
- package com.adobe.air.filesystem.events
34
- {
35
- import flexunit.framework.TestCase;
36
- import flash.filesystem.File;
37
-
38
- public class FileMonitorEventTest extends TestCase
39
- {
40
- public function FileMonitorEventTest(methodName:String=null)
41
- {
42
- super(methodName);
43
- }
44
-
45
- public function test_clone():void
46
- {
47
- var e1:FileMonitorEvent = new FileMonitorEvent(FileMonitorEvent.ADD_VOLUME);
48
- e1.file = new File();
49
-
50
- var e2:FileMonitorEvent = FileMonitorEvent(e1.clone());
51
-
52
- assertTrue("e1 != e2", e1 != e2);
53
- assertTrue("e1.cancelable == e2.cancelable", e1.cancelable == e2.cancelable);
54
- assertTrue("e1.bubbles == e2.bubbles", e1.bubbles == e2.bubbles);
55
- assertTrue("e1.type == e2.type", e1.type == e2.type);
56
- assertTrue("e1.file == e2.file", e1.file == e2.file);
57
- }
58
- }
59
- }
@@ -1,72 +0,0 @@
1
- /*
2
- Copyright (c) 2009, Adobe Systems Incorporated
3
- All rights reserved.
4
-
5
- Redistribution and use in source and binary forms, with or without
6
- modification, are permitted provided that the following conditions are
7
- met:
8
-
9
- * Redistributions of source code must retain the above copyright notice,
10
- this list of conditions and the following disclaimer.
11
-
12
- * Redistributions in binary form must reproduce the above copyright
13
- notice, this list of conditions and the following disclaimer in the
14
- documentation and/or other materials provided with the distribution.
15
-
16
- * Neither the name of Adobe Systems Incorporated nor the names of its
17
- contributors may be used to endorse or promote products derived from
18
- this software without specific prior written permission.
19
-
20
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
21
- IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22
- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23
- PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
- */
32
-
33
- package com.adobe.air.net.events
34
- {
35
- import flash.filesystem.File;
36
-
37
- import flexunit.framework.TestCase;
38
-
39
- public class ResourceCacheEventTest extends TestCase
40
- {
41
- public function ResourceCacheEventTest(methodName:String=null)
42
- {
43
- super(methodName);
44
- }
45
-
46
- public function test_clone():void
47
- {
48
- var type:String = ResourceCacheEvent.ITEM_CACHED;
49
- var key:String = "foo";
50
- var file:File = new File();
51
-
52
- var original:ResourceCacheEvent = new ResourceCacheEvent(type);
53
- original.key = key;
54
- original.file = file;
55
-
56
- var clone:ResourceCacheEvent = ResourceCacheEvent(original.clone());
57
-
58
- assertTrue("original != clone", original != clone);
59
-
60
- assertTrue("clone.bubbles == original.bubbles",
61
- clone.bubbles == original.bubbles);
62
- assertTrue("clone.cancelable == original.cancelable",
63
- clone.cancelable == original.cancelable);
64
- assertTrue("clone.type == original.type",
65
- clone.type == original.type);
66
- assertTrue("clone.key == original.key",
67
- clone.key == original.key);
68
- assertTrue("clone.file == original.file",
69
- clone.file == original.file);
70
- }
71
- }
72
- }
@@ -1,134 +0,0 @@
1
- /*
2
- Copyright (c) 2008, Adobe Systems Incorporated
3
- All rights reserved.
4
-
5
- Redistribution and use in source and binary forms, with or without
6
- modification, are permitted provided that the following conditions are
7
- met:
8
-
9
- * Redistributions of source code must retain the above copyright notice,
10
- this list of conditions and the following disclaimer.
11
-
12
- * Redistributions in binary form must reproduce the above copyright
13
- notice, this list of conditions and the following disclaimer in the
14
- documentation and/or other materials provided with the distribution.
15
-
16
- * Neither the name of Adobe Systems Incorporated nor the names of its
17
- contributors may be used to endorse or promote products derived from
18
- this software without specific prior written permission.
19
-
20
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
21
- IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22
- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23
- PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
- */
32
-
33
- package com.adobe.crypto
34
- {
35
-
36
- import flash.utils.ByteArray;
37
- import flexunit.framework.TestCase;
38
- import flexunit.framework.TestSuite;
39
-
40
- import com.adobe.crypto.HMAC;
41
-
42
- public class HMACMD5Test extends TestCase
43
- {
44
- private var key:ByteArray;
45
- private var data:ByteArray;
46
- private var x:int;
47
-
48
- public function HMACMD5Test( methodName:String = null) {
49
- super( methodName );
50
- }
51
-
52
- override public function setUp():void
53
- {
54
- super.setUp();
55
- key = new ByteArray();
56
- data = new ByteArray();
57
- }
58
-
59
- public function test1():void {
60
- for ( x = 0; x < 16; x++ ) {
61
- key.writeByte(0x0b);
62
- }
63
- data.writeUTFBytes("Hi There");
64
- assertHMAC(key, data, "9294727a3638bb1c13f48ef8158bfc9d");
65
- }
66
-
67
- public function test2():void {
68
- key.writeUTFBytes("Jefe");
69
- data.writeUTFBytes("what do ya want for nothing?");
70
- assertHMAC(key, data, "750c783e6ab0b503eaa86e310a5db738");
71
- }
72
-
73
- public function test3():void {
74
- for ( x = 0; x < 16; x++ ) {
75
- key.writeByte(0xaa);
76
- }
77
-
78
- for ( x = 0; x < 50; x++ ) {
79
- data.writeByte(0xdd);
80
- }
81
-
82
- assertHMAC(key, data, "56be34521d144c88dbb8c733f0e8b3f6");
83
- }
84
-
85
- public function test4():void {
86
- for ( x = 0; x < 25; x++ ) {
87
- key.writeByte( x + 1 );
88
- }
89
-
90
- for ( x = 0; x < 50; x++ ) {
91
- data.writeByte(0xcd);
92
- }
93
-
94
- assertHMAC(key, data, "697eaf0aca3a3aea3a75164746ffaa79");
95
- }
96
-
97
- public function test5():void {
98
- for ( x = 0; x < 16; x++ ) {
99
- key.writeByte(0x0c);
100
- }
101
-
102
- data.writeUTFBytes("Test With Truncation");
103
-
104
- assertHMAC(key, data, "56461ef2342edc00f9bab995690efd4c");
105
- }
106
-
107
- public function test6():void {
108
- for ( x = 0; x < 80; x++ ) {
109
- key.writeByte( 0xaa );
110
- }
111
-
112
- data.writeUTFBytes("Test Using Larger Than Block-Size Key - Hash Key First");
113
-
114
- assertHMAC(key, data, "6b1ab7fe4bd7bf8f0b62e6ce61b9d0cd");
115
- }
116
-
117
- public function test7():void {
118
- for ( x = 0; x < 80; x++ ) {
119
- key.writeByte( 0xaa );
120
- }
121
-
122
- data.writeUTFBytes("Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data");
123
-
124
- assertHMAC(key, data, "6f630fad67cda0ee1fb1f562db3aa53e");
125
- }
126
-
127
- private function assertHMAC( key:ByteArray, value:ByteArray, expected:String):void {
128
- assertTrue( "Hash of '" + value.toString() + "' with key '" + key.toString() + "' returned wrong value ('" + HMAC.hashBytes(key,value) + " ')",
129
- HMAC.hashBytes(key,value) == expected );
130
- };
131
-
132
- }
133
-
134
- }
@@ -1,138 +0,0 @@
1
- /*
2
- Copyright (c) 2008, Adobe Systems Incorporated
3
- All rights reserved.
4
-
5
- Redistribution and use in source and binary forms, with or without
6
- modification, are permitted provided that the following conditions are
7
- met:
8
-
9
- * Redistributions of source code must retain the above copyright notice,
10
- this list of conditions and the following disclaimer.
11
-
12
- * Redistributions in binary form must reproduce the above copyright
13
- notice, this list of conditions and the following disclaimer in the
14
- documentation and/or other materials provided with the distribution.
15
-
16
- * Neither the name of Adobe Systems Incorporated nor the names of its
17
- contributors may be used to endorse or promote products derived from
18
- this software without specific prior written permission.
19
-
20
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
21
- IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22
- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23
- PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
- */
32
-
33
- package com.adobe.crypto
34
- {
35
-
36
- import flash.utils.ByteArray;
37
- import flexunit.framework.TestCase;
38
- import flexunit.framework.TestSuite;
39
- import com.adobe.crypto.HMAC;
40
- import com.adobe.crypto.SHA1;
41
- /**
42
- * Test Cases for HMAC-MD5 and HMAC-SHA-1
43
- * Implementation based on test cases description at
44
- * http://www.faqs.org/rfcs/rfc2202.html
45
- */
46
- public class HMACSHA1Test extends TestCase
47
- {
48
- private var key:ByteArray;
49
- private var data:ByteArray;
50
- private var x:int;
51
-
52
- public function HMACSHA1Test( methodName:String = null) {
53
- super( methodName );
54
- }
55
-
56
- override public function setUp():void
57
- {
58
- super.setUp();
59
- key = new ByteArray();
60
- data = new ByteArray();
61
- }
62
-
63
- public function test1():void {
64
- for ( x = 0; x < 20; x++ ) {
65
- key.writeByte(0x0b);
66
- }
67
- data.writeUTFBytes("Hi There");
68
- assertHMAC(key, data, "b617318655057264e28bc0b6fb378c8ef146be00");
69
- }
70
-
71
- public function test2():void {
72
- key.writeUTFBytes("Jefe");
73
- data.writeUTFBytes("what do ya want for nothing?");
74
- assertHMAC(key, data, "effcdf6ae5eb2fa2d27416d5f184df9c259a7c79");
75
- }
76
-
77
- public function test3():void {
78
- for ( x = 0; x < 20; x++ ) {
79
- key.writeByte(0xaa);
80
- }
81
-
82
- for ( x = 0; x < 50; x++ ) {
83
- data.writeByte(0xdd);
84
- }
85
-
86
- assertHMAC(key, data, "125d7342b9ac11cd91a39af48aa17b4f63f175d3");
87
- }
88
-
89
- public function test4():void {
90
- for ( x = 0; x < 25; x++ ) {
91
- key.writeByte( x + 1 );
92
- }
93
-
94
- for ( x = 0; x < 50; x++ ) {
95
- data.writeByte(0xcd);
96
- }
97
-
98
- assertHMAC(key, data, "4c9007f4026250c6bc8414f9bf50c86c2d7235da");
99
- }
100
-
101
- public function test5():void {
102
- for ( x = 0; x < 20; x++ ) {
103
- key.writeByte(0x0c);
104
- }
105
-
106
- data.writeUTFBytes("Test With Truncation");
107
-
108
- assertHMAC(key, data, "4c1a03424b55e07fe7f27be1d58bb9324a9a5a04");
109
- }
110
-
111
- public function test6():void {
112
- for ( x = 0; x < 80; x++ ) {
113
- key.writeByte( 0xaa );
114
- }
115
-
116
- data.writeUTFBytes("Test Using Larger Than Block-Size Key - Hash Key First");
117
-
118
- assertHMAC(key, data, "aa4ae5e15272d00e95705637ce8a3b55ed402112");
119
- }
120
-
121
- public function test7():void {
122
- for ( x = 0; x < 80; x++ ) {
123
- key.writeByte( 0xaa );
124
- }
125
-
126
- data.writeUTFBytes("Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data");
127
-
128
- assertHMAC(key, data, "e8e99d0f45237d786d6bbaa7965c7808bbff1a91");
129
- }
130
-
131
- private function assertHMAC( key:ByteArray, value:ByteArray, expected:String):void {
132
- assertTrue( "Hash of '" + value.toString() + "' with key '" + key.toString() + "' returned wrong value ('" + HMAC.hashBytes(key,value,SHA1) + " ')",
133
- HMAC.hashBytes(key,value, SHA1) == expected );
134
- };
135
-
136
- }
137
-
138
- }
@@ -1,82 +0,0 @@
1
- /*
2
- Copyright (c) 2008, Adobe Systems Incorporated
3
- All rights reserved.
4
-
5
- Redistribution and use in source and binary forms, with or without
6
- modification, are permitted provided that the following conditions are
7
- met:
8
-
9
- * Redistributions of source code must retain the above copyright notice,
10
- this list of conditions and the following disclaimer.
11
-
12
- * Redistributions in binary form must reproduce the above copyright
13
- notice, this list of conditions and the following disclaimer in the
14
- documentation and/or other materials provided with the distribution.
15
-
16
- * Neither the name of Adobe Systems Incorporated nor the names of its
17
- contributors may be used to endorse or promote products derived from
18
- this software without specific prior written permission.
19
-
20
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
21
- IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22
- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23
- PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
- */
32
-
33
- package com.adobe.crypto
34
- {
35
-
36
- import flexunit.framework.TestCase;
37
- import flexunit.framework.TestSuite;
38
-
39
- import com.adobe.crypto.MD5;
40
-
41
- public class MD5Test extends TestCase {
42
-
43
- public function MD5Test( methodName:String = null) {
44
- super( methodName );
45
- }
46
-
47
- public function testEmpty():void {
48
- assertMD5( "", "d41d8cd98f00b204e9800998ecf8427e" );
49
- }
50
-
51
- public function testA():void {
52
- assertMD5( "a", "0cc175b9c0f1b6a831c399e269772661" );
53
- }
54
-
55
- public function testABC():void {
56
- assertMD5( "abc", "900150983cd24fb0d6963f7d28e17f72" );
57
- }
58
-
59
- public function testMD():void {
60
- assertMD5( "message digest", "f96b697d7cb7938d525a2f31aaf161d0" );
61
- }
62
-
63
- public function testAlphabet():void {
64
- assertMD5( "abcdefghijklmnopqrstuvwxyz", "c3fcd3d76192e4007dfb496cca67e13b" );
65
- }
66
-
67
- public function testAlphaNumeric():void {
68
- assertMD5( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", "d174ab98d277d9f5a5611c2c9f419d9f" );
69
- }
70
-
71
- public function testRepeatingNumeric():void {
72
- assertMD5( "12345678901234567890123456789012345678901234567890123456789012345678901234567890", "57edf4a22be3c955ac49da2e2107b67a" );
73
- }
74
-
75
- private function assertMD5( value:String, expected:String ):void {
76
- assertTrue( "Hash of '" + value + "' returned wrong value ('" + MD5.hash( value ) + " ')",
77
- MD5.hash( value ) == expected );
78
- };
79
-
80
- }
81
-
82
- }