public void Do_Encrypt(string data) { var initialVector = new byte[16]; var key = new byte[32]; var rnd = new Random(); rnd.NextBytes(key); rnd.NextBytes(initialVector); var sut = new CryptographyProvider(); var encryptedValue = sut.Encrypt(data, key, initialVector, Encoding.ASCII); var value = sut.Decrypt(encryptedValue, key, initialVector, Encoding.ASCII); Assert.Equal(data, value); }
/// <summary> /// Encrypts the specified plainText and returns the encrypted text. /// </summary> /// <param name="plainText">The text tp encrypt.</param> /// <returns>The encrypted text.</returns> public static string Encrypt(string plainText) { return(_provider.Encrypt(plainText)); }