// (c) 2006 Richard Grimes // www.grimes.demon.co.uk using System; using System.Security.Cryptography; using System.Security.Cryptography.Xml; using System.Xml; using System.IO; class App { // parameters: e|d infile outfile passphrase static void Main(string[] args) { if (args.Length < 4) { Console.WriteLine("Usage: symm e|d infile outfile passphrase"); return; } bool bEncrypt = (args[0][0] == 'e'); string infile = args[1]; if (!File.Exists(infile)) { Console.WriteLine("{0} does not exist", infile); return; } string outfile = args[2]; if (File.Exists(outfile)) { File.Delete(outfile); } string passphrase = args[3]; Rijndael key = new RijndaelManaged(); PasswordDeriveBytes pdb = new PasswordDeriveBytes(passphrase, null); key.Key = pdb.GetBytes(key.KeySize / 8); if (bEncrypt) { Encrypt(infile, outfile, key); } else { Decrypt(infile, outfile, key); } } static void Encrypt(string infile, string outfile, SymmetricAlgorithm key) { } static void Decrypt(string infile, string outfile, SymmetricAlgorithm key) { } }