public override void Run() { try { using (var inputStream = new FileStream(InputFileName, FileMode.Open)) using (var keyStream = new FileStream(InputFileName.Replace(".txt", ".key.txt"), FileMode.Create)) using (var outputStream = new FileStream(OutputFileName, FileMode.Create)) { switch (Method) { case EncryptionMethod.Aes: { using (var aes = Aes.Create()) { WriteKeys(keyStream, aes); WriteData(inputStream, outputStream, aes); } break; } case EncryptionMethod.Des: { using (var des = DES.Create()) { WriteKeys(keyStream, des); WriteData(inputStream, outputStream, des); } break; } case EncryptionMethod.Rc2: { using (var rc2 = RC2.Create()) { WriteKeys(keyStream, rc2); WriteData(inputStream, outputStream, rc2); } break; } case EncryptionMethod.Rijndael: { using (var rijndael = Rijndael.Create()) { WriteKeys(keyStream, rijndael); WriteData(inputStream, outputStream, rijndael); } break; } default: throw new EnigmaException("Unknown encryption type"); } } } catch (FileNotFoundException e) { throw new EnigmaException($"encrypt: file not found: {e.FileName}"); } catch (IOException e) { throw new EnigmaException($"encrypt: {e.Message}"); } }
public override string GetOutputFileName() { return(InputFileName.Replace(".tmx", ".map")); }