diff dcrypt/crypto/hashes/MD4.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/MD4.d	Sat May 09 23:29:20 2009 -0400
+++ b/dcrypt/crypto/hashes/MD4.d	Sun May 10 22:38:48 2009 -0400
@@ -19,7 +19,7 @@
  */
 class MD4 : Hash
 {
-	private uint h0, h1, h2, h3;
+    private uint h0, h1, h2, h3;
     
     // Shift amounts
     private enum
@@ -56,7 +56,7 @@
         return 16;
     }
     
-    char[] name()
+    string name()
     {
         return "MD4";
     }
@@ -168,7 +168,7 @@
 
     ubyte[] digest()
     {
-    	padMessage(MODE_MD);
+        padMessage(MODE_MD);
         ubyte[] result = new ubyte[digestSize];
         
         result[0..4] = ByteConverter.LittleEndian.from!(uint)(h0);
@@ -202,10 +202,9 @@
     
     debug (UnitTest)
     {
-        // Found in Tango <3
         unittest
         {
-            static const char[][] test_inputs = [
+            static string[] test_inputs = [
                 "",
                 "a",
                 "abc",
@@ -215,7 +214,7 @@
                 "12345678901234567890123456789012345678901234567890123456789012345678901234567890"
             ];
             
-            static const char[][] test_results = [
+            static string[] test_results = [
                 "31d6cfe0d16ae931b73c59d7e0c089c0",
                 "bde52cb31de33e46245e05fbdbd6fb24",
                 "a448017aaf21d8525fc10ae87aa6729d",
@@ -226,10 +225,10 @@
             ];
             
             MD4 h = new MD4();
-            foreach (uint i, char[] input; test_inputs)
+            foreach (uint i, string input; test_inputs)
             {
                 h.update(input);
-                char[] digest = h.hexDigest();
+                string digest = h.hexDigest();
                 assert(digest == test_results[i], 
                         h.name~": ("~digest~") != ("~test_results[i]~")");
             }