From: Nicolas Boisselier Date: Wed, 18 Apr 2018 02:26:55 +0000 (+0100) Subject: etc/profile.d/functions X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=da28ee4ccf8d8a99172c523efcb06bbce1bb4f62;p=nb.git etc/profile.d/functions --- diff --git a/etc/profile.d/functions b/etc/profile.d/functions index d91558e0..010535e4 100644 --- a/etc/profile.d/functions +++ b/etc/profile.d/functions @@ -833,10 +833,10 @@ http_head() { fi } -password_create() { - tr -cd '[:alnum:] #$,;.:*@[]()?+=_%-' < /dev/urandom | head -c${1:-30} - #tr -cd '[:alnum:]!@#$%^&*_+-,./?' < /dev/urandom | head -c${1:-30} - #tr -cd '!-~' < /dev/urandom | head -c${1:-30} +random_string() { + local len=${1:-30} + local chars=${2:-'[:alnum:] #$,;.:*@[]()?+=_%-'} + tr -cd "$chars" < /dev/urandom | head -c${1:-${len}} echo }