예제 #1
0
        public string Encrypt(string message)
        {
            byte[]        result = null;
            StringBuilder hash   = new StringBuilder();

            switch (HashSize)
            {
            case HashFunctionSize.Bits224:
                result = Sha3.Sha3224().ComputeHash(Encoding.UTF8.GetBytes(message));
                break;

            case HashFunctionSize.Bits256:
                result = Sha3.Sha3256().ComputeHash(Encoding.UTF8.GetBytes(message));
                break;

            case HashFunctionSize.Bits384:
                result = Sha3.Sha3384().ComputeHash(Encoding.UTF8.GetBytes(message));
                break;

            case HashFunctionSize.Bits512:
                result = Sha3.Sha3512().ComputeHash(Encoding.UTF8.GetBytes(message));
                break;
            }

            for (int i = 0; i < result.Length; i++)
            {
                hash.Append(result[i].ToString("x2"));
            }

            return(hash.ToString());
        }
예제 #2
0
        public void Sha3384ComputeHash_WithControlledInput_ResultMatchesExpected(string input, string expected)
        {
            var hash = Sha3.Sha3384().ComputeHash(Encoding.UTF8.GetBytes(input));

            hash.ToHexString().Should().Be(expected);
        }