Ejemplo n.º 1
0
        public void Sha3_512_Hash_Should_Match()
        {
            var hasher = new Sha3_512();
            var result = hasher.Digest(testValue).ToHexString();

            Assert.Equal("e0883cffc9ff0ecf41fca8ade29dba1fc0df4b15beccc06ca03283805e176e497f0dd33db3bda375b199a4bb5eb1bb3ba884f3cc26f65f7acf08e1307058cc8d", result);
        }
Ejemplo n.º 2
0
        public static void Properties()
        {
            var a = new Sha3_512();

            Assert.Equal(32, a.MinHashSize);
            Assert.Equal(64, a.DefaultHashSize);
            Assert.Equal(64, a.MaxHashSize);
        }
Ejemplo n.º 3
0
        public void TestSha3_512()
        {
            var sha3_512    = new Sha3_512();
            var bytes       = Encoding.UTF8.GetBytes("abc");
            var hash        = sha3_512.ComputeHash(bytes);
            var sha3_512str = BitConverter.ToString(hash).Replace("-", "").ToLowerInvariant();

            Assert.AreEqual(sha3_512str, "b751850b1a57168a5693cd924b6b096e08f621827444f70d884f5d0240d2712e10e116e9192af3c91a7ec57647e3934057340b4cf408d5a56592f8274eec53f0");
        }
Ejemplo n.º 4
0
        public static void HashEmptyWithSpan(int hashSize)
        {
            var a = new Sha3_512();

            var expected = s_hashOfEmpty.DecodeHex().Substring(0, hashSize);
            var actual   = new byte[hashSize];

            a.Hash(ReadOnlySpan <byte> .Empty, actual);
            Assert.Equal(expected, actual);
        }
Ejemplo n.º 5
0
        public static void HashEmpty()
        {
            var a = new Sha3_512();

            var expected = s_hashOfEmpty.DecodeHex();
            var actual   = a.Hash(ReadOnlySpan <byte> .Empty);

            Assert.Equal(a.DefaultHashSize, actual.Length);
            Assert.Equal(expected, actual);
        }
Ejemplo n.º 6
0
        public bool Equals(BlobFingerprint other)
        {
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            if (ReferenceEquals(null, other))
            {
                return(false);
            }

            return(Size == other.Size &&
                   Sha3_512.SequenceEqual(other.Sha3_512) &&
                   Sha2_256.SequenceEqual(other.Sha2_256) &&
                   Md5.SequenceEqual(other.Md5));
        }
Ejemplo n.º 7
0
        public void Sha3_512_Hash_Should_Throw_On_Null_Input()
        {
            var hasher = new Sha3_512();

            Assert.Throws <ArgumentNullException>(() => hasher.Digest(null));
        }