コード例 #1
0
ファイル: BlowfishTest.cs プロジェクト: alexbasic/Blowfish
        public void EncryptDecryptBlock_NonCryptedKeys()
        {
            byte[] key           = new byte[40];
            var    expectedLeft  = 10U;
            var    expectedRight = 235U;
            var    blowFeistel   = new BlowFeistel();
            var    context       = new BlowfishContext(key);
            UInt32 left          = expectedLeft;
            UInt32 right         = expectedRight;

            blowFeistel.BlowfishEncrypt(context, ref left, ref right);
            blowFeistel.BlowfishDecrypt(context, ref left, ref right);
            Assert.AreEqual(left, expectedLeft);
            Assert.AreEqual(right, expectedRight);
        }
コード例 #2
0
ファイル: BlowfishTest.cs プロジェクト: alexbasic/Blowfish
        public void EncryptDecryptBlock_CryptedKeys()
        {
            byte[] key           = new byte[56];
            var    expectedLeft  = 10U;
            var    expectedRight = 235U;
            var    blowFeistel   = new BlowFeistel();
            Random rnd           = new Random();

            rnd.NextBytes(key);
            var    context = new BlowfishContext(key);
            UInt32 left    = expectedLeft;
            UInt32 right   = expectedRight;

            blowFeistel.CryptPkeys(context);
            blowFeistel.BlowfishEncrypt(context, ref left, ref right);
            blowFeistel.BlowfishDecrypt(context, ref left, ref right);
            Assert.AreEqual(left, expectedLeft);
            Assert.AreEqual(right, expectedRight);
        }