Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
FileStream myStream = new FileStream("TestData.txt", FileMode.OpenOrCreate);
Aes aes = Aes.Create();
byte[] key = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16 };
byte[] iv = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16 };
CryptoStream cryptStream = new CryptoStream(
myStream,
aes.CreateEncryptor(key, iv),
CryptoStreamMode.Write);
StreamWriter sWriter = new StreamWriter(cryptStream);
sWriter.WriteLine("Hello World!");
sWriter.Close();
cryptStream.Close();
myStream.Close();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment