Skip to content

Instantly share code, notes, and snippets.

@murven
Created March 22, 2011 06:35
Show Gist options
  • Save murven/880858 to your computer and use it in GitHub Desktop.
Save murven/880858 to your computer and use it in GitHub Desktop.
This snippet generates a random 256-bit Key and IV to be used for encryption purposes using the AES algorithm. Better when used from LINQPad.
var aesAlgorithm = new System.Security.Cryptography.AesManaged();
aesAlgorithm.GenerateIV();
aesAlgorithm.GenerateKey();
var key = aesAlgorithm.Key;
var iv = aesAlgorithm.IV;
Console.WriteLine(key.Length);
Console.WriteLine(key);
Console.WriteLine(iv.Length);
Console.WriteLine(iv);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment