Wednesday 22 July 2015

Password encryption in a shell script

This is a good article on how to encrypt a password on Linux for use in a shell script:

http://how-to.linuxcareer.com/using-openssl-to-encrypt-messages-and-files

the bottom line is to use the following command:

echo "some password"  |openssl enc -desx -base64

will ask for an encryption password and will generate an encyrpted digest.
To decode the password we use the following command:

MyPASS=$(echo "UVsB3dMG6VkX1+8889gjklo+g9g=" |openssl enc -desx -base64 -d)