public void ECBTest(string fileIn, string encFileOut, string decFileOut) { var key = DESUtility.GenerateKey(); var des = new DESUtility(CipherMode.ECB, key); Assert.That(() => des.EncryptData(fileIn), Throws.Nothing); Assert.That(() => des.DecryptData(encFileOut), Throws.Nothing); var h1 = MD5(fileIn); var h2 = MD5(decFileOut); Assert.That(h1.Equals(h2)); }
public void CBCTest(string fileIn, string encFileOut, string decFileOut) { var key = DESUtility.GenerateKey(); var des = new DESUtility(CipherMode.CBC, key); des.EncryptData(fileIn); des.DecryptData(encFileOut); var h1 = MD5(fileIn); var h2 = MD5(decFileOut); Assert.That(h1.Equals(h2)); }
public static void Main(string[] args) { DESUtility des; CommandLine.Parser.Default.ParseArguments <EncryptOptions, DecryptOptions>(args) .MapResult( (EncryptOptions opts) => { var isModeCBC = opts.Mode.Equals(CipherMode.CBC.ToString()); des = new DESUtility(isModeCBC ? CipherMode.CBC : CipherMode.ECB, opts.Key); des.EncryptData(opts.InputFile); return(0); }, (DecryptOptions opts) => { var isModeCBC = opts.Mode.Equals(CipherMode.CBC.ToString()); des = new DESUtility(isModeCBC ? CipherMode.CBC : CipherMode.ECB, opts.Key); des.DecryptData(opts.InputFile); return(0); }, errs => 1); }