diff dcrypt/crypto/hashes/SHA512.d @ 2:71aae178f89a

Added copy() to hash functions. Modified some code style.
author Thomas Dixon <reikon@reikon.us>
date Wed, 13 Aug 2008 22:01:19 -0400
parents 0e08791a1418
children a5789a7b3b3b
line wrap: on
line diff
--- a/dcrypt/crypto/hashes/SHA512.d	Tue Aug 12 05:48:06 2008 -0400
+++ b/dcrypt/crypto/hashes/SHA512.d	Wed Aug 13 22:01:19 2008 -0400
@@ -151,6 +151,19 @@
         h7 = 0x5be0cd19137e2179u;
     }
     
+    SHA512 copy() {
+        SHA512 h = new SHA512(buffer[0..index]);
+        h.h0 = h0;
+        h.h1 = h1;
+        h.h2 = h2;
+        h.h3 = h3;
+        h.h4 = h4;
+        h.h5 = h5;
+        h.h6 = h6;
+        h.h7 = h7;
+        return h;
+    }
+    
     version (UnitTest) {
         unittest {
             static const char[][] test_inputs = [
@@ -185,7 +198,7 @@
                     h.update(input);
                 char[] digest = h.hexDigest();
                 assert(digest == test_results[i], 
-                        h.name()~": ("~digest~") != ("~test_results[i]~")");
+                        h.name~": ("~digest~") != ("~test_results[i]~")");
             }
         }
     }