-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpassgen
More file actions
executable file
·64 lines (56 loc) · 1.81 KB
/
passgen
File metadata and controls
executable file
·64 lines (56 loc) · 1.81 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/sh
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Copyright 2021 Jeremy Brubaker <jbru362@gmail.com>
#
# abstract: generate a password as in XKCD #936
# Process options {
print_help() (
cat <<EOF
Usage: $0 [OPTION]
Generate an xkcd-936 inspired passphrase
-f path to wordlist (default: \$HOME/share/dict/password_words)
-n number of words to generate (default: 4)
-d word separator (default: none)
-h display this help
-v display version
EOF
) >&2
print_version() (
cat <<EOF
$0 1.0
Copyright (C) 2021 Jeremy Brubaker
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Jeremy Brubaker
EOF
) >&2
wordlist="$HOME/share/dict/password_words"
numwords=4
separator=''
while getopts "f:n:d:hv" opt; do
case $opt in
f) wordlist="$OPTARG" ;;
n) numwords="$OPTARG";;
d) separator="$OPTARG";;
h) print_help; exit ;;
v) print_version; exit ;;
*) print_help; exit ;;
esac
done
# }
awk 'length <= 5 && length >=3' "$wordlist" \
| shuf -n"$numwords" | paste -sd "$separator"