Exemple #1
0
        public void TestSqlDateEncryption2()
        {
            var plain = new DateTime(1984, 10, 1);

            DateTime enc = FPEWrapper.EncryptSqlDateTime(key, tweak, plain);
            DateTime dec = FPEWrapper.DecryptSqlDateTime(key, tweak, enc);

            Assert.AreEqual(plain, dec);
        }
Exemple #2
0
        public void TestSqlDateEncryptionMax()
        {
            var plain = FPEWrapper.MaxPossibleSqlDate;

            DateTime enc = FPEWrapper.EncryptSqlDateTime(key, tweak, plain);
            DateTime dec = FPEWrapper.DecryptSqlDateTime(key, tweak, enc);

            Assert.AreEqual(plain, dec);
        }
Exemple #3
0
        public void TestSqlDateEncryption()
        {
            var plain = DateTime.Now;

            DateTime enc = FPEWrapper.EncryptSqlDateTime(key, tweak, plain);
            DateTime dec = FPEWrapper.DecryptSqlDateTime(key, tweak, enc);

            Assert.AreEqual(plain, dec);
        }
Exemple #4
0
        public void StressTestSqlDateEncryption()
        {
            Random r     = new Random();
            int    times = 10000;

            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.EncryptSqlDateTime(key, tweak, plain);
                DateTime dec = FPEWrapper.DecryptSqlDateTime(key, tweak, enc);
                Console.WriteLine($"Src:{enc}, Dest:{dec}");
                Assert.AreEqual(plain, dec);
            }
        }