Mercurial > projects > dcrypt
diff dcrypt/crypto/hashes/SHA1.d @ 28:ad687db713a4
Further reworked the code for hash padding. Replaced all instances of 'char[]' with 'string' and removed a few 'const' modifiers as per Glenn Haecker's patch for D2 compatibility. Updated CONTRIBUTORS file.
author | Thomas Dixon <reikon@reikon.us> |
---|---|
date | Sun, 10 May 2009 22:38:48 -0400 |
parents | 8b5eaf3c2979 |
children |
line wrap: on
line diff
--- a/dcrypt/crypto/hashes/SHA1.d Sat May 09 23:29:20 2009 -0400 +++ b/dcrypt/crypto/hashes/SHA1.d Sun May 10 22:38:48 2009 -0400 @@ -19,7 +19,7 @@ */ class SHA1 : Hash { - protected uint h0, h1, h2, h3, h4; + protected uint h0, h1, h2, h3, h4; this (void[] input_=null) { @@ -37,7 +37,7 @@ return 20; } - char[] name() + string name() { return "SHA1"; } @@ -160,7 +160,7 @@ ubyte[] digest() { - padMessage(MODE_SHA); + padMessage(MODE_SHA); ubyte[] result = new ubyte[digestSize]; result[0..4] = ByteConverter.BigEndian.from!(uint)(h0); @@ -199,7 +199,7 @@ { unittest { - static const char[][] test_inputs = [ + static string[] test_inputs = [ "", "abc", "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", @@ -207,11 +207,11 @@ "0123456701234567012345670123456701234567012345670123456701234567" ]; - static const int[] test_repeat = [ + static int[] test_repeat = [ 1, 1, 1, 1000000, 10 ]; - static const char[][] test_results = [ + static string[] test_results = [ "da39a3ee5e6b4b0d3255bfef95601890afd80709", "a9993e364706816aba3e25717850c26c9cd0d89d", "84983e441c3bd26ebaae4aa1f95129e5e54670f1", @@ -220,11 +220,11 @@ ]; SHA1 h = new SHA1(); - foreach (uint i, char[] input; test_inputs) + foreach (uint i, string input; test_inputs) { for (int j = 0; j < test_repeat[i]; j++) h.update(input); - char[] digest = h.hexDigest(); + string digest = h.hexDigest(); assert(digest == test_results[i], h.name~": ("~digest~") != ("~test_results[i]~")"); }