Exemplo n.º 1
0
 protected override byte[] GetKey(string pwd)
 {
     using (var rng = new RNGCryptoServiceProvider())
     {
         var salt = new byte[SaltSizeBits / 8];
         rng.GetNonZeroBytes(salt);
         var h        = new Argon2Hasher(KeySizeBits / 8);
         var pwdbytes = new UTF8Encoding(false).GetBytes(pwd);
         var key      = h.HashRaw(pwdbytes, salt);
         return(key);
     }
 }
Exemplo n.º 2
0
 protected override byte[] GetKey(string pwd)
 {
     using (var rng = new RNGCryptoServiceProvider())
     {
         var salt = new byte[SaltSizeBits / 8];
         rng.GetNonZeroBytes(salt);
         var h        = new Argon2Hasher(KeySizeBits / 8);
         var pwdbytes = new UTF8Encoding(false).GetBytes(pwd);
         var hmacPwd  = HmacPasswordWithSecretKeyBeforeGivingItToTheUnderlyingHasher(pwdbytes, SecretKey);
         var key      = h.HashRaw(hmacPwd, salt);
         return(key);
     }
 }