]> git.nbdom.net Git - nb.git/commitdiff
password_create
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Fri, 16 Dec 2016 16:03:02 +0000 (16:03 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Fri, 16 Dec 2016 16:03:02 +0000 (16:03 +0000)
etc/profile.d/functions

index b42bb8e423e9fa65997cb6f310a790f513950011..8252cc687a275be2879dcf6e2284dc1f35a706c0 100644 (file)
@@ -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"
+}