Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static (byte[], string) GenerateSalt()
- {
- // Generate salt
- var salt = RandomNumberGenerator.GetBytes(128 / 8);
- var b64Salt = Convert.ToBase64String(salt);
- return (salt, b64Salt);
- }
- private static string CreateHash(string password, byte[] salt)
- {
- // Create hash from password and salt
- byte[] hash =
- KeyDerivation.Pbkdf2(
- password: password,
- salt: salt,
- prf: KeyDerivationPrf.HMACSHA256,
- iterationCount: 100000,
- numBytesRequested: 256 / 8);
- string b64Hash = Convert.ToBase64String(hash);
- return b64Hash;
- }
- private static string GenerateSecurityToken()
- {
- byte[] securityToken = RandomNumberGenerator.GetBytes(256 / 8);
- string b64SecToken = Convert.ToBase64String(securityToken);
- return b64SecToken;
- }
Add Comment
Please, Sign In to add comment