<< back to sysax.com Product page

12.4. Encrypting files with OpenPGP

The sysaxftp.exe program can be used to encrypt files using the -pgpencrypt option. If a keyring file name is not explicitly specified, the default keyring is used to obtain the public key used for encryption. The -armor option is used to convert the encrypted binary file into an ascii text format. The -signusername option also can be used to sign the encrypted file using the private key of the sender to establish the source of the encrypted file.

Exhibit 12.13. Syntax of command for encrypting files with openPGP

sysaxftp.exe -pgpencrypt <file to encrypt> -username <username or email> [-armor] [-pgpout <output filename>]  [-pgpkeyring <keyring file name>] [-signusername <username or email>] [-signpassphrase <private key passphrase>] [-signkeyring <keyring file name>]

Exhibit 12.14. Examples for using the command for encrypting files with openPGP

sysaxftp.exe -pgpencrypt myfile.txt -username john.doe #encrypt myfile.txt to myfile.pgp using the public key for john.doe from the default keyring

sysaxftp.exe -pgpencrypt myfile.txt -username john.doe -pgpout myfile.enc -pgpkeyring mykeyring.pgp #encrypt myfile.txt to myfile.enc using the public key from mykeyring.pgp

The pgpencrypt command can be used to encrypt files from within a script. The pgpresult predefined status flag is set to the predefined constant success if the corresponding command completed successfully. If an empty string is passed in for the output filename, it will be derived from the input filename.

Exhibit 12.15. Syntax of command for encrypting files with openPGP

pgpencrypt <file to encrypt>, <username or email>, <output filename>, [<keyring file name>];

Exhibit 12.16. Examples for using the command for encrypting files with openPGP

pgpencrypt "myfile.txt", "john.doe", "myfile.enc";  #encrypt myfile.txt to myfile.enc using the public key for user john.doe

pgpencrypt "myfile.txt", "john.doe", "";  #encrypt myfile.txt to myfile.pgp using the public key for user john.doe

pgpencrypt "myfile.txt", "john.doe", "myfile.enc", "mykeyring.pgp";  #encrypt myfile.txt using the public key from mykeyring.pgp

The pgparmoron or pgparmoroff commands can be called before the pgpencrypt command to enable or disable the conversion of the encrypted binary file into an ascii text format.

Exhibit 12.17. Syntax of commands for encrypting files with openPGP

pgparmoron;

pgparmoroff;

Exhibit 12.18. Examples for using the commands for encrypting files with openPGP

pgparmoron; #turn on ascii text armoring

pgparmoroff; #turn off ascii text armoring

The pgpsign command can be called before the pgpencrypt command to sign the encrypted file using the private key of the sender to establish the source of the encrypted file.

Exhibit 12.19. Syntax of command for encrypting files with openPGP

pgpsign <username or email>, <private key passphrase>, [<keyring file name>];

Exhibit 12.20. Examples for using the command for encrypting files with openPGP

pgpsign "jane.doe", "mypass"; #sign using the private key for user jane.doe

pgpsign "jane.doe", "mypass", "mykeyring.pgp"; #sign using the private key for user jane.doe from mykeyring.pgp