82 " |
82 " |
83 ! |
83 ! |
84 |
84 |
85 examples |
85 examples |
86 " |
86 " |
87 [exBegin] |
87 [exBegin] |
88 Test Vectors (from FIPS PUB 180-1); results are: |
88 Test Vectors (from FIPS PUB 180-1); results are: |
89 |
89 |
90 'abc' |
90 'abc' |
91 -> #[90 1 50 98 3C D2 4F B0 D6 96 3F 7D 28 E1 7F 72] |
91 -> #[90 1 50 98 3C D2 4F B0 D6 96 3F 7D 28 E1 7F 72] |
92 |
92 |
93 'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq' |
93 'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq' |
94 -> #[82 15 EF 7 96 A2 B CA AA E1 16 D3 87 6C 66 4A] |
94 -> #[82 15 EF 7 96 A2 B CA AA E1 16 D3 87 6C 66 4A] |
95 |
95 |
96 A million repetitions of 'a' |
96 A million repetitions of 'a' |
97 -> #[77 7 D6 AE 4E 2 7C 70 EE A2 A9 35 C2 29 6F 21] |
97 -> #[77 7 D6 AE 4E 2 7C 70 EE A2 A9 35 C2 29 6F 21] |
98 [exEnd] |
98 [exEnd] |
99 |
99 |
100 |
100 [exBegin] |
101 [exBegin] |
101 Transcript showCR:(MD5Stream hashValueOf:'abc') hexPrintString |
|
102 [exEnd] |
|
103 |
|
104 [exBegin] |
102 (MD5Stream hashValueOf:'abc') |
105 (MD5Stream hashValueOf:'abc') |
103 printOn:Transcript base:16. |
106 printOn:Transcript base:16. |
104 Transcript cr. |
107 Transcript cr. |
105 [exEnd] |
108 [exEnd] |
106 |
109 |
107 [exBegin] |
110 [exBegin] |
108 (MD5Stream hashValueOfStream:('abc' readStream)) |
111 (MD5Stream hashValueOfStream:('abc' readStream)) |
109 printOn:Transcript base:16. |
112 printOn:Transcript base:16. |
110 Transcript cr. |
113 Transcript cr. |
111 [exEnd] |
114 [exEnd] |
112 |
115 |
113 [exBegin] |
116 [exBegin] |
114 |hashStream| |
117 |hashStream| |
115 |
118 |
116 hashStream := MD5Stream new. |
119 hashStream := MD5Stream new. |
117 hashStream nextPut:'abc'. |
120 hashStream nextPut:'abc'. |
118 hashStream hashValue printOn:Transcript base:16. Transcript cr. |
121 hashStream hashValue printOn:Transcript base:16. Transcript cr. |
119 hashStream nextPut:'dbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq'. |
122 hashStream nextPut:'dbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq'. |
120 hashStream hashValue printOn:Transcript base:16. Transcript cr. |
123 hashStream hashValue printOn:Transcript base:16. Transcript cr. |
121 [exEnd] |
124 [exEnd] |
122 |
125 |
123 [exBegin] |
126 [exBegin] |
124 |hashStream| |
127 |hashStream| |
125 |
128 |
126 hashStream := MD5Stream new. |
129 hashStream := MD5Stream new. |
127 hashStream nextPut:'a' asByteArray. |
130 hashStream nextPut:'a' asByteArray. |
128 hashStream nextPut:'bc' asByteArray. |
131 hashStream nextPut:'bc' asByteArray. |
129 hashStream hashValue printOn:Transcript base:16. Transcript cr. |
132 hashStream hashValue printOn:Transcript base:16. Transcript cr. |
130 hashStream nextPut:'dbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq' asByteArray. |
133 hashStream nextPut:'dbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq' asByteArray. |
131 hashStream hashValue printOn:Transcript base:16. Transcript cr. |
134 hashStream hashValue printOn:Transcript base:16. Transcript cr. |
132 [exEnd] |
135 [exEnd] |
133 |
136 |
134 [exBegin] |
137 [exBegin] |
135 |hashStream| |
138 |hashStream| |
136 |
139 |
137 hashStream := MD5Stream new. |
140 hashStream := MD5Stream new. |
138 1000000 timesRepeat:[ hashStream nextPut:$a ]. |
141 1000000 timesRepeat:[ hashStream nextPut:$a ]. |
139 hashStream hashValue printOn:Transcript base:16. Transcript cr. |
142 hashStream hashValue printOn:Transcript base:16. Transcript cr. |
140 [exEnd] |
143 [exEnd] |
141 |
144 |
142 [exBegin] |
145 [exBegin] |
143 |hashStream| |
146 |hashStream| |
144 |
147 |
145 hashStream := MD5Stream new. |
148 hashStream := MD5Stream new. |
146 hashStream nextPut:'a'. |
149 hashStream nextPut:'a'. |
147 hashStream hashValue printOn:Transcript base:16. Transcript cr. |
150 hashStream hashValue printOn:Transcript base:16. Transcript cr. |
148 [exEnd] |
151 [exEnd] |
149 |
152 |
150 [exBegin] |
153 [exBegin] |
151 |hashStream| |
154 |hashStream| |
152 |
155 |
153 hashStream := MD5Stream new. |
156 hashStream := MD5Stream new. |
154 hashStream nextPut:$a. |
157 hashStream nextPut:$a. |
155 hashStream hashValue printOn:Transcript base:16. Transcript cr. |
158 hashStream hashValue printOn:Transcript base:16. Transcript cr. |
156 [exEnd] |
159 [exEnd] |
157 |
160 |
158 [exBegin] |
161 [exBegin] |
159 |hashStream| |
162 |hashStream| |
160 |
163 |
161 hashStream := MD5Stream new. |
164 hashStream := MD5Stream new. |
162 hashStream nextPut:'abc'. |
165 hashStream nextPut:'abc'. |
163 hashStream hashValue printOn:Transcript base:16. Transcript cr. |
166 hashStream hashValue printOn:Transcript base:16. Transcript cr. |
164 hashStream reset. |
167 hashStream reset. |
165 hashStream nextPut:'abc'. |
168 hashStream nextPut:'abc'. |
166 hashStream hashValue printOn:Transcript base:16. Transcript cr. |
169 hashStream hashValue printOn:Transcript base:16. Transcript cr. |
167 [exEnd] |
170 [exEnd] |
168 |
171 |
169 timing throughput: |
172 timing throughput: |
170 [exBegin] |
173 [exBegin] |
171 |hashStream n t| |
174 |hashStream n t| |
172 |
175 |
173 hashStream := MD5Stream new. |
176 hashStream := MD5Stream new. |
174 n := 1000000. |
177 n := 1000000. |
175 t := Time millisecondsToRun:[ |
178 t := Time millisecondsToRun:[ |
176 n timesRepeat:[ |
179 n timesRepeat:[ |
177 hashStream nextPutAll:'12345678901234567890123456789012345678901234567890'. |
180 hashStream nextPutAll:'12345678901234567890123456789012345678901234567890'. |
178 ]. |
181 ]. |
179 ]. |
182 ]. |
180 t := (t / 1000) asFloat. |
183 t := (t / 1000) asFloat. |
181 Transcript show:t; show:' seconds for '; show:(50*n/1024) asFloat; showCR:' Kb'. |
184 Transcript show:t; show:' seconds for '; show:(50*n/1024) asFloat; showCR:' Kb'. |
182 Transcript show:(n*50/1024 / t); showCR:' Kb/s' |
185 Transcript show:(n*50/1024 / t); showCR:' Kb/s' |
183 [exEnd] |
186 [exEnd] |
184 " |
187 " |
185 ! ! |
188 ! ! |
186 |
189 |
187 !MD5Stream class methodsFor:'initialization'! |
190 !MD5Stream class methodsFor:'initialization'! |
188 |
191 |