EvaluateScript and IsCanonicalPubKey implementation, IsCanonicalSignature/CheckSig...
[NovacoinLibrary.git] / Novacoin / RIPEMD160.cs
1 \feffusing System;
2 using System.Security.Cryptography;
3 using System.Collections.Generic;
4 using System.Text;
5 using System.Linq;
6
7 namespace Novacoin
8 {
9     /// <summary>
10     /// Representation of RIPEMD-160 hash.
11     /// </summary>
12     public class RIPEMD160 : Hash
13     {
14         /// <summary>
15         /// Computes RIPEMD160 hash using managed library
16         /// </summary>
17         private static readonly RIPEMD160Managed _hasher160 = new RIPEMD160Managed();
18
19         // 20 bytes
20         public override int hashSize
21         {
22             get { return 20; }
23         }
24
25         public RIPEMD160() : base() { }
26         public RIPEMD160(byte[] bytes, int offset = 0) : base(bytes, offset) { }
27         public RIPEMD160(IEnumerable<byte> bytes, int skip = 0) : base(bytes, skip) { }
28         public RIPEMD160(RIPEMD160 h) : base(h) { }
29
30         public static RIPEMD160 Compute160(IEnumerable<byte> inputBytes)
31         {
32             byte[] dataBytes = inputBytes.ToArray();
33             byte[] digest1 = _hasher160.ComputeHash(dataBytes, 0, dataBytes.Length);
34
35             return new RIPEMD160(digest1);
36         }
37     }
38 }
39