Copy constructors for block, block header and hash classes
[NovacoinLibrary.git] / Novacoin / Hash256.cs
1 \feffusing System;
2 using System.Text;
3 using System.Linq;
4 using System.Collections.Generic;
5
6 using System.Security.Cryptography;
7
8
9
10 namespace Novacoin
11 {
12         /// <summary>
13         /// Representation of SHA-256 hash
14         /// </summary>
15     public class Hash256 : Hash
16     {
17         // 32 bytes
18         public override int hashSize
19         {
20             get { return 32; }
21         }
22
23         public Hash256() : base() { }
24         public Hash256(byte[] bytes) : base(bytes) { }
25         public Hash256(IEnumerable<byte> bytes) : base(bytes) { }
26         public Hash256(Hash256 h) : base(h) { }
27
28
29         public static Hash256 Compute256(IEnumerable<byte> inputBytes)
30         {
31             byte[] dataBytes = inputBytes.ToArray();
32             byte[] digest1 = _hasher256.ComputeHash(dataBytes, 0, dataBytes.Length);
33             byte[] digest2 = _hasher256.ComputeHash(digest1, 0, digest1.Length);
34
35             return new Hash256(digest2);
36         }
37     }
38 }
39