Example #1
0
        private void StoringPasswordsUsingSaltedHashes()
        {
            // using salted hashes

            Console.WriteLine("Encrypting Passwords started");

            Console.WriteLine(string.Empty);

            User U = new User();

            Console.WriteLine("please enter the user name");
            U.UserName = Console.ReadLine().Trim();

            //Console.WriteLine("please enter the password");
            //U.Password = Console.ReadLine().Trim();

            byte[] salt       = CryptographyExample.GenerateSalt();
            byte[] saltedHash = CryptographyExample.HashPasswordWithSalt(Encoding.UTF8.GetBytes(_tempPassword), salt);
            U.Password = Convert.ToBase64String(saltedHash);

            JSONDataBase JsonDB = new JSONDataBase();

            JsonDB.AddUser(U);


            Console.WriteLine("Encrypting Passwords ended");
            Console.WriteLine(string.Empty);
        }