Skip to content

Instantly share code, notes, and snippets.

@abruzzi
Created November 7, 2014 13:55
Show Gist options
  • Save abruzzi/b9592948560ece923497 to your computer and use it in GitHub Desktop.
Save abruzzi/b9592948560ece923497 to your computer and use it in GitHub Desktop.
Encrypt and Decrypt a string

An easy way to encrypt and decrypt string in command line

$ echo -n "juntao/pas$$w0rd" | openssl enc -e -aes-256-cbc -a -salt

type your password twice:

enter aes-256-cbc encryption password:xxxxx
Verifying - enter aes-256-cbc encryption password:xxxxx

and you will get a string like this:

U2FsdGVkX18isExx5kk885ZxJc54+gu7fwlVKGU3zrM=

and if you want it be decrypted, simplye do this:

$ echo "U2FsdGVkX18isExx5kk885ZxJc54+gu7fwlVKGU3zrM=" | openssl enc -d -aes-256-cbc -a -salt

Note the -d option in command openssl, that indicate decrypt, after you type the correct password, you will see the decrypted string:

juntao/pas$$w0rd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment