opass

OpenBSD password suite
git clone https://git.pastanoggin.com/opass.git
Log | Files | Refs | README | LICENSE

enc (722B)


      1 #!/bin/sh
      2 # enc: encrypt a password from stdin with a passphrase
      3 # add at least one readable line to the password so you can confirm that the
      4 # output is correct when you're decrypting later, as openssl doesn't give
      5 # errors about wrong passphrases and spits out garbled output instead
      6 set -e
      7 [ "$#" -ne 1 ] && { echo "usage: ${0##*/} passname" 1>&2; exit 1; }
      8 mkdir -pm 700 "$HOME/.passwords/"
      9 passfile="$HOME/.passwords/${1}.cha20"
     10 if [ -r "$passfile" ]; then
     11 	res=''
     12 	while [ "$res" != 'yes' ]; do
     13 		echo -n "file ${passfile} already exists, overwrite it? (yes,no)[no] "
     14 		read -r res
     15 		if [ "$res" == '' ] || [ "$res" == 'no' ]; then
     16 			exit
     17 		fi
     18 	done
     19 fi
     20 openssl enc -e -chacha20 -pbkdf2 -iter 10000 -out "$passfile"