Пример #1
0
        public const int hashByteSize = 128;    // the final hash - change this

        public string CreatePasswordHash_Single(string password)
        {
            BouncyCastleHashing mainHashingLib = new BouncyCastleHashing();

            byte[] saltBytes  = mainHashingLib.CreateSalt(saltByteSize);
            string saltString = Convert.ToBase64String(saltBytes);

            return(mainHashingLib.PBKDF2_SHA256_GetHash(password, saltString, iterations, hashByteSize));
        }
Пример #2
0
        public bool Validate(string password)
        {
            BouncyCastleHashing mainHashingLib = new BouncyCastleHashing();

            byte[] saltBytes  = mainHashingLib.CreateSalt(saltByteSize);
            string saltString = Convert.ToBase64String(saltBytes);

            string pwdHash = mainHashingLib.PBKDF2_SHA256_GetHash(password, saltString, iterations, hashByteSize);

            return(mainHashingLib.ValidatePassword(password, saltBytes, iterations, hashByteSize, Convert.FromBase64String(pwdHash)));
        }