public Block CreateNewBlock(Block latestBlock)
        {
            Block newBlock = new Block();

            newBlock.TimeStamp             = DateTimeOffset.UtcNow;
            newBlock.ProofOfWork           = CustomHash.ComputeHash(string.Concat(transaction.Amount.ToString(), latestBlock.ProofOfWork), "SHA256", null);
            newBlock.PreviousBlockHash     = latestBlock.ProofOfWork;
            newBlock.EncryptedTransactions = new List <Transaction>();
            newBlock.EncryptedTransactions.Add(transaction);
            newBlock.Threshhold = 1000;

            return(newBlock);
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            string password      = "******"; // original password
            string wrongPassword = "******";   // wrong password

            string passwordHashSha256 =
                CustomHash.ComputeHash(password, "SHA256", null);

            Console.WriteLine("COMPUTING HASH VALUES\r\n");
            Console.WriteLine("SHA256: {0}", passwordHashSha256);
            Console.WriteLine("");

            Console.WriteLine("COMPARING PASSWORD HASHES\r\n");
            Console.WriteLine("SHA256 (good): {0}",
                              CustomHash.VerifyHash(
                                  password, "SHA256",
                                  passwordHashSha256).ToString());
            Console.WriteLine("SHA256 (bad) : {0}",
                              CustomHash.VerifyHash(
                                  wrongPassword, "SHA256",
                                  passwordHashSha256).ToString());
        }