Created
December 14, 2009 12:43
-
-
Save jmeridth/256019 to your computer and use it in GitHub Desktop.
C# rijdael test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Test] | |
public void rijndael_test() | |
{ | |
var rijndaelAlg = Rijndael.Create(); | |
byte[] data = Encoding.UTF8.GetBytes("1234567890abcdef"); | |
rijndaelAlg.Key = new ASCIIEncoding().GetBytes("pass123pass123pass123pass123pass"); | |
rijndaelAlg.IV = new ASCIIEncoding().GetBytes("1234567890abcdef"); | |
using (var memoryStream = new MemoryStream()) | |
using (var cryptoStream = new CryptoStream(memoryStream, rijndaelAlg.CreateEncryptor(), CryptoStreamMode.Write)) | |
{ | |
cryptoStream.Write(data, 0, data.Length); | |
cryptoStream.FlushFinalBlock(); | |
var cipherTextBytes = memoryStream.ToArray(); | |
Console.WriteLine(Convert.ToBase64String(cipherTextBytes)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment