Mercurial > projects > dcrypt
comparison dcrypt/crypto/hashes/MD5.d @ 2:71aae178f89a
Added copy() to hash functions. Modified some code style.
author | Thomas Dixon <reikon@reikon.us> |
---|---|
date | Wed, 13 Aug 2008 22:01:19 -0400 |
parents | 0e08791a1418 |
children | a5789a7b3b3b |
comparison
equal
deleted
inserted
replaced
1:483e4467b5f6 | 2:71aae178f89a |
---|---|
206 super.reset(); | 206 super.reset(); |
207 h0 = 0x67452301u, | 207 h0 = 0x67452301u, |
208 h1 = 0xefcdab89u, | 208 h1 = 0xefcdab89u, |
209 h2 = 0x98badcfeu, | 209 h2 = 0x98badcfeu, |
210 h3 = 0x10325476u; | 210 h3 = 0x10325476u; |
211 } | |
212 | |
213 MD5 copy() { | |
214 MD5 h = new MD5(buffer[0..index]); | |
215 h.h0 = h0; | |
216 h.h1 = h1; | |
217 h.h2 = h2; | |
218 h.h3 = h3; | |
219 return h; | |
211 } | 220 } |
212 | 221 |
213 version (UnitTest) { | 222 version (UnitTest) { |
214 // Found in Tango <3 | 223 // Found in Tango <3 |
215 unittest { | 224 unittest { |
236 MD5 h = new MD5(); | 245 MD5 h = new MD5(); |
237 foreach (uint i, char[] input; test_inputs) { | 246 foreach (uint i, char[] input; test_inputs) { |
238 h.update(input); | 247 h.update(input); |
239 char[] digest = h.hexDigest(); | 248 char[] digest = h.hexDigest(); |
240 assert(digest == test_results[i], | 249 assert(digest == test_results[i], |
241 h.name()~": ("~digest~") != ("~test_results[i]~")"); | 250 h.name~": ("~digest~") != ("~test_results[i]~")"); |
242 } | 251 } |
243 } | 252 } |
244 } | 253 } |
245 } | 254 } |