dango_generator 0.0.38

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. data/LICENSE +16 -0
  2. data/README.txt +41 -0
  3. data/dango_generator.rb +99 -0
  4. data/templates/as3/as3corelib-license.txt +33 -0
  5. data/templates/as3/as3corelib-readme.txt +5 -0
  6. data/templates/as3/com/adobe/crypto/MD5.as +256 -0
  7. data/templates/as3/com/adobe/crypto/SHA1.as +268 -0
  8. data/templates/as3/com/adobe/crypto/SHA224.as +255 -0
  9. data/templates/as3/com/adobe/crypto/SHA256.as +260 -0
  10. data/templates/as3/com/adobe/crypto/WSSEUsernameToken.as +117 -0
  11. data/templates/as3/com/adobe/errors/IllegalStateError.as +66 -0
  12. data/templates/as3/com/adobe/images/BitString.as +42 -0
  13. data/templates/as3/com/adobe/images/JPGEncoder.as +651 -0
  14. data/templates/as3/com/adobe/images/PNGEncoder.as +144 -0
  15. data/templates/as3/com/adobe/net/DynamicURLLoader.as +58 -0
  16. data/templates/as3/com/adobe/net/IURIResolver.as +79 -0
  17. data/templates/as3/com/adobe/net/URI.as +2469 -0
  18. data/templates/as3/com/adobe/net/URIEncodingBitmap.as +142 -0
  19. data/templates/as3/com/adobe/net/proxies/RFC2817Socket.as +204 -0
  20. data/templates/as3/com/adobe/serialization/json/JSON.as +88 -0
  21. data/templates/as3/com/adobe/serialization/json/JSONDecoder.as +218 -0
  22. data/templates/as3/com/adobe/serialization/json/JSONEncoder.as +302 -0
  23. data/templates/as3/com/adobe/serialization/json/JSONParseError.as +90 -0
  24. data/templates/as3/com/adobe/serialization/json/JSONToken.as +107 -0
  25. data/templates/as3/com/adobe/serialization/json/JSONTokenType.as +70 -0
  26. data/templates/as3/com/adobe/serialization/json/JSONTokenizer.as +550 -0
  27. data/templates/as3/com/adobe/utils/ArrayUtil.as +190 -0
  28. data/templates/as3/com/adobe/utils/DateUtil.as +666 -0
  29. data/templates/as3/com/adobe/utils/DictionaryUtil.as +90 -0
  30. data/templates/as3/com/adobe/utils/IntUtil.as +69 -0
  31. data/templates/as3/com/adobe/utils/NumberFormatter.as +77 -0
  32. data/templates/as3/com/adobe/utils/StringUtil.as +257 -0
  33. data/templates/as3/com/adobe/utils/XMLUtil.as +171 -0
  34. data/templates/as3/com/adobe/webapis/ServiceBase.as +51 -0
  35. data/templates/as3/com/adobe/webapis/URLLoaderBase.as +111 -0
  36. data/templates/as3/com/adobe/webapis/events/ServiceEvent.as +78 -0
  37. data/templates/as3/org/rubyforge/dango/DangoClientFramework.as +426 -0
  38. data/templates/as3/org/rubyforge/dango/DangoError.as +11 -0
  39. data/templates/as3/org/rubyforge/dango/DangoErrorCode.as +7 -0
  40. data/templates/as3/org/rubyforge/dango/DangoErrorEvent.as +23 -0
  41. data/templates/as3/org/rubyforge/dango/DangoReceiveEvent.as +21 -0
  42. data/templates/as3/org/rubyforge/dango/DangoURLLoader.as +127 -0
  43. data/templates/as3/org/rubyforge/dango/DangoURLLoaderEvent.as +29 -0
  44. data/templates/as3/org/rubyforge/dango/DangoUtil.as +84 -0
  45. data/templates/dango/config/development.yml +28 -0
  46. data/templates/dango/config/production.yml +3 -0
  47. data/templates/dango/config/system_message.yml +5 -0
  48. data/templates/dango/config/test.yml +3 -0
  49. data/templates/dango/server/99_dango_server.rb +22 -0
  50. data/templates/lib/dango_monitor_client.rb +1 -0
  51. data/templates/lib/dango_tester_client.rb +1 -0
  52. data/templates/script/dango_server +36 -0
  53. data/templates/tasks/dango.rake +2 -0
  54. metadata +108 -0
data/LICENSE ADDED
@@ -0,0 +1,16 @@
1
+ Copyright (C) 2007 Keisuke Minami
2
+
3
+ This library is free software; you can redistribute it and/or
4
+ modify it under the terms of the GNU Lesser General Public
5
+ License as published by the Free Software Foundation; either
6
+ version 2.1 of the License, or (at your option) any later version.
7
+
8
+ This library is distributed in the hope that it will be useful,
9
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
+ Lesser General Public License for more details.
12
+
13
+ You should have received a copy of the GNU Lesser General Public
14
+ License along with this library; if not, write to the Free Software
15
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
+
data/README.txt ADDED
@@ -0,0 +1,41 @@
1
+ = dango -- Realtime communications network framework for Ruby and Flash on Rails.
2
+
3
+
4
+ == Download
5
+
6
+ The latest version of dango can be found at
7
+
8
+ * http://rubyforge.org/frs/?group_id=****
9
+
10
+ == Installation
11
+
12
+ === Normal Installation
13
+
14
+ You can install dango with the following command.
15
+
16
+ % ruby setup.rb
17
+
18
+ from its distribution directory.
19
+
20
+ === GEM Installation
21
+
22
+ Download and install dango with the following.
23
+
24
+ gem install dango
25
+
26
+ == dango References
27
+
28
+ * dango Project Page: http://rubyforge.org/projects/dango
29
+ * dango Download Page: http://rubyforge.org/projects/dango
30
+ * dango API Documents: http://dango.rubyforge.org
31
+
32
+ == Simple Example
33
+
34
+ == Licence
35
+
36
+ This code is free to use under the terms of the MIT licence.
37
+
38
+ == Contact
39
+
40
+ Comments are welcome. Send an email to "Keisuke Minami":mailto:keisuke@rccn.com
41
+
@@ -0,0 +1,99 @@
1
+ require "open-uri"
2
+
3
+ class DangoGenerator < Rails::Generator::NamedBase
4
+ def manifest
5
+ record do |m|
6
+
7
+ # dangoの初期設定
8
+ if name == "init"
9
+
10
+ # 起動スクリプト
11
+ m.template "script/dango_server" , "script/dango_server"
12
+
13
+ # vendorプラグイン
14
+ m.directory 'vendor/plugins/dango/lib'
15
+ m.template "lib/dango_monitor_client.rb" , "vendor/plugins/dango/lib/dango_monitor_client.rb"
16
+ m.template "lib/dango_tester_client.rb" , "vendor/plugins/dango/lib/dango_tester_client.rb"
17
+ m.directory 'vendor/plugins/dango/tasks'
18
+ m.template "tasks/dango.rake" , "vendor/plugins/dango/tasks/dango.rake"
19
+
20
+ # dangoフォルダ内
21
+ m.directory 'dango/server'
22
+ m.template "dango/server/99_dango_server.rb" , "dango/server/99_dango_server.rb"
23
+
24
+ # dangoコンフィグ
25
+ m.directory 'dango/config'
26
+ %w(
27
+ development.yml
28
+ test.yml
29
+ production.yml
30
+ system_message.yml
31
+ ).each do |as3_file|
32
+ m.template "dango/config/#{as3_file}", "dango/config/#{as3_file}"
33
+ end
34
+
35
+ # dangoのas3ライブラリ
36
+ m.directory 'dango/client_swf/org/rubyforge/dango'
37
+ %w(
38
+ DangoClientFramework.as
39
+ DangoError.as
40
+ DangoErrorCode.as
41
+ DangoErrorEvent.as
42
+ DangoReceiveEvent.as
43
+ DangoURLLoader.as
44
+ DangoURLLoaderEvent.as
45
+ DangoUtil.as
46
+ ).each do |as3_file|
47
+ m.template "as3/org/rubyforge/dango/#{as3_file}", "dango/client_swf/org/rubyforge/dango/#{as3_file}"
48
+ end
49
+
50
+ # as3corelibのインポート
51
+ %w(
52
+ as3corelib-readme.txt
53
+ as3corelib-license.txt
54
+ com/adobe/crypto/MD5.as
55
+ com/adobe/crypto/SHA1.as
56
+ com/adobe/crypto/SHA224.as
57
+ com/adobe/crypto/SHA256.as
58
+ com/adobe/crypto/WSSEUsernameToken.as
59
+ com/adobe/errors/IllegalStateError.as
60
+ com/adobe/images/BitString.as
61
+ com/adobe/images/JPGEncoder.as
62
+ com/adobe/images/PNGEncoder.as
63
+ com/adobe/net/DynamicURLLoader.as
64
+ com/adobe/net/IURIResolver.as
65
+ com/adobe/net/URI.as
66
+ com/adobe/net/URIEncodingBitmap.as
67
+ com/adobe/net/proxies/RFC2817Socket.as
68
+ com/adobe/serialization/json/JSON.as
69
+ com/adobe/serialization/json/JSONDecoder.as
70
+ com/adobe/serialization/json/JSONEncoder.as
71
+ com/adobe/serialization/json/JSONParseError.as
72
+ com/adobe/serialization/json/JSONToken.as
73
+ com/adobe/serialization/json/JSONTokenizer.as
74
+ com/adobe/serialization/json/JSONTokenType.as
75
+ com/adobe/utils/ArrayUtil.as
76
+ com/adobe/utils/DateUtil.as
77
+ com/adobe/utils/DictionaryUtil.as
78
+ com/adobe/utils/IntUtil.as
79
+ com/adobe/utils/NumberFormatter.as
80
+ com/adobe/utils/StringUtil.as
81
+ com/adobe/utils/XMLUtil.as
82
+ com/adobe/webapis/ServiceBase.as
83
+ com/adobe/webapis/URLLoaderBase.as
84
+ com/adobe/webapis/events/ServiceEvent.as
85
+ ).each do |as3corelib_file|
86
+ puts as3corelib_file
87
+ m.directory File.dirname("dango/client_swf/#{as3corelib_file}")
88
+ m.template "as3/#{as3corelib_file}", "dango/client_swf/#{as3corelib_file}"
89
+ end
90
+
91
+ puts "completed to initialize dango"
92
+ end
93
+ end
94
+
95
+ end # end manifest
96
+
97
+ attr_accessor :controller_class_name
98
+
99
+ end
@@ -0,0 +1,33 @@
1
+ Adobe Systems Incorporated(r) Source Code License Agreement
2
+ Copyright(c) 2005 Adobe Systems Incorporated. All rights reserved.
3
+
4
+ Please read this Source Code License Agreement carefully before using
5
+ the source code.
6
+
7
+ Adobe Systems Incorporated grants to you a perpetual, worldwide,
8
+ non-exclusive, no-charge, royalty-free, irrevocable copyright license,
9
+ to reproduce, prepare derivative works of, publicly display, publicly
10
+ perform, and distribute this source code and such derivative works in
11
+ source or object code form without any attribution requirements.
12
+
13
+ The name "Adobe Systems Incorporated" must not be used to endorse or
14
+ promote products derived from the source code without prior written
15
+ permission.
16
+
17
+ You agree to indemnify, hold harmless and defend Adobe Systems
18
+ Incorporated from and against any loss, damage, claims or lawsuits,
19
+ including attorney's fees that arise or result from your use or
20
+ distribution of the source code.
21
+
22
+ THIS SOURCE CODE IS PROVIDED "AS IS" AND "WITH ALL FAULTS", WITHOUT ANY
23
+ TECHNICAL SUPPORT OR ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
24
+ BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
25
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ALSO, THERE IS NO
26
+ WARRANTY OF NON-INFRINGEMENT, TITLE OR QUIET ENJOYMENT. IN NO EVENT
27
+ SHALL MACROMEDIA OR ITS SUPPLIERS BE LIABLE FOR ANY DIRECT, INDIRECT,
28
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29
+ BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
30
+ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
31
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33
+ OF THIS SOURCE CODE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,5 @@
1
+ corelib ActionScript 3 Library
2
+ Release version .90
3
+
4
+ Project Homepage:
5
+ http://code.google.com/p/as3corelib/
@@ -0,0 +1,256 @@
1
+ /*
2
+ Adobe Systems Incorporated(r) Source Code License Agreement
3
+ Copyright(c) 2005 Adobe Systems Incorporated. All rights reserved.
4
+
5
+ Please read this Source Code License Agreement carefully before using
6
+ the source code.
7
+
8
+ Adobe Systems Incorporated grants to you a perpetual, worldwide, non-exclusive,
9
+ no-charge, royalty-free, irrevocable copyright license, to reproduce,
10
+ prepare derivative works of, publicly display, publicly perform, and
11
+ distribute this source code and such derivative works in source or
12
+ object code form without any attribution requirements.
13
+
14
+ The name "Adobe Systems Incorporated" must not be used to endorse or promote products
15
+ derived from the source code without prior written permission.
16
+
17
+ You agree to indemnify, hold harmless and defend Adobe Systems Incorporated from and
18
+ against any loss, damage, claims or lawsuits, including attorney's
19
+ fees that arise or result from your use or distribution of the source
20
+ code.
21
+
22
+ THIS SOURCE CODE IS PROVIDED "AS IS" AND "WITH ALL FAULTS", WITHOUT
23
+ ANY TECHNICAL SUPPORT OR ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
24
+ BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25
+ FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ALSO, THERE IS NO WARRANTY OF
26
+ NON-INFRINGEMENT, TITLE OR QUIET ENJOYMENT. IN NO EVENT SHALL MACROMEDIA
27
+ OR ITS SUPPLIERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
28
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
29
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
30
+ OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
31
+ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
32
+ OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOURCE CODE, EVEN IF
33
+ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+ */
35
+
36
+ package com.adobe.crypto {
37
+
38
+ import com.adobe.utils.IntUtil;
39
+
40
+ /**
41
+ * The MD5 Message-Digest Algorithm
42
+ *
43
+ * Implementation based on algorithm description at
44
+ * http://www.faqs.org/rfcs/rfc1321.html
45
+ */
46
+ public class MD5 {
47
+
48
+ /**
49
+ * Performs the MD5 hash algorithm on a string.
50
+ *
51
+ * @param s The string to hash
52
+ * @return A string containing the hash value of s
53
+ * @langversion ActionScript 3.0
54
+ * @playerversion Flash 9.0
55
+ * @tiptext
56
+ */
57
+ public static function hash( s:String ):String {
58
+ // initialize the md buffers
59
+ var a:int = 1732584193;
60
+ var b:int = -271733879;
61
+ var c:int = -1732584194;
62
+ var d:int = 271733878;
63
+
64
+ // variables to store previous values
65
+ var aa:int;
66
+ var bb:int;
67
+ var cc:int;
68
+ var dd:int;
69
+
70
+ // create the blocks from the string and
71
+ // save the length as a local var to reduce
72
+ // lookup in the loop below
73
+ var x:Array = createBlocks( s );
74
+ var len:int = x.length;
75
+
76
+ // loop over all of the blocks
77
+ for ( var i:int = 0; i < len; i += 16) {
78
+ // save previous values
79
+ aa = a;
80
+ bb = b;
81
+ cc = c;
82
+ dd = d;
83
+
84
+ // Round 1
85
+ a = ff( a, b, c, d, x[i+ 0], 7, -680876936 ); // 1
86
+ d = ff( d, a, b, c, x[i+ 1], 12, -389564586 ); // 2
87
+ c = ff( c, d, a, b, x[i+ 2], 17, 606105819 ); // 3
88
+ b = ff( b, c, d, a, x[i+ 3], 22, -1044525330 ); // 4
89
+ a = ff( a, b, c, d, x[i+ 4], 7, -176418897 ); // 5
90
+ d = ff( d, a, b, c, x[i+ 5], 12, 1200080426 ); // 6
91
+ c = ff( c, d, a, b, x[i+ 6], 17, -1473231341 ); // 7
92
+ b = ff( b, c, d, a, x[i+ 7], 22, -45705983 ); // 8
93
+ a = ff( a, b, c, d, x[i+ 8], 7, 1770035416 ); // 9
94
+ d = ff( d, a, b, c, x[i+ 9], 12, -1958414417 ); // 10
95
+ c = ff( c, d, a, b, x[i+10], 17, -42063 ); // 11
96
+ b = ff( b, c, d, a, x[i+11], 22, -1990404162 ); // 12
97
+ a = ff( a, b, c, d, x[i+12], 7, 1804603682 ); // 13
98
+ d = ff( d, a, b, c, x[i+13], 12, -40341101 ); // 14
99
+ c = ff( c, d, a, b, x[i+14], 17, -1502002290 ); // 15
100
+ b = ff( b, c, d, a, x[i+15], 22, 1236535329 ); // 16
101
+
102
+ // Round 2
103
+ a = gg( a, b, c, d, x[i+ 1], 5, -165796510 ); // 17
104
+ d = gg( d, a, b, c, x[i+ 6], 9, -1069501632 ); // 18
105
+ c = gg( c, d, a, b, x[i+11], 14, 643717713 ); // 19
106
+ b = gg( b, c, d, a, x[i+ 0], 20, -373897302 ); // 20
107
+ a = gg( a, b, c, d, x[i+ 5], 5, -701558691 ); // 21
108
+ d = gg( d, a, b, c, x[i+10], 9, 38016083 ); // 22
109
+ c = gg( c, d, a, b, x[i+15], 14, -660478335 ); // 23
110
+ b = gg( b, c, d, a, x[i+ 4], 20, -405537848 ); // 24
111
+ a = gg( a, b, c, d, x[i+ 9], 5, 568446438 ); // 25
112
+ d = gg( d, a, b, c, x[i+14], 9, -1019803690 ); // 26
113
+ c = gg( c, d, a, b, x[i+ 3], 14, -187363961 ); // 27
114
+ b = gg( b, c, d, a, x[i+ 8], 20, 1163531501 ); // 28
115
+ a = gg( a, b, c, d, x[i+13], 5, -1444681467 ); // 29
116
+ d = gg( d, a, b, c, x[i+ 2], 9, -51403784 ); // 30
117
+ c = gg( c, d, a, b, x[i+ 7], 14, 1735328473 ); // 31
118
+ b = gg( b, c, d, a, x[i+12], 20, -1926607734 ); // 32
119
+
120
+ // Round 3
121
+ a = hh( a, b, c, d, x[i+ 5], 4, -378558 ); // 33
122
+ d = hh( d, a, b, c, x[i+ 8], 11, -2022574463 ); // 34
123
+ c = hh( c, d, a, b, x[i+11], 16, 1839030562 ); // 35
124
+ b = hh( b, c, d, a, x[i+14], 23, -35309556 ); // 36
125
+ a = hh( a, b, c, d, x[i+ 1], 4, -1530992060 ); // 37
126
+ d = hh( d, a, b, c, x[i+ 4], 11, 1272893353 ); // 38
127
+ c = hh( c, d, a, b, x[i+ 7], 16, -155497632 ); // 39
128
+ b = hh( b, c, d, a, x[i+10], 23, -1094730640 ); // 40
129
+ a = hh( a, b, c, d, x[i+13], 4, 681279174 ); // 41
130
+ d = hh( d, a, b, c, x[i+ 0], 11, -358537222 ); // 42
131
+ c = hh( c, d, a, b, x[i+ 3], 16, -722521979 ); // 43
132
+ b = hh( b, c, d, a, x[i+ 6], 23, 76029189 ); // 44
133
+ a = hh( a, b, c, d, x[i+ 9], 4, -640364487 ); // 45
134
+ d = hh( d, a, b, c, x[i+12], 11, -421815835 ); // 46
135
+ c = hh( c, d, a, b, x[i+15], 16, 530742520 ); // 47
136
+ b = hh( b, c, d, a, x[i+ 2], 23, -995338651 ); // 48
137
+
138
+ // Round 4
139
+ a = ii( a, b, c, d, x[i+ 0], 6, -198630844 ); // 49
140
+ d = ii( d, a, b, c, x[i+ 7], 10, 1126891415 ); // 50
141
+ c = ii( c, d, a, b, x[i+14], 15, -1416354905 ); // 51
142
+ b = ii( b, c, d, a, x[i+ 5], 21, -57434055 ); // 52
143
+ a = ii( a, b, c, d, x[i+12], 6, 1700485571 ); // 53
144
+ d = ii( d, a, b, c, x[i+ 3], 10, -1894986606 ); // 54
145
+ c = ii( c, d, a, b, x[i+10], 15, -1051523 ); // 55
146
+ b = ii( b, c, d, a, x[i+ 1], 21, -2054922799 ); // 56
147
+ a = ii( a, b, c, d, x[i+ 8], 6, 1873313359 ); // 57
148
+ d = ii( d, a, b, c, x[i+15], 10, -30611744 ); // 58
149
+ c = ii( c, d, a, b, x[i+ 6], 15, -1560198380 ); // 59
150
+ b = ii( b, c, d, a, x[i+13], 21, 1309151649 ); // 60
151
+ a = ii( a, b, c, d, x[i+ 4], 6, -145523070 ); // 61
152
+ d = ii( d, a, b, c, x[i+11], 10, -1120210379 ); // 62
153
+ c = ii( c, d, a, b, x[i+ 2], 15, 718787259 ); // 63
154
+ b = ii( b, c, d, a, x[i+ 9], 21, -343485551 ); // 64
155
+
156
+ a += aa;
157
+ b += bb;
158
+ c += cc;
159
+ d += dd;
160
+ }
161
+
162
+ // Finish up by concatening the buffers with their hex output
163
+ return IntUtil.toHex( a ) + IntUtil.toHex( b ) + IntUtil.toHex( c ) + IntUtil.toHex( d );
164
+ }
165
+
166
+ /**
167
+ * Auxiliary function f as defined in RFC
168
+ */
169
+ private static function f( x:int, y:int, z:int ):int {
170
+ return ( x & y ) | ( (~x) & z );
171
+ }
172
+
173
+ /**
174
+ * Auxiliary function g as defined in RFC
175
+ */
176
+ private static function g( x:int, y:int, z:int ):int {
177
+ return ( x & z ) | ( y & (~z) );
178
+ }
179
+
180
+ /**
181
+ * Auxiliary function h as defined in RFC
182
+ */
183
+ private static function h( x:int, y:int, z:int ):int {
184
+ return x ^ y ^ z;
185
+ }
186
+
187
+ /**
188
+ * Auxiliary function i as defined in RFC
189
+ */
190
+ private static function i( x:int, y:int, z:int ):int {
191
+ return y ^ ( x | (~z) );
192
+ }
193
+
194
+ /**
195
+ * A generic transformation function. The logic of ff, gg, hh, and
196
+ * ii are all the same, minus the function used, so pull that logic
197
+ * out and simplify the method bodies for the transoformation functions.
198
+ */
199
+ private static function transform( func:Function, a:int, b:int, c:int, d:int, x:int, s:int, t:int):int {
200
+ var tmp:int = a + int( func( b, c, d ) ) + x + t;
201
+ return IntUtil.rol( tmp, s ) + b;
202
+ }
203
+
204
+ /**
205
+ * ff transformation function
206
+ */
207
+ private static function ff ( a:int, b:int, c:int, d:int, x:int, s:int, t:int ):int {
208
+ return transform( f, a, b, c, d, x, s, t );
209
+ }
210
+
211
+ /**
212
+ * gg transformation function
213
+ */
214
+ private static function gg ( a:int, b:int, c:int, d:int, x:int, s:int, t:int ):int {
215
+ return transform( g, a, b, c, d, x, s, t );
216
+ }
217
+
218
+ /**
219
+ * hh transformation function
220
+ */
221
+ private static function hh ( a:int, b:int, c:int, d:int, x:int, s:int, t:int ):int {
222
+ return transform( h, a, b, c, d, x, s, t );
223
+ }
224
+
225
+ /**
226
+ * ii transformation function
227
+ */
228
+ private static function ii ( a:int, b:int, c:int, d:int, x:int, s:int, t:int ):int {
229
+ return transform( i, a, b, c, d, x, s, t );
230
+ }
231
+
232
+ /**
233
+ * Converts a string to a sequence of 16-word blocks
234
+ * that we'll do the processing on. Appends padding
235
+ * and length in the process.
236
+ *
237
+ * @param s The string to split into blocks
238
+ * @return An array containing the blocks that s was
239
+ * split into.
240
+ */
241
+ private static function createBlocks( s:String ):Array {
242
+ var blocks:Array = new Array();
243
+ var len:int = s.length * 8;
244
+ var mask:int = 0xFF; // ignore hi byte of characters > 0xFF
245
+ for( var i:int = 0; i < len; i += 8 ) {
246
+ blocks[ i >> 5 ] |= ( s.charCodeAt( i / 8 ) & mask ) << ( i % 32 );
247
+ }
248
+
249
+ // append padding and length
250
+ blocks[ len >> 5 ] |= 0x80 << ( len % 32 );
251
+ blocks[ ( ( ( len + 64 ) >>> 9 ) << 4 ) + 14 ] = len;
252
+ return blocks;
253
+ }
254
+
255
+ }
256
+ }