119 self new test01_crc32 |
119 self new test01_crc32 |
120 " |
120 " |
121 ! |
121 ! |
122 |
122 |
123 test02_md5 |
123 test02_md5 |
124 |h| |
124 |h s| |
125 |
125 |
126 h := MD5Stream hashValueOf:''. |
126 h := MD5Stream hashValueOf:''. |
127 self assert:(h = (ByteArray fromHexString:'d41d8cd98f00b204e9800998ecf8427e')). |
127 self assert:(h = (ByteArray fromHexString:'d41d8cd98f00b204e9800998ecf8427e')). |
128 |
128 |
129 h := MD5Stream hashValueOf:'The quick brown fox jumps over the lazy dog'. |
129 h := MD5Stream hashValueOf:'The quick brown fox jumps over the lazy dog'. |
130 self assert:(h = (ByteArray fromHexString:'9e107d9d372bb6826bd81d3542a419d6')). |
130 self assert:(h = (ByteArray fromHexString:'9e107d9d372bb6826bd81d3542a419d6')). |
131 |
131 |
132 h := MD5Stream hashValueOf:'abc'. |
132 h := MD5Stream hashValueOf:'abc'. |
133 self assert:(h = #[16r90 16r01 16r50 16r98 16r3C 16rD2 16r4F 16rB0 |
133 self assert:(h = #[16r90 16r01 16r50 16r98 16r3C 16rD2 16r4F 16rB0 |
134 16rD6 16r96 16r3F 16r7D 16r28 16rE1 16r7F 16r72]). |
134 16rD6 16r96 16r3F 16r7D 16r28 16rE1 16r7F 16r72]). |
|
135 |
|
136 s := MD5Stream new. |
|
137 s nextPutByte:$a codePoint. |
|
138 s nextPutByte:$b codePoint. |
|
139 s nextPutByte:$c codePoint. |
|
140 self assert:(s hashValue = #[16r90 16r01 16r50 16r98 16r3C 16rD2 16r4F 16rB0 |
|
141 16rD6 16r96 16r3F 16r7D 16r28 16rE1 16r7F 16r72]). |
|
142 |
|
143 s := MD5Stream new. |
|
144 s nextPut:$a. |
|
145 s nextPut:$b. |
|
146 s nextPut:$c. |
|
147 self assert:(s hashValue = #[16r90 16r01 16r50 16r98 16r3C 16rD2 16r4F 16rB0 |
|
148 16rD6 16r96 16r3F 16r7D 16r28 16rE1 16r7F 16r72]). |
|
149 |
|
150 s := MD5Stream new. |
|
151 s nextPutAll:'abc'. |
|
152 self assert:(s hashValue = #[16r90 16r01 16r50 16r98 16r3C 16rD2 16r4F 16rB0 |
|
153 16rD6 16r96 16r3F 16r7D 16r28 16rE1 16r7F 16r72]). |
|
154 |
|
155 s := MD5Stream new. |
|
156 s nextPutAll:'abc' asByteArray. |
|
157 self assert:(s hashValue = #[16r90 16r01 16r50 16r98 16r3C 16rD2 16r4F 16rB0 |
|
158 16rD6 16r96 16r3F 16r7D 16r28 16rE1 16r7F 16r72]). |
135 |
159 |
136 h := MD5Stream hashValueOf:'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq'. |
160 h := MD5Stream hashValueOf:'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq'. |
137 self assert:(h = #[16r82 16r15 16rEF 16r07 16r96 16rA2 16r0B 16rCA |
161 self assert:(h = #[16r82 16r15 16rEF 16r07 16r96 16rA2 16r0B 16rCA |
138 16rAA 16rE1 16r16 16rD3 16r87 16r6C 16r66 16r4A]). |
162 16rAA 16rE1 16r16 16rD3 16r87 16r6C 16r66 16r4A]). |
139 |
163 |
140 h := (MD5Stream new |
164 h := (MD5Stream new |
141 next:1000000 put:$a; |
165 next:1000000 put:$a; |
142 hashValue). |
166 hashValue). |
143 self assert:(h = #[16r77 16r07 16rD6 16rAE 16r4E 16r02 16r7C 16r70 |
167 self assert:(h = #[16r77 16r07 16rD6 16rAE 16r4E 16r02 16r7C 16r70 |
144 16rEE 16rA2 16rA9 16r35 16rC2 16r29 16r6F 16r21]). |
168 16rEE 16rA2 16rA9 16r35 16rC2 16r29 16r6F 16r21]). |
145 |
169 |
146 " |
170 " |
147 self run:#test02_md5 |
171 self run:#test02_md5 |
148 self new test02_md5 |
172 self new test02_md5 |
149 " |
173 " |
|
174 |
|
175 "Modified: / 23-03-2019 / 15:23:42 / Claus Gittinger" |
150 ! |
176 ! |
151 |
177 |
152 test03_sha1 |
178 test03_sha1 |
153 |h| |
179 |h s| |
154 |
180 |
155 "/ test vectors from https://www.di-mgt.com.au/sha_testvectors.html |
181 "/ test vectors from https://www.di-mgt.com.au/sha_testvectors.html |
156 "/ and others |
182 "/ and others |
157 |
183 |
158 h := SHA1Stream hashValueOf:''. |
184 h := SHA1Stream hashValueOf:''. |
159 self assert:(h = (ByteArray fromHexString:'da39a3ee5e6b4b0d3255bfef95601890afd80709')). |
185 self assert:(h = (ByteArray fromHexString:'da39a3ee5e6b4b0d3255bfef95601890afd80709')). |
160 |
186 |
161 h := SHA1Stream hashValueOf:'abc'. |
187 h := SHA1Stream hashValueOf:'abc'. |
162 self assert:(h = (ByteArray fromHexStringWithSeparators:'a9993e36 4706816a ba3e2571 7850c26c 9cd0d89d')). |
188 self assert:(h = (ByteArray fromHexStringWithSeparators:'a9993e36 4706816a ba3e2571 7850c26c 9cd0d89d')). |
|
189 |
|
190 s := SHA1Stream new. |
|
191 s nextPutByte:$a codePoint. |
|
192 s nextPutByte:$b codePoint. |
|
193 s nextPutByte:$c codePoint. |
|
194 self assert:(s hashValue = (ByteArray fromHexStringWithSeparators:'a9993e36 4706816a ba3e2571 7850c26c 9cd0d89d')). |
|
195 |
|
196 s := SHA1Stream new. |
|
197 s nextPut:$a. |
|
198 s nextPut:$b. |
|
199 s nextPut:$c. |
|
200 self assert:(s hashValue = (ByteArray fromHexStringWithSeparators:'a9993e36 4706816a ba3e2571 7850c26c 9cd0d89d')). |
|
201 |
|
202 s := SHA1Stream new. |
|
203 s nextPutAll:'abc'. |
|
204 self assert:(s hashValue = (ByteArray fromHexStringWithSeparators:'a9993e36 4706816a ba3e2571 7850c26c 9cd0d89d')). |
|
205 |
|
206 s := SHA1Stream new. |
|
207 s nextPutAll:'abc' asByteArray. |
|
208 self assert:(s hashValue = (ByteArray fromHexStringWithSeparators:'a9993e36 4706816a ba3e2571 7850c26c 9cd0d89d')). |
163 |
209 |
164 h := SHA1Stream hashValueOf:'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq'. |
210 h := SHA1Stream hashValueOf:'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq'. |
165 self assert:(h = (ByteArray fromHexStringWithSeparators:'84983e44 1c3bd26e baae4aa1 f95129e5 e54670f1')). |
211 self assert:(h = (ByteArray fromHexStringWithSeparators:'84983e44 1c3bd26e baae4aa1 f95129e5 e54670f1')). |
166 |
212 |
167 h := SHA1Stream hashValueOf:'abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu'. |
213 h := SHA1Stream hashValueOf:'abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu'. |
175 self assert:(h = #[146 31 26 53 78 167 121 73 144 117 145 88 50 42 25 52 53 37 177 73]). |
221 self assert:(h = #[146 31 26 53 78 167 121 73 144 117 145 88 50 42 25 52 53 37 177 73]). |
176 |
222 |
177 h := SHA1Stream hashValueOf:(String new:1000000 withAll:$a). |
223 h := SHA1Stream hashValueOf:(String new:1000000 withAll:$a). |
178 self assert:(h = (ByteArray fromHexStringWithSeparators:'34aa973c d4c4daa4 f61eeb2b dbad2731 6534016f')). |
224 self assert:(h = (ByteArray fromHexStringWithSeparators:'34aa973c d4c4daa4 f61eeb2b dbad2731 6534016f')). |
179 |
225 |
|
226 h := SHA1Stream hashValueOf:#[48 130 2 149 160 3 2 1 2 2 1 6 48 13 6 9 42 134 72 134 247 13 1 1 5 5 0 48 111 49 25 48 23 6 3 85 4 3 19 16 69 120 101 112 116 32 76 101 118 101 108 32 50 32 67 65 49 11 48 9 6 3 85 4 6 19 2 68 69 49 26 48 24 6 3 85 4 10 19 17 69 120 101 112 116 32 83 111 102 116 119 97 114 101 32 65 71 49 11 48 9 6 3 85 4 11 19 2 67 65 49 28 48 26 6 9 42 134 72 134 247 13 1 9 1 22 13 99 101 114 116 64 101 120 101 112 116 46 100 101 48 30 23 13 48 56 48 52 50 50 50 48 48 48 48 48 90 23 13 49 54 48 54 48 49 49 57 53 57 53 57 90 48 72 49 11 48 9 6 3 85 4 6 19 2 68 69 49 26 48 24 6 3 85 4 10 19 17 69 120 101 112 116 32 83 111 102 116 119 97 114 101 32 65 71 49 29 48 27 6 3 85 4 3 19 20 101 120 112 101 99 99 111 32 99 111 100 101 32 115 105 103 110 105 110 103 48 129 159 48 13 6 9 42 134 72 134 247 13 1 1 1 5 0 3 129 141 0 48 129 137 2 129 129 0 199 150 115 153 147 36 175 136 129 9 92 77 196 254 201 72 55 141 131 27 57 64 226 5 191 35 239 72 236 142 151 98 19 209 37 164 153 24 185 170 82 62 223 250 229 224 59 238 40 73 29 84 83 109 2 188 117 254 37 86 32 136 145 32 255 118 90 26 62 76 137 45 196 88 220 234 231 81 63 165 29 158 212 132 117 227 250 68 249 54 42 54 69 145 185 217 234 66 192 205 240 247 173 215 243 64 30 52 116 19 113 47 189 90 216 64 241 30 193 187 185 219 5 35 231 222 30 183 2 3 1 0 1 163 129 254 48 129 251 48 9 6 3 85 29 19 4 2 48 0 48 29 6 3 85 29 14 4 22 4 20 142 53 132 147 2 27 121 108 9 10 151 194 20 232 134 227 84 160 251 55 48 129 153 6 3 85 29 35 4 129 145 48 129 142 128 20 36 157 29 207 97 136 114 233 22 165 218 37 28 117 161 157 224 230 74 178 161 115 164 113 48 111 49 25 48 23 6 3 85 4 3 19 16 69 120 101 112 116 32 76 101 118 101 108 32 49 32 67 65 49 11 48 9 6 3 85 4 6 19 2 68 69 49 26 48 24 6 3 85 4 10 19 17 69 120 101 112 116 32 83 111 102 116 119 97 114 101 32 65 71 49 11 48 9 6 3 85 4 11 19 2 67 65 49 28 48 26 6 9 42 134 72 134 247 13 1 9 1 22 13 99 101 114 116 64 101 120 101 112 116 46 100 101 130 1 2 48 11 6 3 85 29 15 4 4 3 2 7 128 48 19 6 3 85 29 37 4 12 48 10 6 8 43 6 1 5 5 7 3 3 48 17 6 9 96 134 72 1 134 248 66 1 1 4 4 3 2 4 16]. |
|
227 self assert:(h = #[152 185 22 239 129 56 192 23 215 67 254 147 139 91 251 28 96 142 185 186]). |
|
228 |
180 " |
229 " |
181 self run:#test03_sha1 |
230 self run:#test03_sha1 |
182 self new test03_sha1 |
231 self new test03_sha1 |
183 " |
232 " |
184 |
233 |
185 "Modified: / 25-11-2013 / 11:42:46 / cg" |
234 "Modified: / 25-11-2013 / 11:42:46 / cg" |
186 "Modified: / 22-03-2019 / 12:29:01 / Claus Gittinger" |
235 "Modified: / 23-03-2019 / 15:22:29 / Claus Gittinger" |
187 ! |
|
188 |
|
189 test03b_sha1 |
|
190 |h| |
|
191 |
|
192 h := SHA1Stream hashValueOf:#[48 130 2 149 160 3 2 1 2 2 1 6 48 13 6 9 42 134 72 134 247 13 1 1 5 5 0 48 111 49 25 48 23 6 3 85 4 3 19 16 69 120 101 112 116 32 76 101 118 101 108 32 50 32 67 65 49 11 48 9 6 3 85 4 6 19 2 68 69 49 26 48 24 6 3 85 4 10 19 17 69 120 101 112 116 32 83 111 102 116 119 97 114 101 32 65 71 49 11 48 9 6 3 85 4 11 19 2 67 65 49 28 48 26 6 9 42 134 72 134 247 13 1 9 1 22 13 99 101 114 116 64 101 120 101 112 116 46 100 101 48 30 23 13 48 56 48 52 50 50 50 48 48 48 48 48 90 23 13 49 54 48 54 48 49 49 57 53 57 53 57 90 48 72 49 11 48 9 6 3 85 4 6 19 2 68 69 49 26 48 24 6 3 85 4 10 19 17 69 120 101 112 116 32 83 111 102 116 119 97 114 101 32 65 71 49 29 48 27 6 3 85 4 3 19 20 101 120 112 101 99 99 111 32 99 111 100 101 32 115 105 103 110 105 110 103 48 129 159 48 13 6 9 42 134 72 134 247 13 1 1 1 5 0 3 129 141 0 48 129 137 2 129 129 0 199 150 115 153 147 36 175 136 129 9 92 77 196 254 201 72 55 141 131 27 57 64 226 5 191 35 239 72 236 142 151 98 19 209 37 164 153 24 185 170 82 62 223 250 229 224 59 238 40 73 29 84 83 109 2 188 117 254 37 86 32 136 145 32 255 118 90 26 62 76 137 45 196 88 220 234 231 81 63 165 29 158 212 132 117 227 250 68 249 54 42 54 69 145 185 217 234 66 192 205 240 247 173 215 243 64 30 52 116 19 113 47 189 90 216 64 241 30 193 187 185 219 5 35 231 222 30 183 2 3 1 0 1 163 129 254 48 129 251 48 9 6 3 85 29 19 4 2 48 0 48 29 6 3 85 29 14 4 22 4 20 142 53 132 147 2 27 121 108 9 10 151 194 20 232 134 227 84 160 251 55 48 129 153 6 3 85 29 35 4 129 145 48 129 142 128 20 36 157 29 207 97 136 114 233 22 165 218 37 28 117 161 157 224 230 74 178 161 115 164 113 48 111 49 25 48 23 6 3 85 4 3 19 16 69 120 101 112 116 32 76 101 118 101 108 32 49 32 67 65 49 11 48 9 6 3 85 4 6 19 2 68 69 49 26 48 24 6 3 85 4 10 19 17 69 120 101 112 116 32 83 111 102 116 119 97 114 101 32 65 71 49 11 48 9 6 3 85 4 11 19 2 67 65 49 28 48 26 6 9 42 134 72 134 247 13 1 9 1 22 13 99 101 114 116 64 101 120 101 112 116 46 100 101 130 1 2 48 11 6 3 85 29 15 4 4 3 2 7 128 48 19 6 3 85 29 37 4 12 48 10 6 8 43 6 1 5 5 7 3 3 48 17 6 9 96 134 72 1 134 248 66 1 1 4 4 3 2 4 16]. |
|
193 self assert:(h = #[152 185 22 239 129 56 192 23 215 67 254 147 139 91 251 28 96 142 185 186]). |
|
194 |
|
195 " |
|
196 self run:#test03b_sha1 |
|
197 self new test03b_sha1 |
|
198 " |
|
199 |
|
200 "Created: / 24-01-2014 / 17:47:22 / cg" |
|
201 ! |
236 ! |
202 |
237 |
203 test04_md2 |
238 test04_md2 |
204 |h| |
239 |h| |
205 |
240 |