From ae667450dc08bffe31710b55932e853e2ef77b54 Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Fri, 16 Dec 2016 16:03:02 +0000 Subject: [PATCH] password_create --- etc/profile.d/functions | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/etc/profile.d/functions b/etc/profile.d/functions index b42bb8e4..8252cc68 100644 --- a/etc/profile.d/functions +++ b/etc/profile.d/functions @@ -776,8 +776,24 @@ http_head() { echo "Can't find web client" 1>&2 fi } -alias Head=http_head -( -unset -f get -unset -f head -) 2> /dev/null | true + +password_create() { + declare length=12 encrypt=0 + while [ $# -gt 0 ]; do + + case "$1" in + + -*help|-h) echo "Usage: $FUNCNAME [LENGTH default:12] -encrypt"; return ;; + + -*encrypt) encrypt=1 ;; + + *) length=$1 ;; + + esac + shift + + done + declare password=`apg -m $length -x $length -a 0 -M L | head -1` + [ "$encrypt" == "1" ] && password="$password "`echo "$password" | makepasswd --clearfrom=- --crypt-md5 | sed 's/^.*\(\$.*\)$/\1/'` + echo "$password" +} -- 2.47.3