Exemplo n.º 1
0
        private static void ProcessDecryptCommand(DecryptVerbOptions options)
        {
            string inputFilePath = options.InputFilePath;

            Console.Out.WriteLine($@"The file ""{Path.GetFileName(inputFilePath)}"" is being decrypted...");

            byte[] inputByteArray = File.ReadAllBytes(options.InputFilePath);
            byte[] keyByteArray   = File.ReadAllBytes(options.KeyPath);

            IDecryptor desDecryptor = CryptoFactory.CreateDecryptor(inputByteArray, keyByteArray);

            byte[] decryptedData = desDecryptor.DecryptData();

            GenerateOutputFileNameIfNotSet(options);
            FileStream outputFileStream = File.OpenWrite(options.OutputFilePath);

            outputFileStream.Write(decryptedData, 0, decryptedData.Length);

            Console.Out.WriteLine($"The result file is: {Path.GetFileName(options.OutputFilePath)}");
        }