howtophil icon

Encypt then encode to codegroup to write down

howtophil | PRO | 01/10/17 01:49:29 AM UTC | 0 ⭐ | 587 👁️ | Never ⏰ | []
Bash |

1.05 KB

|

None

|

0 👍

/

0 👎

#!/bin/bash
cmdopt=$1
 
if [ -z $cmdopt ]; then
    echo "Please specify -e to encrypt or -d to decrypt"
fi
 
if [[ $cmdopt == "-e" ]]; then
    echo "#---------------------------------------------------"
    echo "# You'll be asked for your encryption key"
    echo "# After you enter that key twice:"
    echo "# Type the text you'd like to encrypt"
    echo "# and hit ctrl-d when done."
    echo "# Then you'll get the codegroup encoded form"
    echo "# of your encrypted data."
    echo "# Which you can write down wherever."
    echo "#---------------------------------------------------"
    ccrypt |codegroup
fi
 
if [[ $cmdopt == "-d" ]]; then
    echo "#---------------------------------------------------"
    echo "# Type in the codegroup enccoded data to decrypt" 
    echo "# and hit ctrl-d when done."
    echo "# Then you'll be asked for your encryption key."
    echo "# After that, you'll get the ccrypt decrypted"
    echo "# version of your encrypted data."
    echo "#---------------------------------------------------"
    todecrypt=$(cat)
    echo "$todecrypt" |codegroup -d |ccrypt -d
fi

Comments