Пример #1
0
        static void TestNHashCash()
        {
            for (int i = 0; i < iterations; i++)
            {
                Minter minter = new Minter();
                string header = minter.Mint("*****@*****.**", Minter.StampFormat.Version1);
                bool   ret    = HashCash.Verify(header);

                Console.WriteLine((ret ? "Passed" : "Failed") + "   " + header);
            }
        }
Пример #2
0
        static void TestHashCash()
        {
            var check = HashCash.Verify("1:20:1303030600:[email protected]::McMybZIhxKXu57jd:ckvi");

            Console.WriteLine(check ? "Passed Verification" : "Failed Verification");

            int totalTime = 0;

            for (int i = 0; i < iterations; i++)
            {
                try
                {
                    HashCash hc     = new HashCash("*****@*****.**");
                    DateTime start  = DateTime.Now;
                    string   header = hc.Compute();
                    DateTime stop   = DateTime.Now;
                    bool     ret    = HashCash.Verify(header);

                    if (!ret)
                    {
                        throw new HashCashException("Verification failed.");
                    }

                    int ms = (int)((stop - start).TotalMilliseconds);
                    Console.WriteLine(i + "-> Time: " + ms + "ms   Iterations = " + hc.Iterations);
                    totalTime += ms;
                }
                catch (HashCashException ex)
                {
                    Console.WriteLine(ex.Message);
                    break;
                }
            }

            Console.WriteLine("Average time: " + (int)(totalTime / iterations) + "ms");
        }