4 using System.Collections.Generic;
10 /// Representation of SHA-256 hash
15 const int hashSize = 32;
18 /// Array of digest bytes.
20 private byte[] hashBytes = new byte[hashSize];
23 /// Initializes an empty instance of the Hash256 class.
27 hashBytes = Enumerable.Repeat<byte>(0, hashSize).ToArray();
31 /// Initializes a new instance of Hash256 class with first 32 bytes from supplied list
33 /// <param name="bytesList">List of bytes</param>
34 public Hash256(List<byte> bytesList)
36 hashBytes = bytesList.Take<byte>(hashSize).ToArray<byte>();
39 public Hash256(byte[] bytesArray)
41 hashBytes = bytesArray;
44 public override string ToString()
46 StringBuilder sb = new StringBuilder(hashSize * 2);
47 foreach (byte b in hashBytes)
49 sb.AppendFormat("{0:x2}", b);