GnuPG is a popular command-line tool for encryption, decryption, and digital signatures. It can protect files with a password, create public and private key pairs, sign files, and verify signatures. You can install GnuPG in Termux and use simple commands to learn how file encryption and key management work on Android.
Here’s what you can do with GnuPG in Termux:
- Encrypt and decrypt files.
- Protect files with a password.
- Create public and private key pairs.
- Create digital signatures.
- Verify digital signatures.
- List public and secret keys.
- View key fingerprints.
- Import and export keys.
- Create ASCII-armored files.
- Generate revocation certificates.
- Change key passphrases.
Install GnuPG in Termux
You only need one command to install GnuPG in Termux. Run the command below in the Termux terminal to install it.
Update Termux packages.
pkg update && pkg upgrade -yInstall GnuPG.
pkg install gnupg -yCheck the installed GnuPG version.
gpg --versionGnuPG is now installed and ready to use.
Usage Commands
After installing GnuPG, you can use the following commands to encrypt files, decrypt files, create keys, and work with digital signatures.
Show the GnuPG help menu.
gpg --helpCreate a text file for testing.
echo "Hello from Termux" > message.txtEncrypt a file with a password.
gpg -c message.txtGnuPG will ask you to enter a passphrase. After encryption, a file named message.txt.gpg will be created.
Decrypt the encrypted file.
gpg -d message.txt.gpgTo save the decrypted content into a new file:
gpg -o decrypted.txt -d message.txt.gpgCreate a new GnuPG key pair.
gpg --generate-keyFollow the instructions shown in the terminal to create your key.
List public keys.
gpg --list-keysList secret keys.
gpg --list-secret-keysShow key fingerprints.
gpg --fingerprintCreate a digital signature for a file.
gpg --sign message.txtCreate a clear-text signature.
gpg --clear-sign message.txtCreate a detached signature.
gpg --detach-sign message.txtVerify a signature.
gpg --verify message.txt.ascExport a public key to an ASCII file.
gpg --armor --export YOUR_EMAIL > public-key.ascImport a public or private key.
gpg --import public-key.ascYou can also use GnuPG’s short commands for common operations.
List keys.
gpg -kList secret keys.
gpg -KCreate an ASCII-armored output.
gpg -aSpecify an output file.
gpg -o output.txtEncrypt a file for a specific recipient.
gpg -e -r USER-ID message.txtSign and encrypt a file for a specific recipient.
gpg -se -r USER-ID message.txtGenerate a revocation certificate for a key.
gpg --generate-revocationRun an operation without making changes.
gpg --dry-runUse the following command to see the complete available command list:
gpg --helpGnuPG provides many other commands and options for advanced key management, encryption, signatures, and OpenPGP operations.
End Note
GnuPG is a useful command-line tool for learning about file encryption, digital signatures, and public-key cryptography. It provides many options for protecting files and managing keys from the Termux terminal.

