Init some fields, add ToString() for Hash160 and Hash256, start implementation of...
[NovacoinLibrary.git] / Novacoin / Hash160.cs
index 8a995d5..993e4c9 100644 (file)
@@ -1,4 +1,6 @@
 \feffusing System;
+using System.Text;
+using System.Linq;
 
 namespace Novacoin
 {
@@ -12,9 +14,25 @@ namespace Novacoin
                /// </summary>
                private byte[] h;
 
+               /// <summary>
+               /// Initializes an empty instance of the Hash160 class.
+               /// </summary>
                public Hash160 ()
                {
+                       // Fill with 20 zero bytes
+                       h = Enumerable.Repeat<byte> (0, 20).ToArray ();
+               }
+
+               public override string ToString()
+               {
+                       StringBuilder sb = new StringBuilder(h.Length * 2);
+                       foreach (byte b in h)
+                       {
+                               sb.AppendFormat ("{0:x2}", b);
+                       }
+                       return sb.ToString();
                }
+
        }
 }