Posted By

mviera on 10/03/09


Tagged

password generator


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

abumap


Random password generator


 / Published in: Bash
 

  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  

You need to login to post a comment.