public static string GetHash(HashAlgorithm hashAlgorithm, BlockDataModel data) { byte[] byteData = hashAlgorithm.ComputeHash(Encoding.UTF8.GetBytes(data.ToString())); var sBuilder = new StringBuilder(); for (int i = 0; i < byteData.Length; i++) { sBuilder.Append(byteData[i].ToString("x2")); } return(sBuilder.ToString()); }
public static string GetHash(HashAlgorithm hashAlgorithm, int index, DateTime timeStamp, BlockDataModel data, string previousHash, int nonce) { byte[] byteData = hashAlgorithm.ComputeHash(Encoding.UTF8.GetBytes(index.ToString() + previousHash + data.ToString() + timeStamp.ToString() + nonce.ToString())); var sBuilder = new StringBuilder(); for (int i = 0; i < byteData.Length; i++) { sBuilder.Append(byteData[i].ToString("x2")); } return(sBuilder.ToString()); }