diff dcrypt/crypto/hashes/SHA224.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/SHA224.d	Sat May 09 23:29:20 2009 -0400
+++ b/dcrypt/crypto/hashes/SHA224.d	Sun May 10 22:38:48 2009 -0400
@@ -29,14 +29,14 @@
         return 28;
     }
     
-    char[] name()
+    string name()
     {
         return "SHA224";
     }
     
     ubyte[] digest()
     {
-    	padMessage(MODE_SHA);
+        padMessage(MODE_SHA);
 
         ubyte[] result = new ubyte[digestSize];
         
@@ -84,18 +84,18 @@
     {
         unittest
         {
-            static const char[][] test_inputs = [
+            static string[] test_inputs = [
                 "",
                 "abc",
                 "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
                 "a"
             ];
             
-            static const int[] test_repeat = [
+            static int[] test_repeat = [
                 1, 1, 1, 1000000
             ];
             
-            static const char[][] test_results = [
+            static string[] test_results = [
                 "d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f",
                 "23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7",
                 "75388b16512776cc5dba5da1fd890150b0c6455cb4f58b1952522525",
@@ -103,11 +103,11 @@
             ];
             
             SHA224 h = new SHA224();
-            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]~")");
             }