Random password generator


/ Published in: Bash
Save to your folder(s)



Copy this code and paste it in your HTML
  1. #!/bin/bash
  2. w="$1"
  3.  
  4. [[ -n "$w" ]] || w=12
  5. if [[ $w -lt 8 ]]; then
  6. echo "A password of length $w would be too weak."
  7. exit 1
  8. fi
  9. passwd=$( cat /dev/urandom |tr -dc "a-zA-Z0-9_\?\$\#\." |fold -w $w |head -1 )
  10. echo "${passwd}"

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.