This document describes step by step guide how to use crypt
with GPG (GnuPG).
Current implementation supports encryption and decryption using armored keys only. Support for keyring is planned in the next release.
Generate a new GPG key pair:
gpg --gen-key
Identify your public key by running:
gpg --list-keys
Run this command to export your GPG Public Key (armored):
gpg --armor --export --output my_pubkey.gpg $ID
Encrypt:
echo test | crypt encrypt gpg --public-key my-public-key.gpg --out test.enc
echo test | ./crypt enc gpg --keyserver keyserver.ubuntu.com --key-id 51716619E084DAB9 --out test.enc
Identify your public key by running:
gpg --list-secret-keys
Run this command to export your GPG Private Key (armored):
gpg --export-secret-keys --armor $ID > my-private-key.asc
Decrypt:
crypt decrypt --private-key my-private-key.asc --in test.enc
Decrypt with passphrase for the private key:
crypt decrypt --private-key my-private-key.asc --passphrase <passphrase> --in test.enc
Also, you can set GPG_PASSPHRASE
environment variable:
export GPG_PASSPHRASE=<passphrase>
crypt decrypt --private-key my-private-key.asc --in test.enc
This section describes current limitations and planned fixes in the next releases.
In the GnuPG 2.1 keyring format has changed, see What’s new in GnuPG 2.1 for more details.
Use --export-secret-keys
to export the secret keys , or --export
to export your public keys.
Upstream issues: