Skip to content

Instantly share code, notes, and snippets.

@tvvignesh
Last active July 19, 2018 20:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tvvignesh/356e8674f5cfc6e33d3baf2830bb41bf to your computer and use it in GitHub Desktop.
Save tvvignesh/356e8674f5cfc6e33d3baf2830bb41bf to your computer and use it in GitHub Desktop.
Encrypt and Decrypt files using GPG Algorithm - https://www.gnupg.org/

Remove existing GPG Secret Keys

gpg --delete-secret-keys "Vignesh T.V."

Remove existing GPG Public Keys

gpg --delete-keys "Vignesh T.V."

Generate GPG Keys

gpg --gen-key

Export GPG Public Key

gpg --output ./mygpg.key --armor --export vigneshviswam@gmail.com

Export GPG Private Key

gpg --list-secret-keys (Get the ID from there and replace the ID below)

gpg --export-secret-keys 0009E10FB8CF0BD4699A72257250F6DB43FE74C2 > gpg-private.asc

Encrypt the file using GPG

gpg --trust-model always --encrypt --armor -o ./encrypted.asc -r vigneshviswam@gmail.com ./file.txt


Decryption

Import Private Key

gpg --import gpg-private.asc

Find GPGConf directories

gpgconf –list-dirs

Create GPGConf file in any of those directories with name gpg-agent.conf and with content

allow-loopback-pinentry

Reload GPG Agent

gpgconf --kill gpg-agent gpg-connect-agent reloadagent /bye

Create a .bat file with these contents (%1 is the command line argument to be passed from NiFi)

echo |gpg --pinentry-mode loopback --batch --passphrase-fd 0 -d %1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment