Last active
December 8, 2016 10:56
-
-
Save luizpestana/b40ab7d5a7f5a16d4a07f492b06c7b5f to your computer and use it in GitHub Desktop.
Encrypt clipboard messages using public key
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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