コード例 #1
0
ファイル: HashTests.cs プロジェクト: AndHell/Andhell.Crypto
        public void VerifyString_CHANGED()
        {
            IHashBox hashBox = new HashBox();

            var result = hashBox.Compute(TEST_STRING);

            Assert.IsFalse(result.Verify(TEST_STRING_CHANGED));
        }
コード例 #2
0
ファイル: HashTests.cs プロジェクト: AndHell/Andhell.Crypto
        public void VerifyString()
        {
            IHashBox hashBox = new HashBox();

            var result = hashBox.Compute(TEST_STRING);

            Assert.IsTrue(result.Verify(TEST_STRING));
        }
コード例 #3
0
ファイル: HashTests.cs プロジェクト: AndHell/Andhell.Crypto
        public void VerifyBytes()
        {
            IHashBox hashBox = new HashBox();

            var bytes  = Encoding.Default.GetBytes(TEST_STRING);
            var result = hashBox.Compute(bytes);

            Assert.IsTrue(result.Verify(bytes));
        }
コード例 #4
0
ファイル: HashTests.cs プロジェクト: AndHell/Andhell.Crypto
        public void VerifyString_CHANGED_Keyed()
        {
            IHashBox hashBox = new HashBox(new Key(TEST_KEY));

            var result = hashBox.Compute(TEST_STRING_CHANGED);
            var tmp    = new HashedTag(TEST_HASHED_KEY);

            Assert.IsFalse(result.Verify(tmp));
        }
コード例 #5
0
ファイル: HashTests.cs プロジェクト: AndHell/Andhell.Crypto
        public void VerifyBytes_CHANGED_Keyed()
        {
            IHashBox hashBox = new HashBox(new Key(TEST_KEY));

            var bytes  = Encoding.Default.GetBytes(TEST_STRING_CHANGED);
            var result = hashBox.Compute(bytes);
            var tmp    = new HashedTag(TEST_HASHED_KEY);

            Assert.IsFalse(result.Verify(tmp));
        }
コード例 #6
0
ファイル: HashTests.cs プロジェクト: AndHell/Andhell.Crypto
        public void VerifyString_Keyed()
        {
            IHashBox hashBox = new HashBox(new Key(TEST_KEY));

            var result = hashBox.Compute(TEST_STRING);
            var hashed = string.Join(", ", result.HashBytes);

            var tmp = new HashedTag(TEST_HASHED_KEY);

            Assert.IsTrue(result.Verify(tmp));
        }
コード例 #7
0
ファイル: HashTests.cs プロジェクト: AndHell/Andhell.Crypto
        public void VerifyNullParamters()
        {
            HashBox hashBox = new HashBox();

            string strNull = null;

            Assert.ThrowsException <ArgumentNullException>(() => hashBox.Compute(strNull));
            strNull = "";
            Assert.ThrowsException <ArgumentNullException>(() => hashBox.Compute(strNull));

            byte[] bNull = null;
            Assert.ThrowsException <ArgumentNullException>(() => hashBox.Compute(bNull));
            bNull = new byte[0];
            Assert.ThrowsException <ArgumentException>(() => hashBox.Compute(bNull));


            Key kNull = null;

            Assert.ThrowsException <ArgumentNullException>(() => new HashBox(kNull));
        }
コード例 #8
0
 private void NewHashBoxAndIndexList(TElement value, TElement key)
 {
     hashBox   = new HashBox(value, value.GetHashCode(), key);
     indexList = value.GetHashCode() / maxUIntDivider;
 }