public static string Decrypt(PublicSecret secret, string key) { Secret internalSecret = new Secret() { IV = Convert.FromBase64String(secret.IV), Data = Convert.FromBase64String(secret.Data) }; AESEncryption encryptor = new AESEncryption(key); return encryptor.Decrypt(internalSecret); }
public static PublicSecret Encrypt(string plainText, string key) { AESEncryption encryptor = new AESEncryption(key); Secret secret= encryptor.Encrypt(plainText); PublicSecret result = new PublicSecret(); result.IV = Convert.ToBase64String(secret.IV); result.Data = Convert.ToBase64String(secret.Data); return result; }
public void TestMethod1() { const string sourceText = "This is a test, indeed."; const string encryptionKey = "12345abcde...."; AESEncryption enc = new AESEncryption(encryptionKey); Secret result = enc.Encrypt(sourceText); string decResult = enc.Decrypt(result); Assert.AreEqual(sourceText, decResult); }