EvaluateScript and IsCanonicalPubKey implementation, IsCanonicalSignature/CheckSig...
[NovacoinLibrary.git] / Novacoin / SHA1.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 SHA1 : Hash
14     {
15         /// <summary>
16         /// Computes RIPEMD160 hash using managed library
17         /// </summary>
18         private static readonly SHA1Managed _hasher1 = new SHA1Managed();
19
20         // 32 bytes
21         public override int hashSize
22         {
23             get { return 20; }
24         }
25
26         public SHA1() : base() { }
27         public SHA1(byte[] bytes, int offset = 0) : base(bytes, offset) { }
28         public SHA1(IEnumerable<byte> bytes, int skip = 0) : base(bytes, skip) { }
29         public SHA1(SHA1 h) : base(h) { }
30
31
32         public static SHA1 Compute1(IEnumerable<byte> inputBytes)
33         {
34             byte[] dataBytes = inputBytes.ToArray();
35             byte[] digest1 = _hasher1.ComputeHash(dataBytes, 0, dataBytes.Length);
36
37             return new SHA1(digest1);
38         }
39     }
40 }
41