Pad to a fixed length
This commit is contained in:
parent
1c91882710
commit
974447ab6d
|
@ -71,6 +71,10 @@ function pass_show_help {
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function pad_string {
|
||||||
|
echo -n -e "$1" | sed -e :a -e 's/^.\{1,1024\}$/& /;ta'
|
||||||
|
}
|
||||||
|
|
||||||
while [[ $# > 1 ]]
|
while [[ $# > 1 ]]
|
||||||
do
|
do
|
||||||
key="$1"
|
key="$1"
|
||||||
|
@ -122,14 +126,15 @@ if [ ${#CURR_PASSWORD} -eq 0 ]; then
|
||||||
echo ""
|
echo ""
|
||||||
exit 4
|
exit 4
|
||||||
else
|
else
|
||||||
gpg -dq --passphrase "$MASTER_PASSWORD" ~/.passwords/$CURR_USERNAME/$CURR_APP
|
pass=$(gpg -dq --passphrase "$MASTER_PASSWORD" ~/.passwords/$CURR_USERNAME/$CURR_APP)
|
||||||
|
echo ${pass}
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
# store password
|
# store password
|
||||||
if [ ! -d ~/.passwords/$CURR_USERNAME ]; then
|
if [ ! -d ~/.passwords/$CURR_USERNAME ]; then
|
||||||
mkdir -p ~/.passwords/$CURR_USERNAME
|
mkdir -p ~/.passwords/$CURR_USERNAME
|
||||||
fi
|
fi
|
||||||
echo “$CURR_PASSWORD” | gpg -ca --cipher-algo AES256 --passphrase "$MASTER_PASSWORD" > ~/.passwords/$CURR_USERNAME/$CURR_APP
|
echo -n "$(pad_string '${CURR_PASSWORD}')" | gpg -ca --cipher-algo AES256 --passphrase "$MASTER_PASSWORD" > ~/.passwords/$CURR_USERNAME/$CURR_APP
|
||||||
if [ ! -f ~/.passwords/$CURR_USERNAME/$CURR_APP ]; then
|
if [ ! -f ~/.passwords/$CURR_USERNAME/$CURR_APP ]; then
|
||||||
exit 5
|
exit 5
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue