コード例 #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
 // internal methods
 /// <summary>
 /// Computes the MONGODB-CR password digest.
 /// </summary>
 /// <param name="username">The username.</param>
 /// <returns></returns>
 internal string ComputeMongoCRPasswordDigest(string username)
 {
     using (var md5 = MD5.Create())
         using (var decryptedPassword = new DecryptedSecureString(_securePassword))
         {
             var encoding    = Utf8Encodings.Strict;
             var prefixBytes = encoding.GetBytes(username + ":mongo:");
             var hash        = ComputeHash(md5, prefixBytes, decryptedPassword.GetUtf8Bytes());
             return(BsonUtils.ToHexString(hash));
         }
 }
コード例 #3
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()));
                }
        }