コード例 #1
0
        /// <summary>Verifies that a hash generated with ArgonHashString matches the supplied password.</summary>
        /// <param name="hash">The hash.</param>
        /// <param name="password">The password.</param>
        /// <returns><c>true</c> on success; otherwise, <c>false</c>.</returns>
        /// <exception cref="ArgumentNullException"></exception>
        public static bool ArgonHashStringVerify(byte[] hash, byte[] password)
        {
            if (password == null)
            {
                throw new ArgumentNullException("password", "Password cannot be null");
            }
            if (hash == null)
            {
                throw new ArgumentNullException("hash", "Hash cannot be null");
            }

            var ret = SodiumLibrary.crypto_pwhash_str_verify(hash, password, password.Length);

            return(ret == 0);
        }