-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgen-pass
More file actions
executable file
·43 lines (41 loc) · 1.28 KB
/
Copy pathgen-pass
File metadata and controls
executable file
·43 lines (41 loc) · 1.28 KB
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
#!/bin/bash
# pass-gen - Secure password generator
LEN="${1:-16}"
TYPE="${2:-mix}"
case "$TYPE" in
simple|1)
tr -dc 'a-z' </dev/urandom | head -c "$LEN"
;;
mix|2)
tr -dc 'a-zA-Z' </dev/urandom | head -c "$LEN"
;;
num|3)
tr -dc 'a-z0-9' </dev/urandom | head -c "$LEN"
;;
strong|4|mix)
tr -dc 'a-zA-Z0-9!@#$%^&*' </dev/urandom | head -c "$LEN"
;;
ultra|5)
tr -dc 'a-zA-Z0-9!@#$%^&*()_+-=[]{}|;:,.<>?' </dev/urandom | head -c "$LEN"
;;
passphrase|6)
WORDS=(apple banana cherry date eagle falcon grape harvest island jungle kernel lemon mango)
for i in $(seq 1 "$LEN"); do echo -n "${WORDS[$((RANDOM % ${#WORDS[@]}))]}"; [ $i -lt "$LEN" ] && echo -n "-"; done
echo
;;
xkcd)
echo "CorrectHorseBatteryStaple" | head -c "$LEN"
;;
*)
echo "pass-gen v1.0.0 - Password Generator"
echo "Usage: pass-gen [length] [type]"
echo ""
echo "Types:"
echo " 1 simple Lowercase only"
echo " 2 mix Letters only"
echo " 3 num Lower + numbers"
echo " 4 strong Letters + symbols (default)"
echo " 5 ultra All characters"
echo " 6 passphrase Word-based"
;;
esac