mirror of
https://github.com/octoleo/Purse.git
synced 2025-02-05 21:48:30 +00:00
Option to read password by username
This commit is contained in:
parent
25122d0549
commit
c8e0f6d494
@ -20,7 +20,7 @@ Run the script with `./pwd.sh`
|
||||
|
||||
Type `w` to write a password.
|
||||
|
||||
Type `r` to read passwords. Pipe to `grep` and `pbcopy` or `xsel`, for example.
|
||||
Type `r` to read a password or all passwords.
|
||||
|
||||
Type `d` to delete a password.
|
||||
|
||||
|
8
pwd.sh
8
pwd.sh
@ -59,11 +59,15 @@ encrypt () {
|
||||
read_pass () {
|
||||
# Read a password from safe.
|
||||
|
||||
if [[ -z ${username} || ${username} == "all" ]] ; then
|
||||
username=""
|
||||
fi
|
||||
|
||||
if [ ! -s ${safe} ] ; then
|
||||
fail "No passwords found"
|
||||
else
|
||||
get_pass "Enter password to unlock ${safe}: " ; echo
|
||||
decrypt ${password} ${safe} || fail "Decryption failed"
|
||||
decrypt ${password} ${safe} | grep " ${username}" || fail "Decryption failed"
|
||||
fi
|
||||
}
|
||||
|
||||
@ -120,6 +124,7 @@ create_username () {
|
||||
userpass=$password
|
||||
else
|
||||
userpass=$(gen_pass)
|
||||
echo "Password: ${userpass}"
|
||||
fi
|
||||
}
|
||||
|
||||
@ -143,6 +148,7 @@ elif [ "${action}" == "d" ] ; then
|
||||
read -p "Username to delete? " username
|
||||
write_pass
|
||||
else
|
||||
read -p "Username to read? (default: all) " username
|
||||
read_pass
|
||||
fi
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user