Search code examples
encryptionantpgp

PGP Decrypt using ANT


We have an ant build file that needs to encrypt/decrypt a bunch of files using a PGP Public Key. Is there a native (or library) ant task to do so. I really would like to avoid solutions that involve the use of <exec> (unless ther is no other way around).

Much obliged


Solution

  • This is how you do it with <exec>:

    <exec executable="sh" >
        <arg value="-c" />
        <arg value="echo ${encrypted.passphrase} | gpg --passphrase-fd 0 --output ${data.dir}/Performance.dat --decrypt ${data.dir.encrypted}/${encrypted.file.name}"/>
    </exec>
    

    This way you provide the key passphrase in one line. But it would be nice to do it using something that is no OS dependent.