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 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 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); } }