Exemple #1
0
    public override bool Process(dynamic profile, dynamic procContext)
    {
        string inputFile = procContext[TaskContext.InputFileField];

        if (!File.Exists(inputFile))
        {
            return(false);
        }
        string outputFile;

        if (Regex.IsMatch(inputFile, TaskContext.OutputFileMatchPattern))
        {
            outputFile = Regex.Replace(inputFile, TaskContext.OutputFileMatchPattern, TaskContext.OutputFileReplacePattern, RegexOptions.IgnoreCase);
        }
        else
        {
            return(false);
        }
        if (string.IsNullOrEmpty(TaskContext.SenderKeyFile))
        {
            PGPEncryptDecrypt.EncryptFile(inputFile, outputFile, TaskContext.RecipientKeyFile, TaskContext.Armor, true);
        }
        else
        {
            PGPEncryptDecrypt.EncryptAndSign(inputFile, outputFile, TaskContext.RecipientKeyFile, TaskContext.SenderKeyFile, TaskContext.SenderPassphrase, TaskContext.Armor);
        }
        return(true);
    }
Exemple #2
0
 /// <summary>
 /// Encrypts the and sign.
 /// </summary>
 /// <param name="inputFile">The input file.</param>
 /// <param name="publicKeyFile">The public key file.</param>
 /// <param name="privateKeyFile">The private key file.</param>
 /// <param name="passPhrase">The pass phrase.</param>
 /// <param name="outputFile">The output file.</param>
 /// <param name="overwriteTarget">if set to <c>true</c> [overwrite target].</param>
 /// <param name="removeSource">if set to <c>true</c> [remove source].</param>
 /// <param name="armor">if set to <c>true</c> [armor].</param>
 public static void EncryptAndSign(string inputFile, string publicKeyFile, string privateKeyFile, string passPhrase, string outputFile, bool overwriteTarget, bool removeSource, bool armor)
 {
     Common.ValidateFile(inputFile);
     Common.ValidateFile(publicKeyFile);
     Common.ValidateFile(privateKeyFile);
     Common.ValidateOverwrite(overwriteTarget, outputFile);
     PGPEncryptDecrypt.EncryptAndSign(inputFile, outputFile, publicKeyFile, privateKeyFile, passPhrase, armor);
     Common.RemoveFile(removeSource, inputFile);
 }