Last active
October 18, 2018 16:17
-
-
Save taikedz/fb89c1f7b5c275fe70125852b9fe1e85 to your computer and use it in GitHub Desktop.
Decrypt a symmetric password encrypted string using openssl, and put it in the x-clipboard (`shift + insert` to paste) uing xclip
This file contains hidden or 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
# Example to create an encrypted string: | |
# echo "hi"|openssl aes-256-cbc -a | |
# the decryption example below is for password "pass" | |
# requires openssl and xclip | |
give-my-token() { | |
# Using 1.1.0+ | |
echo "U2FsdGVkX1/uwQA5Uc/F8vTYJEWZcgcuY+V9DVQovNs="|openssl aes-256-cbc -a -d 2>/dev/null|xclip || { | |
echo "Could not decrypt." | |
return 1 | |
} | |
echo "(written to x-clipboard)" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note that the
versions of OpenSSL must match to decrypt dataOpenSSL may break compatibility between versions. For example, data encrypted withOpenSSL 1.0.2g 1 Mar 2016
cannot be decrypted usingOpenSSL 1.1.0g 2 Nov 2017
and a correct password.This was due to a change in hash algorithm in the lead-up to
1.1.0
and a workaround can be used to force the old behaviour. For obvious reasons, it's best to use the new behaviour, and update all encrypted files where appropriate.To decrypt an old ciphertext with 1.1.0+, use the arguments
-md md5
(-md
was added to openssl sometime between the aforementioned versions precisely for this compatibility workaround)