EvaluateScript and IsCanonicalPubKey implementation, IsCanonicalSignature/CheckSig...
[NovacoinLibrary.git] / Novacoin / SHA256.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 namespace Novacoin
9 {
10     /// <summary>
11     /// Representation of SHA-256 hash
12     /// </summary>
13     public class SHA256 : Hash
14     {
15         // 32 bytes
16         public override int hashSize
17         {
18             get { return 32; }
19         }
20
21         public SHA256() : base() { }
22         public SHA256(byte[] bytes, int offset = 0) : base(bytes, offset) { }
23         public SHA256(IEnumerable<byte> bytes, int skip = 0) : base(bytes, skip) { }
24         public SHA256(SHA256 h) : base(h) { }
25
26
27         public static SHA256 Compute256(IEnumerable<byte> inputBytes)
28         {
29             byte[] dataBytes = inputBytes.ToArray();
30             byte[] digest1 = _hasher256.ComputeHash(dataBytes, 0, dataBytes.Length);
31
32             return new SHA256(digest1);
33         }
34     }
35 }
36