PGPENCRYPT Encrypt a file using PGP |
Top Previous Next |
. This script command encrypts a file using PGP encryption. Files may be decrypted using the FileLink PGPDECRYPT script command or any other PGP or GPG encryption application.
To encrypt a file, you must have an existing keyring containing the private key you wish to use. (If you have multiple private keys on a given keyring, FileLink will always use the first key.) You must also have the public key of the recipient of the file on the keyring and use the /user, /comment, and/or /email options to specify all or part of the key ID for it to be identified.
Use the /armor option if you wish the resulting file to be in ASCII armored format.
Use the /sign option if you wish the resulting file to be digitally signed.
Use the /textmode option if you wish the resulting file to be a text mode format.
When signing an encrypted file, you must specify your passphrase either within the command itself using the /pw option or by previously specifying it when creating or selecting a key using the FileLink configurator.
Important FileLink secures your passphrase by saving it in an encoded format in the Windows registry along with its other settings. The passphrase is also never displayed in the FileLink console window nor written to any log file. But be aware that it does appear in clear-text in a script file. Therefore, the method of specifying your passphrase during configuration is the most secure.
It is typical for encrypted files to have an extension of .gpg (except where noted below). In most of the examples below, we add this extension at the end of the original file to create the name of the encrypted version of the file. We recommend that you adopt these conventions as well.
Original File Name: "datafile.txt" Encrypted File Name: "datafile.txt.gpg"
For ASCII armored files (see below):
Original File Name: "datafile.txt" Encrypted File Name: "datafile.txt.asc"
In the example below a file is encrypted using a public key on the default keyring that is identified by a user name of “Dick Tracy”.
PGPENCRYPT "datafile.txt" "datafile.txt.gpg" /user="Dick Tracy"
In the example below, more of the key ID is specified.
PGPENCRYPT "datafile.txt" "datafile.txt.gpg" /user="Dick Tracy" /[email protected]
The following example encrypts a file and specifies the keyring is in an alternate location.
PGPENCRYPT "datafile.txt" "datafile.txt.gpg" "c:\gnupg" /user="Dick Tracy"
The following example encrypts a file and specifies the output format to be ASCII armored. (The .asc extension is typically used for these types of files.)
PGPENCRYPT "datafile.txt" "datafile.txt.asc /user="Dick Tracy" /armor
The following example encrypts a file and digitally signs it.
PGPENCRYPT "datafile.txt" "datafile.txt.gpg" /user="Dick" /sign /pw="my passphrase"
Important When encrypting a file, PGP requires the public key of the recipient so that only the recipient may decrypt the file. The recipient’s public key must be present on your keyring at the time of encryption. Keys are imported to your keyring by way of the PGPIMPORT script command or by using the Manage Key functionality in the FileLink configurator.
For advanced troubleshooting, you may include the /gpglog option which results in commands and responses to and from GnuPG (gpg.exe) being written to the specified log file. (GnuPG is the underlying PGP encryption/decryption engine used by FileLink.) The following example encrypts a file and writes to a log file named “encrypt.log”.
PGPENCRYPT "datafile.txt" "datafile.txt.gpg" /user="Dick" /gpglog="encrypt.log"
If a fully qualified file name is not specified, the log file will be created in the current FileLink working folder. If the file exists, it will be appended to. Delete the file before each PGPENCRYPT command if you want only a single command to be logged.
In some cases you may be required to encrypt a file using a GnuPG option that is not directly implemented by FileLink. In such cases, the /gpgopt option allows you to specify the necessary option(s) in the PGPENCRYPT command and have it passed to GnuPG. The following example encrypts a file and specifies an unsupported option.
"datafile.txt" "datafile.txt.gpg" /user="Dick" /gpgopt="--force-v3-sigs"
Multiple GnuPG options may be passed using /gpgopt. When doing so, separate each complete option with a semi-colon as shown below.
PGPENCRYPT ... /gpgopt="--force-v3-sigs;--no-verbose"
Be sure to always precede each GnuPG option with two dashes.
Related Command(s): PGPDECRYPT, PGPIMPORT
|