Example #1
4
        static void Main(string[] args)
        {
            int[] HashArray = new int[4] { 224, 256, 384, 512 };
            string Data = "This is the SHA-3 Demonstration";

            Console.WriteLine("Demonstration of SHA-3\n");

            for (int Index = 0; Index < HashArray.Length; Index++)
            {
                using (var SHA3Provider = new SHA3.SHA3Managed(HashArray[Index]))
                {
                    Console.WriteLine("Hash Length : {0}", HashArray[Index]);
                    Console.WriteLine("Hash : {0}\n", BitConverter.ToString(SHA3Provider.ComputeHash(Encoding.Default.GetBytes(Data))));
                }
            }

            Console.WriteLine("End");
            Console.ReadLine();
        }
Example #2
0
        public static void Main(string[] args)
        {
            //length must be 224, 256, 384, or 512
            var sha3 = new SHA3Managed(512);
            var hash = sha3.ComputeHash(Encoding.UTF8.GetBytes("Hello from Steve"));

            Console.WriteLine(Convert.ToBase64String(hash));
        }
        private static void MassTest(string password)
        {
            int costfactor = 0;
            int iterations = 1250;
            Console.Clear();
            Console.WriteLine("Password:{0}", password);

            Console.WriteLine("============================");
            Console.WriteLine("==        MASS TEST       ==");
            Console.WriteLine("============================");

            Console.Write("Enter cost factor for bcrypt (between 4-31; default is 6): ");
            if (!int.TryParse(Console.ReadLine(), out costfactor))
            {
                costfactor = 6;
            }

            if (costfactor < 4)
                costfactor = 4;
            else if (costfactor > 31)
                costfactor = 31;

            Console.Write("Crypting the password {0} times with a cost factor of {1}...\n\r", iterations, costfactor);
            var startStime = DateTime.Now;
            for(var i = 1; i <= iterations; i++)
            {
                var b1 = BlowfishCrypter.Blowfish.Crypt(string.Concat("{0}{1}", password, i), BlowfishCrypter.Blowfish.GenerateSalt(costfactor));
                if(i%50 == 0)
                    Console.Write("{0} ", i);
            }
            var endTime = DateTime.Now.Subtract(startStime);

            Console.WriteLine("done");
            Console.WriteLine("Operation took {0} to complete.", endTime.ToString("c"));
            Console.WriteLine("");

            Console.Write("Crypting the password {0} times using SHA-3 with 512Bit length...\n\r", iterations);
            startStime = DateTime.Now;
            for (var i = 1; i <= iterations; i++)
            {
                var bytes = new ASCIIEncoding().GetBytes(string.Concat("{0}{1}", password, i));
                var sha3 = new SHA3.SHA3Managed(512);
                sha3.ComputeHash(bytes);
                if (i % 50 == 0)
                    Console.Write("{0} ", i);
            }
            endTime = DateTime.Now.Subtract(startStime);

            Console.WriteLine("done");
            Console.WriteLine("Operation took {0} to complete.\n\r", endTime.ToString("c"));
            Console.WriteLine("Press any key to return to menu");
            Console.ReadKey();
        }