Пример #1
0
        public void TestLongEncryptionMinPlusTwo()
        {
            long initial        = long.MinValue + 2;
            var  encryptedValue = FPEWrapper.EncryptLong(key, tweak, initial);
            var  decryptedValue = FPEWrapper.DecryptLong(key, tweak, encryptedValue);

            Assert.AreEqual(initial, decryptedValue);
        }
Пример #2
0
        public void TestLongEncryptionMinusOne()
        {
            long initial        = -1;
            var  encryptedValue = FPEWrapper.EncryptLong(key, tweak, initial);
            var  decryptedValue = FPEWrapper.DecryptLong(key, tweak, encryptedValue);

            Assert.AreEqual(initial, decryptedValue);
        }
Пример #3
0
        public void StressTestLongEncryption()
        {
            Random r     = new Random();
            int    times = 10000;

            for (int i = 0; i < times; i++)
            {
                int plain = r.Next(int.MinValue + 2, int.MaxValue - 2);
                var enc   = FPEWrapper.EncryptLong(key, tweak, plain);
                var dec   = FPEWrapper.DecryptLong(key, tweak, enc);
                Console.WriteLine($"Src:{enc}, Dest:{dec}");
                Assert.AreEqual(plain, dec);
            }
        }