diff dcrypt/crypto/hashes/MD5.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/MD5.d	Sat May 09 23:29:20 2009 -0400
+++ b/dcrypt/crypto/hashes/MD5.d	Sun May 10 22:38:48 2009 -0400
@@ -19,7 +19,7 @@
  */
 class MD5 : Hash
 {
-	private uint h0, h1, h2, h3;
+    private uint h0, h1, h2, h3;
     
     // Shift amounts
     private enum
@@ -61,7 +61,7 @@
         return 16;
     }
     
-    char[] name()
+    string name()
     {
         return "MD5";
     }
@@ -208,7 +208,7 @@
     
     ubyte[] digest()
     {
-    	padMessage(MODE_MD);
+        padMessage(MODE_MD);
         ubyte[] result = new ubyte[digestSize];
         
         result[0..4] = ByteConverter.LittleEndian.from!(uint)(h0);
@@ -245,7 +245,7 @@
         // Found in Tango <3
         unittest
         {
-            static const char[][] test_inputs = [
+            static string[] test_inputs = [
                 "",
                 "a",
                 "abc",
@@ -255,7 +255,7 @@
                 "12345678901234567890123456789012345678901234567890123456789012345678901234567890"
             ];
             
-            static const char[][] test_results = [
+            static string[] test_results = [
                 "d41d8cd98f00b204e9800998ecf8427e",
                 "0cc175b9c0f1b6a831c399e269772661",
                 "900150983cd24fb0d6963f7d28e17f72",
@@ -266,10 +266,10 @@
             ];
             
             MD5 h = new MD5();
-            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]~")");
             }