-
-
Save alex-alekseichuk/57089c230bcaa739899d3183f04472da to your computer and use it in GitHub Desktop.
Edit encrypted by password text file
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
#!/usr/bin/bash | |
echo -n 'Password: ' | |
read -s password | |
plain=$(mktemp) | |
openssl enc -aes-256-cbc -pbkdf2 -iter 100000 -pass pass:$password -d <$1 >$plain 2>/dev/null | |
prev=$(mktemp) | |
cp $plain $prev | |
vi $plain | |
if ! (cmp -s $prev $plain); then | |
openssl enc -aes-256-cbc -pbkdf2 -iter 100000 -pass pass:$password <$plain >$1 2>/dev/null | |
fi | |
rm -rf $plain | |
rm -rf $prev |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment