/specs/hashes/md5.ds
http://github.com/wilkie/djehuty · Unknown · 32 lines · 25 code · 7 blank · 0 comment · 0 complexity · 6edddfe8bac4250c0e4b3925c56c2e0f MD5 · raw file
- module specs.hashes.md5;
- import testing.support;
- import hashes.md5;
- describe MD5() {
- describe hash() {
- it should_hash_as_expected_for_string_literals() {
- string s = HashMD5.hash("Hashing Hashing Hashing").toString();
- should(s == "7ba85cd90a910d790172b15e895f8e56");
- }
- it should_respect_leading_zeroes() {
- // Testing: leading 0s on parts, note that there is a 0 on the 9th value from the left
- string s = HashMD5.hash("d").toString();
- should(s == "8277e0910d750195b448797616e091ad");
- }
- it should_work_on_byte_arrays() {
- // Testing a classic MD5 Collision
- ubyte[] filea = cast(ubyte[])import("testmd5a.bin");
- ubyte[] fileb = cast(ubyte[])import("testmd5b.bin");
- string a = HashMD5.hash(filea).toString();
- string b = HashMD5.hash(fileb).toString();
- should(a == b);
- should(a == "da5c61e1edc0f18337e46418e48c1290");
- }
- }
- }