Пример #1
0
        public HMACChiko2(byte[] rgbKey)
        {
            HashSizeValue = 512;
            // Create the hash algorithms.
            hash1 = Sha3.Sha3512();
            hash2 = Sha3.Sha3512();
            // Get the key.
            if (rgbKey.Length > 128)
            {
                KeyValue = hash1.ComputeHash(rgbKey);
                // No need to call Initialize; ComputeHash does it automatically.
            }
            else
            {
                KeyValue = (byte[])rgbKey.Clone();
            }
            // Compute rgbInner and rgbOuter.
            int i = 0;

            for (i = 0; i < 128; i++)
            {
                rgbInner[i] = 0x36;
                rgbOuter[i] = 0x5C;
            }
            for (i = 0; i < KeyValue.Length; i++)
            {
                rgbInner[i] ^= KeyValue[i];
                rgbOuter[i] ^= KeyValue[i];
            }
        }
Пример #2
0
        public string CheckDigitalSignature(string hashToCheck, string plainText)
        {
            //string message = ConfigurationManager.AppSettings["Message"];

            Sha3.ComputeHash(plainText);
            //string hashedMessage = GetHash();
            if (Sha3.Hash.Equals(hashToCheck))
            {
                return("Poruka je besprijekorna");
            }
            return("Poruka nema integriteta");
        }
Пример #3
0
        /// <summary>
        /// Encrypting method using SHA-512 algorithm
        /// </summary>
        /// <param name="password">Password to encrypt</param>
        /// <returns>Encrypted password</returns>
        public String EncryptPassword(string password)
        {
            Sha3 sha512 = Sha3.Sha3512();

            byte[] inputBytes = System.Text.Encoding.ASCII.GetBytes(password);
            byte[] hashBytes  = sha512.ComputeHash(inputBytes);

            // Convert the byte array to hexadecimal string
            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < hashBytes.Length; i++)
            {
                sb.Append(hashBytes[i].ToString("X2").ToLower());
            }
            return(sb.ToString());
        }
Пример #4
0
        public static string GetPasswordHash(string password)
        {
            if (password is null)
            {
                return(null);
            }

            using Sha3 sha3 = Sha3.Sha3512();

            var           hash    = sha3.ComputeHash(Encoding.UTF8.GetBytes(password));
            StringBuilder builder = new StringBuilder();

            foreach (var b in hash)
            {
                builder.Append(b.ToString("x2"));
            }

            return(builder.ToString());
        }
Пример #5
0
 /// <summary>
 /// Computes the hash value for the specified string
 /// </summary>
 /// <exception cref="System.ArgumentNullException"></exception>
 /// <exception cref="System.ObjectDisposedException"></exception>
 public static byte[] ComputeHash(this Sha3 hasher, string value)
 {
     return(hasher.ComputeHash(Encoding.UTF8.GetBytes(value)));
 }