rocket-js 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) hide show
  1. data/Rakefile +5 -52
  2. data/spec/ruby/spec_helper.rb +2 -1
  3. metadata +7 -129
  4. data/src/vendor/web-socket-js/FABridge.js +0 -604
  5. data/src/vendor/web-socket-js/README.txt +0 -109
  6. data/src/vendor/web-socket-js/WebSocketMain.swf +0 -0
  7. data/src/vendor/web-socket-js/WebSocketMainInsecure.zip +0 -0
  8. data/src/vendor/web-socket-js/flash-src/WebSocket.as +0 -473
  9. data/src/vendor/web-socket-js/flash-src/WebSocketMain.as +0 -88
  10. data/src/vendor/web-socket-js/flash-src/WebSocketMainInsecure.as +0 -19
  11. data/src/vendor/web-socket-js/flash-src/WebSocketStateEvent.as +0 -32
  12. data/src/vendor/web-socket-js/flash-src/bridge/FABridge.as +0 -943
  13. data/src/vendor/web-socket-js/flash-src/build.sh +0 -10
  14. data/src/vendor/web-socket-js/flash-src/com/adobe/net/proxies/RFC2817Socket.as +0 -204
  15. data/src/vendor/web-socket-js/flash-src/com/gsolo/encryption/MD5.as +0 -375
  16. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/Crypto.as +0 -287
  17. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/cert/MozillaRootCertificates.as +0 -3235
  18. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/cert/X509Certificate.as +0 -218
  19. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/cert/X509CertificateCollection.as +0 -57
  20. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/hash/HMAC.as +0 -82
  21. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/hash/IHMAC.as +0 -27
  22. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/hash/IHash.as +0 -21
  23. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/hash/MAC.as +0 -137
  24. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/hash/MD2.as +0 -124
  25. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/hash/MD5.as +0 -204
  26. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/hash/SHA1.as +0 -106
  27. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/hash/SHA224.as +0 -28
  28. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/hash/SHA256.as +0 -115
  29. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/hash/SHABase.as +0 -71
  30. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/prng/ARC4.as +0 -90
  31. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/prng/IPRNG.as +0 -20
  32. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/prng/Random.as +0 -119
  33. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/prng/TLSPRF.as +0 -142
  34. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/rsa/RSAKey.as +0 -339
  35. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/AESKey.as +0 -2797
  36. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/BlowFishKey.as +0 -375
  37. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/CBCMode.as +0 -55
  38. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/CFB8Mode.as +0 -61
  39. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/CFBMode.as +0 -64
  40. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/CTRMode.as +0 -58
  41. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/DESKey.as +0 -365
  42. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/ECBMode.as +0 -86
  43. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/ICipher.as +0 -21
  44. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/IMode.as +0 -15
  45. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/IPad.as +0 -32
  46. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/IStreamCipher.as +0 -21
  47. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/ISymmetricKey.as +0 -35
  48. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/IVMode.as +0 -110
  49. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/NullPad.as +0 -34
  50. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/OFBMode.as +0 -52
  51. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/PKCS5.as +0 -44
  52. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/SSLPad.as +0 -44
  53. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/SimpleIVMode.as +0 -60
  54. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/TLSPad.as +0 -42
  55. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/TripleDESKey.as +0 -88
  56. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/XTeaKey.as +0 -94
  57. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/aeskey.pl +0 -29
  58. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/dump.txt +0 -2304
  59. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/AESKeyTest.as +0 -1220
  60. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/ARC4Test.as +0 -58
  61. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/BigIntegerTest.as +0 -39
  62. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/BlowFishKeyTest.as +0 -148
  63. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/CBCModeTest.as +0 -160
  64. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/CFB8ModeTest.as +0 -71
  65. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/CFBModeTest.as +0 -98
  66. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/CTRModeTest.as +0 -109
  67. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/DESKeyTest.as +0 -112
  68. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/ECBModeTest.as +0 -151
  69. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/HMACTest.as +0 -184
  70. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/ITestHarness.as +0 -20
  71. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/MD2Test.as +0 -56
  72. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/MD5Test.as +0 -58
  73. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/OFBModeTest.as +0 -101
  74. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/RSAKeyTest.as +0 -92
  75. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/SHA1Test.as +0 -198
  76. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/SHA224Test.as +0 -58
  77. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/SHA256Test.as +0 -60
  78. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/TLSPRFTest.as +0 -51
  79. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/TestCase.as +0 -42
  80. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/TripleDESKeyTest.as +0 -59
  81. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/XTeaKeyTest.as +0 -66
  82. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/BulkCiphers.as +0 -102
  83. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/CipherSuites.as +0 -117
  84. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/IConnectionState.as +0 -14
  85. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/ISecurityParameters.as +0 -29
  86. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/KeyExchanges.as +0 -24
  87. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/MACs.as +0 -38
  88. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/SSLConnectionState.as +0 -171
  89. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/SSLEvent.as +0 -26
  90. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/SSLSecurityParameters.as +0 -340
  91. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/TLSConfig.as +0 -70
  92. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/TLSConnectionState.as +0 -151
  93. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/TLSEngine.as +0 -895
  94. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/TLSError.as +0 -39
  95. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/TLSEvent.as +0 -27
  96. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/TLSSecurityParameters.as +0 -197
  97. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/TLSSocket.as +0 -370
  98. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/TLSSocketEvent.as +0 -26
  99. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/TLSTest.as +0 -180
  100. data/src/vendor/web-socket-js/flash-src/com/hurlant/math/BarrettReduction.as +0 -90
  101. data/src/vendor/web-socket-js/flash-src/com/hurlant/math/BigInteger.as +0 -1543
  102. data/src/vendor/web-socket-js/flash-src/com/hurlant/math/ClassicReduction.as +0 -35
  103. data/src/vendor/web-socket-js/flash-src/com/hurlant/math/IReduction.as +0 -11
  104. data/src/vendor/web-socket-js/flash-src/com/hurlant/math/MontgomeryReduction.as +0 -85
  105. data/src/vendor/web-socket-js/flash-src/com/hurlant/math/NullReduction.as +0 -34
  106. data/src/vendor/web-socket-js/flash-src/com/hurlant/math/bi_internal.as +0 -11
  107. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/ArrayUtil.as +0 -25
  108. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/Base64.as +0 -189
  109. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/Hex.as +0 -66
  110. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/Memory.as +0 -28
  111. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/ByteString.as +0 -43
  112. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/DER.as +0 -210
  113. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/IAsn1Type.as +0 -21
  114. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/Integer.as +0 -44
  115. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/OID.as +0 -35
  116. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/ObjectIdentifier.as +0 -112
  117. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/PEM.as +0 -118
  118. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/PrintableString.as +0 -49
  119. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/Sequence.as +0 -90
  120. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/Set.as +0 -27
  121. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/Type.as +0 -94
  122. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/UTCTime.as +0 -60
  123. data/src/vendor/web-socket-js/sample.html +0 -76
  124. data/src/vendor/web-socket-js/swfobject.js +0 -4
  125. data/src/vendor/web-socket-js/web_socket.js +0 -388
@@ -1,35 +0,0 @@
1
- package com.hurlant.math
2
- {
3
- use namespace bi_internal;
4
-
5
- /**
6
- * Modular reduction using "classic" algorithm
7
- */
8
- internal class ClassicReduction implements IReduction
9
- {
10
- private var m:BigInteger;
11
- public function ClassicReduction(m:BigInteger) {
12
- this.m = m;
13
- }
14
- public function convert(x:BigInteger):BigInteger {
15
- if (x.s<0 || x.compareTo(m)>=0) {
16
- return x.mod(m);
17
- }
18
- return x;
19
- }
20
- public function revert(x:BigInteger):BigInteger {
21
- return x;
22
- }
23
- public function reduce(x:BigInteger):void {
24
- x.divRemTo(m, null,x);
25
- }
26
- public function mulTo(x:BigInteger, y:BigInteger, r:BigInteger):void {
27
- x.multiplyTo(y,r);
28
- reduce(r);
29
- }
30
- public function sqrTo(x:BigInteger, r:BigInteger):void {
31
- x.squareTo(r);
32
- reduce(r);
33
- }
34
- }
35
- }
@@ -1,11 +0,0 @@
1
- package com.hurlant.math
2
- {
3
- internal interface IReduction
4
- {
5
- function convert(x:BigInteger):BigInteger;
6
- function revert(x:BigInteger):BigInteger;
7
- function reduce(x:BigInteger):void;
8
- function mulTo(x:BigInteger, y:BigInteger, r:BigInteger):void;
9
- function sqrTo(x:BigInteger, r:BigInteger):void;
10
- }
11
- }
@@ -1,85 +0,0 @@
1
- package com.hurlant.math
2
- {
3
- use namespace bi_internal;
4
- /**
5
- * Montgomery reduction
6
- */
7
- internal class MontgomeryReduction implements IReduction
8
- {
9
- private var m:BigInteger;
10
- private var mp:int;
11
- private var mpl:int;
12
- private var mph:int;
13
- private var um:int;
14
- private var mt2:int;
15
- public function MontgomeryReduction(m:BigInteger) {
16
- this.m = m;
17
- mp = m.invDigit();
18
- mpl = mp & 0x7fff;
19
- mph = mp>>15;
20
- um = (1<<(BigInteger.DB-15))-1;
21
- mt2 = 2*m.t;
22
- }
23
- /**
24
- * xR mod m
25
- */
26
- public function convert(x:BigInteger):BigInteger {
27
- var r:BigInteger = new BigInteger;
28
- x.abs().dlShiftTo(m.t, r);
29
- r.divRemTo(m, null, r);
30
- if (x.s<0 && r.compareTo(BigInteger.ZERO)>0) {
31
- m.subTo(r,r);
32
- }
33
- return r;
34
- }
35
- /**
36
- * x/R mod m
37
- */
38
- public function revert(x:BigInteger):BigInteger {
39
- var r:BigInteger = new BigInteger;
40
- x.copyTo(r);
41
- reduce(r);
42
- return r;
43
- }
44
- /**
45
- * x = x/R mod m (HAC 14.32)
46
- */
47
- public function reduce(x:BigInteger):void {
48
- while (x.t<=mt2) { // pad x so am has enough room later
49
- x.a[x.t++] = 0;
50
- }
51
- for (var i:int=0; i<m.t; ++i) {
52
- // faster way of calculating u0 = x[i]*mp mod DV
53
- var j:int = x.a[i]&0x7fff;
54
- var u0:int = (j*mpl+(((j*mph+(x.a[i]>>15)*mpl)&um)<<15))&BigInteger.DM;
55
- // use am to combine the multiply-shift-add into one call
56
- j = i+m.t;
57
- x.a[j] += m.am(0, u0, x, i, 0, m.t);
58
- // propagate carry
59
- while (x.a[j]>=BigInteger.DV) {
60
- x.a[j] -= BigInteger.DV;
61
- x.a[++j]++;
62
- }
63
- }
64
- x.clamp();
65
- x.drShiftTo(m.t, x);
66
- if (x.compareTo(m)>=0) {
67
- x.subTo(m,x);
68
- }
69
- }
70
- /**
71
- * r = "x^2/R mod m"; x != r
72
- */
73
- public function sqrTo(x:BigInteger, r:BigInteger):void {
74
- x.squareTo(r);
75
- reduce(r);
76
- }
77
- /**
78
- * r = "xy/R mod m"; x,y != r
79
- */
80
- public function mulTo(x:BigInteger, y:BigInteger, r:BigInteger):void {
81
- x.multiplyTo(y,r);
82
- reduce(r);
83
- }
84
- }
85
- }
@@ -1,34 +0,0 @@
1
- package com.hurlant.math
2
- {
3
- use namespace bi_internal;
4
- /**
5
- * A "null" reducer
6
- */
7
- public class NullReduction implements IReduction
8
- {
9
- public function revert(x:BigInteger):BigInteger
10
- {
11
- return x;
12
- }
13
-
14
- public function mulTo(x:BigInteger, y:BigInteger, r:BigInteger):void
15
- {
16
- x.multiplyTo(y,r);
17
- }
18
-
19
- public function sqrTo(x:BigInteger, r:BigInteger):void
20
- {
21
- x.squareTo(r);
22
- }
23
-
24
- public function convert(x:BigInteger):BigInteger
25
- {
26
- return x;
27
- }
28
-
29
- public function reduce(x:BigInteger):void
30
- {
31
- }
32
-
33
- }
34
- }
@@ -1,11 +0,0 @@
1
- /**
2
- * bi_internal
3
- *
4
- * A namespace. w00t.
5
- * Copyright (c) 2007 Henri Torgemane
6
- *
7
- * See LICENSE.txt for full license information.
8
- */
9
- package com.hurlant.math {
10
- public namespace bi_internal = "http://crypto.hurlant.com/BigInteger";
11
- }
@@ -1,25 +0,0 @@
1
- /**
2
- * ArrayUtil
3
- *
4
- * A class that allows to compare two ByteArrays.
5
- * Copyright (c) 2007 Henri Torgemane
6
- *
7
- * See LICENSE.txt for full license information.
8
- */
9
- package com.hurlant.util {
10
- import flash.utils.ByteArray;
11
-
12
-
13
- public class ArrayUtil {
14
-
15
- public static function equals(a1:ByteArray, a2:ByteArray):Boolean {
16
- if (a1.length != a2.length) return false;
17
- var l:int = a1.length;
18
- for (var i:int=0;i<l;i++) {
19
- if (a1[i]!=a2[i]) return false;
20
- }
21
- return true;
22
- }
23
- }
24
-
25
- }
@@ -1,189 +0,0 @@
1
- /* Base64 library for ActionScript 3.0.
2
- * Based on: Ma Bingyao code.
3
- * Optimized by: Jean-Philippe Auclair / jpauclair.wordpress.com
4
- * Copyright (C) 2007 Ma Bingyao <andot@ujn.edu.cn>
5
- * LastModified: Oct 26, 2009
6
- * This library is free. You can redistribute it and/or modify it.
7
- */
8
- package com.hurlant.util{
9
- import flash.utils.ByteArray;
10
-
11
- public class Base64
12
- {
13
- private static const _encodeChars : Vector.<int> = InitEncoreChar();
14
- private static const _decodeChars : Vector.<int> = InitDecodeChar();
15
-
16
- public static function encodeByteArray(data : ByteArray) : String
17
- {
18
- var out : ByteArray = new ByteArray();
19
- //Presetting the length keep the memory smaller and optimize speed since there is no "grow" needed
20
- out.length = (2 + data.length - ((data.length + 2) % 3)) * 4 / 3; //Preset length //1.6 to 1.5 ms
21
- var i : int = 0;
22
- var r : int = data.length % 3;
23
- var len : int = data.length - r;
24
- var c : int; //read (3) character AND write (4) characters
25
-
26
- while (i < len)
27
- {
28
- //Read 3 Characters (8bit * 3 = 24 bits)
29
- c = data[i++] << 16 | data[i++] << 8 | data[i++];
30
-
31
- //Cannot optimize this to read int because of the positioning overhead. (as3 bytearray seek is slow)
32
- //Convert to 4 Characters (6 bit * 4 = 24 bits)
33
- c = (_encodeChars[c >>> 18] << 24) | (_encodeChars[c >>> 12 & 0x3f] << 16) | (_encodeChars[c >>> 6 & 0x3f] << 8) | _encodeChars[c & 0x3f];
34
-
35
- //Optimization: On older and slower computer, do one write Int instead of 4 write byte: 1.5 to 0.71 ms
36
- out.writeInt(c);
37
- /*
38
- out.writeByte(_encodeChars[c >> 18] );
39
- out.writeByte(_encodeChars[c >> 12 & 0x3f]);
40
- out.writeByte(_encodeChars[c >> 6 & 0x3f]);
41
- out.writeByte(_encodeChars[c & 0x3f]);
42
- */
43
- }
44
-
45
- if (r == 1) //Need two "=" padding
46
- {
47
- //Read one char, write two chars, write padding
48
- c = data[i];
49
- c = (_encodeChars[c >>> 2] << 24) | (_encodeChars[(c & 0x03) << 4] << 16) | 61 << 8 | 61;
50
- out.writeInt(c);
51
- }
52
- else if (r == 2) //Need one "=" padding
53
- {
54
- c = data[i++] << 8 | data[i];
55
- c = (_encodeChars[c >>> 10] << 24) | (_encodeChars[c >>> 4 & 0x3f] << 16) | (_encodeChars[(c & 0x0f) << 2] << 8) | 61;
56
- out.writeInt(c);
57
- }
58
-
59
- out.position = 0;
60
- return out.readUTFBytes(out.length);
61
- }
62
-
63
-
64
- public static function decodeToByteArray(str : String) : ByteArray
65
- {
66
- var c1 : int;
67
- var c2 : int;
68
- var c3 : int;
69
- var c4 : int;
70
- var i : int;
71
- var len : int;
72
- var out : ByteArray;
73
- len = str.length;
74
- i = 0;
75
- out = new ByteArray();
76
- var byteString : ByteArray = new ByteArray();
77
- byteString.writeUTFBytes(str);
78
- while (i < len)
79
- {
80
- //c1
81
- do
82
- {
83
- c1 = _decodeChars[byteString[i++]];
84
- } while (i < len && c1 == -1);
85
- if (c1 == -1) break;
86
-
87
- //c2
88
- do
89
- {
90
- c2 = _decodeChars[byteString[i++]];
91
- } while (i < len && c2 == -1);
92
- if (c2 == -1) break;
93
-
94
- out.writeByte((c1 << 2) | ((c2 & 0x30) >> 4));
95
-
96
- //c3
97
- do
98
- {
99
- c3 = byteString[i++];
100
- if (c3 == 61) return out;
101
-
102
- c3 = _decodeChars[c3];
103
- } while (i < len && c3 == -1);
104
- if (c3 == -1) break;
105
-
106
- out.writeByte(((c2 & 0x0f) << 4) | ((c3 & 0x3c) >> 2));
107
-
108
- //c4
109
- do {
110
- c4 = byteString[i++];
111
- if (c4 == 61) return out;
112
-
113
- c4 = _decodeChars[c4];
114
- } while (i < len && c4 == -1);
115
- if (c4 == -1) break;
116
-
117
- out.writeByte(((c3 & 0x03) << 6) | c4);
118
-
119
- }
120
-
121
- out.position = 0;
122
-
123
- return out;
124
- }
125
-
126
- public static function encode(data : String) : String {
127
- // Convert string to ByteArray
128
- var bytes : ByteArray = new ByteArray();
129
- bytes.writeUTFBytes(data);
130
-
131
- // Return encoded ByteArray
132
- return encodeByteArray(bytes);
133
- }
134
-
135
- public static function decode(data : String) : String {
136
- // Decode data to ByteArray
137
- var bytes : ByteArray = decodeToByteArray(data);
138
-
139
- // Convert to string and return
140
- return bytes.readUTFBytes(bytes.length);
141
- }
142
-
143
- public static function InitEncoreChar() : Vector.<int>
144
- {
145
- var encodeChars : Vector.<int> = new Vector.<int>();
146
- // We could push the number directly, but i think it's nice to see the characters (with no overhead on encode/decode)
147
- var chars : String = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
148
- for (var i : int = 0; i < 64; i++)
149
- {
150
- encodeChars.push(chars.charCodeAt(i));
151
- }
152
- /*
153
- encodeChars.push(
154
- 65, 66, 67, 68, 69, 70, 71, 72,
155
- 73, 74, 75, 76, 77, 78, 79, 80,
156
- 81, 82, 83, 84, 85, 86, 87, 88,
157
- 89, 90, 97, 98, 99, 100, 101, 102,
158
- 103, 104, 105, 106, 107, 108, 109, 110,
159
- 111, 112, 113, 114, 115, 116, 117, 118,
160
- 119, 120, 121, 122, 48, 49, 50, 51,
161
- 52, 53, 54, 55, 56, 57, 43, 47);
162
- */
163
- return encodeChars;
164
- }
165
-
166
- public static function InitDecodeChar() : Vector.<int>
167
- {
168
- var decodeChars : Vector.<int> = new Vector.<int>();
169
-
170
- decodeChars.push(-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
171
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
172
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
173
- 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1,
174
- -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
175
- 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1,
176
- -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
177
- 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1
178
- - 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
179
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
180
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
181
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
182
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
183
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
184
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
185
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1);
186
- return decodeChars;
187
- }
188
- }
189
- }
@@ -1,66 +0,0 @@
1
- /**
2
- * Hex
3
- *
4
- * Utility class to convert Hex strings to ByteArray or String types.
5
- * Copyright (c) 2007 Henri Torgemane
6
- *
7
- * See LICENSE.txt for full license information.
8
- */
9
- package com.hurlant.util
10
- {
11
- import flash.utils.ByteArray;
12
-
13
- public class Hex
14
- {
15
- /**
16
- * Support straight hex, or colon-laced hex.
17
- * (that means 23:03:0e:f0, but *NOT* 23:3:e:f0)
18
- * Whitespace characters are ignored.
19
- */
20
- public static function toArray(hex:String):ByteArray {
21
- hex = hex.replace(/\s|:/gm,'');
22
- var a:ByteArray = new ByteArray;
23
- if (hex.length&1==1) hex="0"+hex;
24
- for (var i:uint=0;i<hex.length;i+=2) {
25
- a[i/2] = parseInt(hex.substr(i,2),16);
26
- }
27
- return a;
28
- }
29
-
30
- public static function fromArray(array:ByteArray, colons:Boolean=false):String {
31
- var s:String = "";
32
- for (var i:uint=0;i<array.length;i++) {
33
- s+=("0"+array[i].toString(16)).substr(-2,2);
34
- if (colons) {
35
- if (i<array.length-1) s+=":";
36
- }
37
- }
38
- return s;
39
- }
40
-
41
- /**
42
- *
43
- * @param hex
44
- * @return a UTF-8 string decoded from hex
45
- *
46
- */
47
- public static function toString(hex:String):String {
48
- var a:ByteArray = toArray(hex);
49
- return a.readUTFBytes(a.length);
50
- }
51
-
52
-
53
- /**
54
- *
55
- * @param str
56
- * @return a hex string encoded from the UTF-8 string str
57
- *
58
- */
59
- public static function fromString(str:String, colons:Boolean=false):String {
60
- var a:ByteArray = new ByteArray;
61
- a.writeUTFBytes(str);
62
- return fromArray(a, colons);
63
- }
64
-
65
- }
66
- }