Exemple #1
0
        public string CalculateBlockHash(string previousBlockHash)
        {
            var blockHeader = BlockNumber + CreatedDate.ToString() + previousBlockHash;
            var combined    = merkleTree.RootNode + blockHeader;

            string completeBlockHash;

            if (KeyStore == null)
            {
                completeBlockHash = Convert.ToBase64String(Hashing.ComputeHashSha256(Encoding.UTF8.GetBytes(combined)));
            }
            else
            {
                completeBlockHash = Convert.ToBase64String(HMAC.ComputeHmacSha256(Encoding.UTF8.GetBytes(combined), KeyStore.AuthenticatedHashKey));
            }

            return(completeBlockHash);
        }