예제 #1
0
        public string calculateBlockHash(string previousBlockHash)
        {
            string blockHeaderHash = BlockNumber + BlockCreationDate.ToString() + previousBlockHash;
            string finalBlockHash  = merkleTreeObj.RootNode + blockHeaderHash;

            return(Convert.ToBase64String(HashData.ComputeHashSha256(Encoding.UTF8.GetBytes(finalBlockHash))));
        }
예제 #2
0
        /*Calculate the hash of block which is combination of song details and block details.*/
        public string calculateBlockHash(string blockHashToCompute)
        {
            string songDetailString = null;
            string blockHashString  = null;

            songDetailString = SongNumber + SongName + AlbumName + ArtistOrBand + PublicationLabel + OwnershipPercentagePerBandMember + BlockCreationDate;
            blockHashString  = BlockNumber + BlockCreationDate.ToString() + blockHashToCompute;

            return(Convert.ToBase64String(HashData.ComputeHashSha256(Encoding.UTF8.GetBytes(songDetailString + blockHashString))));
        }
예제 #3
0
        public string calculateBlockHash(string previousBlockHash)
        {
            string blockHeaderHash   = BlockNumber + BlockCreationDate.ToString() + previousBlockHash;
            string combinedBlockHash = merkleTreeObj.RootNode + blockHeaderHash;

            string completeBlockHash;

            if (KeyStore == null)
            {
                completeBlockHash = Convert.ToBase64String(HashData.ComputeHashSha256(Encoding.UTF8.GetBytes(combinedBlockHash)));
            }
            else
            {
                completeBlockHash = Convert.ToBase64String(Hmac.ComputeHmacsha256(Encoding.UTF8.GetBytes(combinedBlockHash), KeyStore.AuthenticatedHashKey));
            }

            return(completeBlockHash);
        }