Exemplo n.º 1
0
        public void TestDateEncryption()
        {
            var plain = DateTime.Now;

            DateTime enc = FPEWrapper.EncryptDateTime(key, tweak, plain);
            DateTime dec = FPEWrapper.DecryptDateTime(key, tweak, enc);

            Assert.AreEqual(plain, dec);
        }
Exemplo n.º 2
0
        public void StressTestDateEncryption()
        {
            Random r     = new Random();
            int    times = 1000;

            for (int i = 0; i < times; i++)
            {
                int year  = r.Next(1900, 2020);
                int month = r.Next(1, 12);
                int date  = r.Next(1, 28);

                int hour   = r.Next(0, 23);
                int minute = r.Next(0, 59);
                int sec    = r.Next(0, 59);
                int ms     = r.Next(0, 999);
                var plain  = new DateTime(year, month, date, hour, minute, sec, ms);

                DateTime enc = FPEWrapper.EncryptDateTime(key, tweak, plain);
                DateTime dec = FPEWrapper.DecryptDateTime(key, tweak, enc);
                Console.WriteLine($"Src:{enc}, Dest:{dec}");
                Assert.AreEqual(plain, dec);
            }
        }