public void StressTestStringEncryptionUniqueness() { Dictionary <string, string> results = new Dictionary <string, string>(); int times = 1000; Random r = new Random(); List <string> randomInput = GetRandomStrings(times, 20, char.MinValue, char.MaxValue); for (int i = 0; i < times; i++) { var plain = randomInput[i]; var enc = FPEWrapper.EncryptString(key, tweak, plain); var dec = FPEWrapper.DecryptString(key, tweak, enc); Console.WriteLine($"Src:{enc}, Dest:{dec}"); Assert.AreEqual(plain, dec); Assert.AreEqual(plain.Length, dec.Length); if (results.ContainsKey(enc)) { Assert.Fail($"results already contains Encrypted value:{enc} for Plain text:{results[enc]}"); } else { results.Add(enc, plain); } } }
public void TestSafeIntEncryptionMinusOne() { int initial = -1; var encryptedValue = FPEWrapper.EncryptSafeInt(key, tweak, initial); var decryptedValue = FPEWrapper.DecryptSafeInt(key, tweak, encryptedValue); Assert.AreEqual(initial, decryptedValue); }
public void TestIntEncryptionMaxMinusTwo() { int initial = int.MaxValue - 2; var encryptedValue = FPEWrapper.EncryptInt(key, tweak, initial); var decryptedValue = FPEWrapper.DecryptInt(key, tweak, encryptedValue); Assert.AreEqual(initial, decryptedValue); }
public void TestIntToIntRankingMinPlusOne() { int initial = FPEWrapper.MinAllowedSafeInt + 1; var rankedValue = FPEWrapper.RankIntToSafeInt(initial); var unrankedValue = FPEWrapper.UnrankSafeIntToInt(rankedValue); Assert.AreEqual(initial, unrankedValue); }
public void TestSafeIntEncryptionMinPlusTwo() { int initial = FPEWrapper.MinAllowedSafeInt + 2; var encryptedValue = FPEWrapper.EncryptSafeInt(key, tweak, initial); var decryptedValue = FPEWrapper.DecryptSafeInt(key, tweak, encryptedValue); Assert.AreEqual(initial, decryptedValue); }
public void TestRankingLongZero() { long initial = 0; var rankedValue = FPEWrapper.RankLong(initial); var unrankedValue = FPEWrapper.UnrankLong(rankedValue); Assert.AreEqual(initial, unrankedValue); }
public void TestDecimalEncryptionMinusOne() { Decimal initial = -1; var encryptedValue = FPEWrapper.EncryptDecimal(key, tweak, initial); var decryptedValue = FPEWrapper.DecryptDecimal(key, tweak, encryptedValue); Assert.AreEqual(initial, decryptedValue); }
public void TestRankingMinPlusOne() { int initial = int.MinValue + 1; var rankedValue = FPEWrapper.RankInt(initial); var unrankedValue = FPEWrapper.UnrankInt(rankedValue); Assert.AreEqual(initial, unrankedValue); }
public void TestDecimalEncryptionMinPlusTwo() { Decimal initial = FPEWrapper.MinAllowedDecimal + 0.00002M; var encryptedValue = FPEWrapper.EncryptDecimal(key, tweak, initial); var decryptedValue = FPEWrapper.DecryptDecimal(key, tweak, encryptedValue); Assert.AreEqual(initial, decryptedValue); }
public void TestIntToIntRankingZero() { int initial = 0; var rankedValue = FPEWrapper.RankIntToSafeInt(initial); var unrankedValue = FPEWrapper.UnrankSafeIntToInt(rankedValue); Assert.AreEqual(initial, unrankedValue); }
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); }
public void TestLongEncryptionZero() { long initial = 0; var encryptedValue = FPEWrapper.EncryptLong(key, tweak, initial); var decryptedValue = FPEWrapper.DecryptLong(key, tweak, encryptedValue); Assert.AreEqual(initial, decryptedValue); }
public void TestRankingLongMinPlusOne() { long initial = long.MinValue + 1; var rankedValue = FPEWrapper.RankLong(initial); var unrankedValue = FPEWrapper.UnrankLong(rankedValue); Assert.AreEqual(initial, unrankedValue); }
public void TestDecimalEncryptionFiveDecimalPoints() { Decimal initial = 0.00001M; var encryptedValue = FPEWrapper.EncryptDecimal(key, tweak, initial); var decryptedValue = FPEWrapper.DecryptDecimal(key, tweak, encryptedValue); Assert.AreEqual(initial, decryptedValue); }
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); }
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); }
public void TestULongEncryptionMin() { ulong plain = ulong.MinValue + 1; var enc = FPEWrapper.EncryptULong(key, tweak, plain); var dec = FPEWrapper.DecryptULong(key, tweak, enc); Assert.AreEqual(plain, dec); }
public void TestUIntEncryptionZero() { uint plain = 0; var enc = FPEWrapper.EncryptUInt(key, tweak, plain); var dec = FPEWrapper.DecryptUInt(key, tweak, enc); Assert.AreEqual(plain, dec); }
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); }
public void TestUIntEncryptionMin() { uint plain = uint.MinValue + 1; var enc = FPEWrapper.EncryptUInt(key, tweak, plain); var dec = FPEWrapper.DecryptUInt(key, tweak, enc); Assert.AreEqual(plain, dec); }
public void TestStringEncryption() { var plain = "hello world"; var enc = FPEWrapper.EncryptString(key, tweak, plain); var dec = FPEWrapper.DecryptString(key, tweak, enc); Assert.AreEqual(plain, dec); Assert.AreEqual(plain.Length, dec.Length); }
public void TestStringEncryptionUniqueness() { Dictionary <string, string> results = new Dictionary <string, string>(); List <string> randomInput = new List <string>() { "01", "02", "03", "04", "05", "06", "07", "08", "09", "1", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "99", "Demo" }; for (int i = 0; i < randomInput.Count; i++) { var plain = randomInput[i]; var enc = FPEWrapper.EncryptString(key, tweak, plain); var dec = FPEWrapper.DecryptString(key, tweak, enc); Console.WriteLine($"Src:{enc}, Dest:{dec}"); Assert.AreEqual(plain, dec); Assert.AreEqual(plain.Length, dec.Length); if (results.ContainsKey(enc)) { Assert.Fail($"results already contains Encrypted value:{enc} for Plain text:{results[enc]}"); } else { results.Add(enc, plain); } } }
public void StressTestSafeIntEncryption() { Random r = new Random(); int times = 10000; for (int i = 0; i < times; i++) { int plain = r.Next(FPEWrapper.MinAllowedSafeInt, FPEWrapper.MaxAllowedSafeInt); var encryptedValue = FPEWrapper.EncryptSafeInt(key, tweak, plain); var decryptedValue = FPEWrapper.DecryptSafeInt(key, tweak, encryptedValue); Console.WriteLine($"Src:{plain}, Dest:{decryptedValue}"); Assert.AreEqual(plain, decryptedValue); } }
public void StressTestDecimalEncryption() { Random r = new Random(); int times = 10000; for (int i = 0; i < times; i++) { Decimal plain = r.Next(int.MinValue + 2, int.MaxValue - 2); var enc = FPEWrapper.EncryptDecimal(key, tweak, plain); var dec = FPEWrapper.DecryptDecimal(key, tweak, enc); Console.WriteLine($"Src:{enc}, Dest:{dec}"); Assert.AreEqual(plain, dec); } }
public void TestULongEncryptionRandom() { Random r = new Random(); int times = 1000; for (int i = 0; i < times; i++) { ulong plain = (ulong)r.Next(0, int.MaxValue); var enc = FPEWrapper.EncryptULong(key, tweak, plain); var dec = FPEWrapper.DecryptULong(key, tweak, enc); Assert.AreEqual(plain, dec); } }
public void StressTestStringEncryption() { Random r = new Random(); int times = 1000; for (int i = 0; i < times; i++) { var plain = GetRandomString(20); var enc = FPEWrapper.EncryptString(key, tweak, plain); var dec = FPEWrapper.DecryptString(key, tweak, enc); Console.WriteLine($"Src:{enc}, Dest:{dec}"); Assert.AreEqual(plain, dec); Assert.AreEqual(plain.Length, dec.Length); } }
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); } }
public void TestDecimalEncryptionMaxMinusOne() { FPEWrapper.EncryptDecimal(key, tweak, FPEWrapper.MaxAllowedDecimal - 0.00001M); }
public void TestDecimalEncryptionMinPlusOne() { FPEWrapper.EncryptDecimal(key, tweak, FPEWrapper.MinAllowedDecimal + 0.00001M); }
public void TestDecimalEncryptionMin() { FPEWrapper.EncryptDecimal(key, tweak, FPEWrapper.MinAllowedDecimal); }