Exemplo n.º 1
0
 public static void GenerateKey(string password, User user)
 {
     using (var derivedBytes = new Rfc2898DeriveBytes(password, SaltSize))
     {
         user.Salt = derivedBytes.Salt;
         user.Key = derivedBytes.GetBytes(KeySize);
     }
 }
Exemplo n.º 2
0
 public static bool CheckPassword(string password, User user)
 {         
     using (var derivedBytes = new Rfc2898DeriveBytes(password, user.Salt))
     {
         byte[] newKey = derivedBytes.GetBytes(KeySize);
         return newKey.SequenceEqual(user.Key);
     }
 }