-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgreatpassword.sh
executable file
·49 lines (39 loc) · 1.52 KB
/
greatpassword.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/bash
# create secure, easy to type passwords
cd $(dirname $(realpath $0))
function securepassword () {
if [ x"$1" == x"" ]; then
nletters=8
else
nletters="$1"
fi
python2 <<EOF
from random import choice
letters = "0123456789ABCDEFGHJKLMNPQRSTUVWXabcdefghijkmnopqrstuvwx"
delimiters = ",.+-*/!"
pw = ""
for i in range($nletters):
if i%4 == 0 and i != 0 and i != $nletters:
pw += choice(delimiters)
pw += choice(letters)
print pw
EOF
}
TMPDIR=$(mktemp -d /run/user/1000/securepassword-XXXXX)
if [ x"${TMPDIR}" == x"" ]; then
echo cannot create TMPDIR >&2
exit 1
fi
for i in {1..10}; do securepassword "$1" >> ${TMPDIR}/pws.txt; done
for i in $(cat ${TMPDIR}/pws.txt); do
echo "$i" > ${TMPDIR}/pwtest.txt
Q=$(./check_neo.py --check=QWERTZ_LAYOUT -f ${TMPDIR}/pwtest.txt | grep x100 | cut -d " " -f 2)
N=$(./check_neo.py --check=NEO_LAYOUT -f ${TMPDIR}/pwtest.txt | grep x100 | cut -d " " -f 2)
D=$(./check_neo.py --check=DVORAK_LAYOUT -f ${TMPDIR}/pwtest.txt | grep x100 | cut -d " " -f 2)
C=$(./check_neo.py --check=CRY_LAYOUT -f ${TMPDIR}/pwtest.txt | grep x100 | cut -d " " -f 2)
S=$(guile -c "(import (ice-9 format))(format #t \"~15,2,,,'0f\" (* $Q $N $D $C))")
echo $S $Q $N $D $C "$i"
done > ${TMPDIR}/pws-checked-qwertz-neo-dvorak-cry.tmp
cat ${TMPDIR}/pws-checked-qwertz-neo-dvorak-cry.tmp | sort -V > ${TMPDIR}/pws-checked-qwertz-neo-dvorak-cry.txt
echo your passwords are in ${TMPDIR}/pws-checked-qwertz-neo-dvorak-cry.txt
echo when you are finished, delete ${TMPDIR} >&2