VarInt class, TxIn/TXOut/Tx serializarion, some CKey and CPubKey methods
[NovacoinLibrary.git] / Novacoin / Hash256.cs
index 7461274..c2e4645 100644 (file)
@@ -3,6 +3,9 @@ using System.Text;
 using System.Linq;
 using System.Collections.Generic;
 
+using System.Security.Cryptography;
+
+
 
 namespace Novacoin
 {
@@ -16,6 +19,19 @@ namespace Novacoin
         {
             get { return 32; }
         }
+
+        public Hash256() : base() { }
+        public Hash256(byte[] bytesArray) : base(bytesArray) { }
+        public Hash256(IList<byte> bytesList) : base(bytesList) { }
+
+        public static Hash256 Compute256(IEnumerable<byte> inputBytes)
+        {
+            byte[] dataBytes = inputBytes.ToArray();
+            byte[] digest1 = _hasher256.ComputeHash(dataBytes, 0, dataBytes.Length);
+            byte[] digest2 = _hasher256.ComputeHash(digest1, 0, digest1.Length);
+
+            return new Hash256(digest2);
+        }
     }
 }