Esempio n. 1
0
        /// <summary>
        /// Checks if the Hash of the plaintext equals the Hash
        /// </summary>
        /// <param name="plaintext">String to compare</param>
        /// <returns>True, if the Hash are equal</returns>
        /// <exception cref="ArgumentNullException"></exception>
        public virtual bool Verify(string plaintext)
        {
            if (string.IsNullOrEmpty(plaintext))
            {
                throw new ArgumentNullException(nameof(plaintext));
            }

            var hash = new HashBox().Compute(plaintext);

            return(Verify(hash));
        }
Esempio n. 2
0
        /// <summary>
        /// Checks if the Hash of the data equals the Hash
        /// </summary>
        /// <param name="plaindata">Bytes to compare</param>
        /// <returns>True, if the Hash are equal</returns>
        /// <exception cref="ArgumentNullException"></exception>
        public virtual bool Verify(byte[] plaindata)
        {
            if (plaindata == null)
            {
                throw new ArgumentNullException(nameof(plaindata));
            }
            else if (plaindata.Length == 0)
            {
                throw new ArgumentException($"{nameof(plaindata)} can't be empty");
            }

            var hash = new HashBox().Compute(plaindata);

            return(Verify(hash));
        }
Esempio n. 3
0
        /// <summary>
        /// Checks if the Keyed Hash of the data equals the Hash
        /// </summary>
        /// <param name="plaindata">Bytes to compare</param>
        /// <param name="key">Key used for hashing</param>
        /// <returns>True, if the Hash are equal</returns>
        /// <exception cref="ArgumentNullException"></exception>
        public virtual bool Verify(byte[] plaindata, IKey key)
        {
            var hash = new HashBox(key).Compute(plaindata);

            return(Verify(hash));
        }
Esempio n. 4
0
        /// <summary>
        /// Checks if the Keyed Hash of the plaintext equals the hash
        /// </summary>
        /// <param name="plaintext">string to compare</param>
        /// <param name="key">Key used for hashing</param>
        /// <returns>true, is the hashed string matches the hash</returns>
        /// <exception cref="ArgumentNullException"></exception>
        public virtual bool Verify(string plaintext, IKey key)
        {
            var hash = new HashBox(key).Compute(plaintext);

            return(Verify(hash));
        }