Skip to content

Instantly share code, notes, and snippets.

@Ell
Created May 19, 2011 18:37
Show Gist options
  • Save Ell/981414 to your computer and use it in GitHub Desktop.
Save Ell/981414 to your computer and use it in GitHub Desktop.
private static void EncryptFile(string inputFile, string outputFile)
{
int num;
string s = "h3y_gUyZ";
byte[] bytes = new UnicodeEncoding().GetBytes(s);
string path = outputFile;
FileStream stream = new FileStream(path, FileMode.Create);
RijndaelManaged managed = new RijndaelManaged();
CryptoStream stream2 = new CryptoStream(stream, managed.CreateEncryptor(bytes, bytes), CryptoStreamMode.Write);
FileStream stream3 = new FileStream(inputFile, FileMode.Open);
while ((num = stream3.ReadByte()) != -1)
{
stream2.WriteByte((byte) num);
}
stream3.Close();
stream2.Close();
stream.Close();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment