public async Task EncryptFileTest() { // Arrange var aes = new SimpleAes(key); // Act await aes.EncryptAsync(testFile, cryptFile); // Assert Assert.IsTrue(File.Exists(cryptFile)); }
public async Task EncryptTest() { // Arrange var aes = new SimpleAes(key); // Act string encrypted = await aes.EncryptAsync(sample); // Assert Assert.AreEqual(result, encrypted); }
public async Task DecryptEncryptFileTest() { // Arrange var aes = new SimpleAes(key); // Act await aes.DecryptAsync(testCryptFile, outFile); await aes.EncryptAsync(outFile, cryptFile); // Assert Assert.AreEqual(File.ReadAllText(testCryptFile), File.ReadAllText(cryptFile)); }
public async Task EncryptStreamTest() { // Arrange var aes = new SimpleAes(key); using var ms = new MemoryStream(Encoding.UTF8.GetBytes(sample)); // Act byte[] encrypted = await aes.EncryptAsync(ms); string encStr = Convert.ToBase64String(encrypted); // Assert Assert.AreEqual(result, encStr); }
public async Task DecryptEncryptStreamTest() { // Arrange var aes = new SimpleAes(key); using var inStream = new MemoryStream(Convert.FromBase64String(result)); // Act byte[] decrypted = await aes.DecryptAsync(inStream); using var outStream = new MemoryStream(decrypted); byte[] encrypted = await aes.EncryptAsync(outStream); string encStr = Convert.ToBase64String(encrypted); // Assert Assert.AreEqual(result, encStr); }
public async Task EncryptDecryptStreamTest() { // Arrange var aes = new SimpleAes(key); using var inStream = new MemoryStream(Encoding.UTF8.GetBytes(sample)); // Act byte[] encrypted = await aes.EncryptAsync(inStream); using var outStream = new MemoryStream(encrypted); byte[] decrypted = await aes.DecryptAsync(outStream); string decStr = Encoding.UTF8.GetString(decrypted); // Assert Assert.AreEqual(sample, decStr); }