public void SymmetricEncryptionMac() { var secretMessage = "This is very secret"; var cipher = SymmetricCryptoProviderWithMac.SimpleEncryptWithPassword(secretMessage, "123456789123", Encoding.UTF8); var clear = SymmetricCryptoProviderWithMac.SimpleDecryptWithPassword(cipher, "123456789123", Encoding.UTF8); Assert.AreEqual(secretMessage, clear); }
public void SymmetricEncryptionFileMac() { var path = @"C:\Test\test.txt"; var text = File.ReadAllText(path); SymmetricCryptoProviderWithMac.SimpleEncryptFileWithPassword(new FileInfo(path), "123456789123"); SymmetricCryptoProviderWithMac.SimpleDecryptFileWithPassword(new FileInfo(path), "123456789123"); var text2 = File.ReadAllText(path); Assert.AreEqual(text, text2); }
public void SymmetricEncryptionRawMac() { byte[] key = new byte[16]; byte[] auth = new byte[16]; var rng = new RNGCryptoServiceProvider(); rng.GetBytes(key); rng.GetBytes(auth); var secretMessage = "This is very secret"; var cipher = SymmetricCryptoProviderWithMac.EncryptMessage(secretMessage, key, auth, Encoding.UTF8); var clear = SymmetricCryptoProviderWithMac.DecryptMessage(cipher, key, auth, Encoding.UTF8); Assert.AreEqual(secretMessage, clear); }