Created
June 12, 2020 10:13
-
-
Save elvisciotti/763c0dcb020da2e08e4694184a341381 to your computer and use it in GitHub Desktop.
Openssl 1.1 simmetric crypt and decrypt command line on Mac OSx
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
# crypt all txt files into .env and delete source | |
OPENSSL_BIN="/usr/local/Cellar/[email protected]/1.1.1g/bin/openssl" | |
PASSWORD="password-changeme" | |
for TXT in ~/path/to/*.txt; do | |
test -f $TXT && \ | |
$OPENSSL aes-256-cbc -pbkdf2 -a -salt -in "${TXT}" -out "${TXT}.enc" -pass pass:${PASSWORD} && \ | |
rm -f "${TXT}" | |
done |
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
# decrypt all the .env file into txt and delete source | |
OPENSSL_BIN="/usr/local/Cellar/[email protected]/1.1.1g/bin/openssl" | |
PASSWORD="password-changeme" | |
for ENC in ~/path/to/*.enc; do | |
TXT=${ENC/\.enc/} | |
test -f ${TXT} || | |
{ | |
$OPENSSL_BIN aes-256-cbc -pbkdf2 -d -a -in "${TXT}.enc" -out "${TXT}" -pass pass:${PASSWORD} && \ | |
rm -f "${TXT}.enc" | |
} | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment