Skip to content

Instantly share code, notes, and snippets.

@luizpestana
Last active December 8, 2016 10:56
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 luizpestana/b40ab7d5a7f5a16d4a07f492b06c7b5f to your computer and use it in GitHub Desktop.
Save luizpestana/b40ab7d5a7f5a16d4a07f492b06c7b5f to your computer and use it in GitHub Desktop.
Encrypt clipboard messages using public key
# include this in your ~/.bashrc
# enc usage:
# 1) put the public keys (pem files) in ~/.keylist/recipient_name.pem
# 2) copy the text you want to encrypt
# 3) go to terminal and type enc recipient_name to encrypt your clipboard
# dec usage:
# 1) copy the encrypted message
# 2) go to terminal and type dec
function enc () {
PUBFILE=~/.keylist/$1.pem
if [ -f $PUBFILE ];
then
TEXT=`xclip -o`
echo "ENCRYPTED: $TEXT"
echo $TEXT | openssl rsautl -encrypt -ssl -pubin -inkey $PUBFILE | openssl enc -base64 | xclip -selection c
else
echo "ERROR: File $PUBFILE does not exist."
fi
}
function dec () {
KEYFILE=~/.ssh/id_rsa
xclip -o | openssl enc -base64 -d | openssl rsautl -decrypt -inkey $KEYFILE
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment