public void Test() { Random rand = new Random(); AsymmetricEncryption ae = new AsymmetricEncryption(); for (int i = 0; i < 100; i++) { byte[] data = new byte[10000]; rand.NextBytes(data); string text = data.ToBase64String(); string ciphertext = ae.EncryptToString(text); string plaintext = ae.DecryptToString(ciphertext); Assert.AreEqual(text, plaintext); } }
public void DecryptWithoutPrivateKeyTest() { var encryption = new AsymmetricEncryption(_publicKey, null); Assert.Throws(typeof(CryptographicException), () => { encryption.DecryptToString(encryption.Encrypt("aw3lrifos83fusoi3fjsofisjfo")); }); }
public void EncryptionStringEqualsTest() { var encryption = new AsymmetricEncryption(_publicKey, _privateKey); Assert.AreEqual("aw3lrifos83fusoi3fjsofisjfo", encryption.DecryptToString(encryption.Encrypt("aw3lrifos83fusoi3fjsofisjfo"))); }