예제 #1
0
 /// <summary>
 /// Returns a hash code for this instance.
 /// </summary>
 /// <returns>
 /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
 /// </returns>
 public override int GetHashCode()
 {
     using (var decryptedPassword = new DecryptedSecureString(_securePassword))
     {
         return(new Hasher().HashStructElements(decryptedPassword.GetChars()).GetHashCode());
     }
 }
예제 #2
0
        // public methods
        /// <summary>
        /// Determines whether the specified <see cref="System.Object" /> is equal to this instance.
        /// </summary>
        /// <param name="rhs">The <see cref="System.Object" /> to compare with this instance.</param>
        /// <returns>
        ///   <c>true</c> if the specified <see cref="System.Object" /> is equal to this instance; otherwise, <c>false</c>.
        /// </returns>
        public override bool Equals(object rhs)
        {
            if (object.ReferenceEquals(rhs, null) || GetType() != rhs.GetType())
            {
                return(false);
            }

            using (var lhsDecryptedPassword = new DecryptedSecureString(_securePassword))
                using (var rhsDecryptedPassword = new DecryptedSecureString(((PasswordEvidence)rhs)._securePassword))
                {
                    return(lhsDecryptedPassword.GetChars().SequenceEqual(rhsDecryptedPassword.GetChars()));
                }
        }