summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorShokara Kou <kou@13f0.net>2022-10-13 19:04:45 -0400
committerShokara Kou <kou@13f0.net>2022-10-13 19:04:45 -0400
commit3b937958ac383b05761c9a16bcf5cc9003cd6031 (patch)
treea8cfa131012f31800ec170679035879291684c04 /contrib
parent32341a174c86712cabb9243caf9e88f4d7feec50 (diff)
add generate function and contrib/random script
I sometimes forget to copy-paste the passwords and usernames I generate, so this should help with that. Uses the random string generator script I made before by default.
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/random22
1 files changed, 22 insertions, 0 deletions
diff --git a/contrib/random b/contrib/random
new file mode 100755
index 0000000..10ddda7
--- /dev/null
+++ b/contrib/random
@@ -0,0 +1,22 @@
1#!/bin/sh
2# Simple random string generator for passwords and usernames
3# $LEN initial declaration commented out for runtime LEN config
4
5LC_ALL=C
6#LEN=${LEN:-24}
7ALPHA="A-Za-z"
8NUM="0-9"
9SPECIAL='!"#$%&'\''()*+,-./:;<=>?@[\]^_`{|}~'
10
11random() {
12 </dev/urandom tr -dc "${ALPHA}${NUM}${SPECIAL}" | /bin/dd bs=1 count=${LEN:-32} 2>/dev/null ; echo
13}
14
15case $1 in
16 pass)
17 random ;;
18 user)
19 LEN=${LEN:-12} SPECIAL='' random ;;
20 *)
21 printf "Usage: $0 pass|user\nSet LEN environment variable for length" ;;
22esac