public static string NextBlockHash(VoteBlock block) { var hasher = SHA384.Create(); var bytes = Encoding.UTF8.GetBytes(block.data + block.timeStamp.ToString()); return(Convert.ToBase64String(hasher.ComputeHash(bytes))); }
public VoteBlock AddNewBlock(string data) { var newBlock = new VoteBlock() { data = data, index = _chain.Count + 1, timeStamp = DateTime.Now, previousHash = VoteHelpers.NextBlockHash(_chain[_chain.Count - 1]) }; _chain.Add(newBlock); return(newBlock); }