Advertisement
constantin-net

test_no_pw

Jul 14th, 2022
895
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.60 KB | None | 0 0
  1. #!/bin/bash
  2. [ -z "$1" ] && echo -e "USAGE:\n\t-e password passphrase\n\t-c" && exit 0
  3. secret="$HOME/.secret_vault"
  4. secret_p="$HOME/.secret_passphrase"
  5.  
  6. if [ "$1" == "-e" ] && [ -n "$2" ] && [ -n "$3" ]; then
  7.     touch $secret
  8.     touch $secret_p
  9.     echo "$2" | openssl enc -aes-256-cbc -md sha512 -a -pbkdf2 -iter 100000 -salt -pass pass:"$3" > "$secret"
  10.     chmod 600 $secret
  11.     echo "$3" > $secret_p
  12.     chmod 600 $secret_p
  13.     exit
  14. fi
  15. if [ "$1" == "-c" ]; then
  16.    cat "$secret" | openssl enc -aes-256-cbc -md sha512 -a -d -pbkdf2 -iter 100000 -salt -pass pass:`cat "$secret_p"`
  17. fi
  18. exit 0
  19.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement