From 17a36aca59a189f405ae1391ae5e5bd07dd7327b Mon Sep 17 00:00:00 2001 From: shockrah Date: Thu, 12 Mar 2020 14:34:22 -0700 Subject: [PATCH] password generator using /dev/urandom --- password-gen.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 password-gen.sh diff --git a/password-gen.sh b/password-gen.sh new file mode 100755 index 0000000..7dc3a85 --- /dev/null +++ b/password-gen.sh @@ -0,0 +1,23 @@ +#!/bin/sh + + +alnum() { + cat /dev/urandom | tr -dc [:alnum:] | fold -w 32 | head -1 +} + +alnum_spec() { + cat /dev/urandom | tr -dc [:alnum:]'!@#$%^&*()-_=+' | fold -w 32 | head -1 +} + +_help() { + echo 'Flags: + a - alphanumeric set + s - alphanumeric + special characters' +} + +case $1 in + a) alnum;; + s) alnum_spec;; + *) _help;; +esac +