Esempio n. 1
0
        public string GetHash(string text)
        {
            byte[]        dataToDecrypt = this.AES.GetBytes(text);
            byte[]        data          = SHA_Hasher.ComputeHash(dataToDecrypt);
            StringBuilder builder       = new StringBuilder();

            for (int i = 0; i < data.Length; i++)
            {
                builder.Append(data[i].ToString());
            }
            string hash = builder.ToString();

            return(hash);
        }
Esempio n. 2
0
        public bool VerifyHash(string text, string hash)
        {
            byte[]        dataToHash  = this.AES.GetBytes(EncryptContent(text));
            byte[]        HashOfInput = SHA_Hasher.ComputeHash(dataToHash);
            StringBuilder builder     = new StringBuilder();

            for (int i = 0; i < HashOfInput.Length; i++)
            {
                builder.Append(HashOfInput[i].ToString());
            }
            string         cleanedHash = builder.ToString();
            StringComparer comparer    = StringComparer.OrdinalIgnoreCase;

            if (comparer.Compare(cleanedHash, hash) == 0)
            {
                return(true);
            }
            return(false);
        }