Skip to content

Instantly share code, notes, and snippets.

@elvisciotti
Created June 12, 2020 10:13
Show Gist options
  • Save elvisciotti/763c0dcb020da2e08e4694184a341381 to your computer and use it in GitHub Desktop.
Save elvisciotti/763c0dcb020da2e08e4694184a341381 to your computer and use it in GitHub Desktop.
Openssl 1.1 simmetric crypt and decrypt command line on Mac OSx
# 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
# 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