Example #1
0
        public async Task DecryptFileTest()
        {
            // Arrange
            var aes = new SimpleAes(key);

            // Act
            await aes.DecryptAsync(testCryptFile, outFile);

            // Assert
            Assert.IsTrue(File.Exists(outFile));
        }
Example #2
0
        public async Task DecryptStreamTest()
        {
            // Arrange
            var aes   = new SimpleAes(key);
            var bytes = Convert.FromBase64String(result);

            using var ms = new MemoryStream(bytes);

            // Act
            byte[] decrypted = await aes.DecryptAsync(ms);

            var decStr = Encoding.UTF8.GetString(decrypted);

            // Assert
            Assert.AreEqual(sample, decStr);
        }
Example #3
0
        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);
        }
Example #4
0
        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);
        }