Beispiel #1
0
 private ComputedPassword ComputePassword(string plainPassword, byte[] salt)
 {
     using (var hmac = salt != null && salt.Any()
         ? new System.Security.Cryptography.HMACSHA512(salt)
         : new System.Security.Cryptography.HMACSHA512())
     {
         return(ComputedPassword.Create(hmac.ComputeHash(Encoding.UTF8.GetBytes(plainPassword)), hmac.Key));
     }
 }
        protected static bool Equals(ComputedPassword lhs, ComputedPassword rhs)
        {
            if (ReferenceEquals(null, lhs) && ReferenceEquals(null, rhs))
            {
                return(false);
            }
            if (ReferenceEquals(null, lhs))
            {
                return(false);
            }
            if (ReferenceEquals(null, rhs))
            {
                return(false);
            }
            if (ReferenceEquals(rhs, lhs))
            {
                return(true);
            }

            return(!lhs.Hash.Where((t, i) => t != rhs.Hash[i]).Any() && !lhs.Salt.Where((t, i) => t != rhs.Salt[i]).Any());
        }