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 TestSafeIntEncryptionMinusOne() { int initial = -1; var encryptedValue = FPEWrapper.EncryptSafeInt(key, tweak, initial); var decryptedValue = FPEWrapper.DecryptSafeInt(key, tweak, encryptedValue); Assert.AreEqual(initial, decryptedValue); }
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); } }