diff options
| author | Shokara Kou <kou@13f0.net> | 2022-10-13 19:04:45 -0400 |
|---|---|---|
| committer | Shokara Kou <kou@13f0.net> | 2022-10-13 19:04:45 -0400 |
| commit | 3b937958ac383b05761c9a16bcf5cc9003cd6031 (patch) | |
| tree | a8cfa131012f31800ec170679035879291684c04 /contrib | |
| parent | 32341a174c86712cabb9243caf9e88f4d7feec50 (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-x | contrib/random | 22 |
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 | |||
| 5 | LC_ALL=C | ||
| 6 | #LEN=${LEN:-24} | ||
| 7 | ALPHA="A-Za-z" | ||
| 8 | NUM="0-9" | ||
| 9 | SPECIAL='!"#$%&'\''()*+,-./:;<=>?@[\]^_`{|}~' | ||
| 10 | |||
| 11 | random() { | ||
| 12 | </dev/urandom tr -dc "${ALPHA}${NUM}${SPECIAL}" | /bin/dd bs=1 count=${LEN:-32} 2>/dev/null ; echo | ||
| 13 | } | ||
| 14 | |||
| 15 | case $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" ;; | ||
| 22 | esac | ||
