10-04-04 11:02 PM
FreewareTown.com <Spam2@sharewareisland.com> wrote:
> Free Random Password Generator
> http://www.sharewareisland.com/randompasswords.aspx
Here's a simple one:
#!/bin/bash
## JimD: Sun Oct 3 18:12:36 PDT 2004
## Generate a reasonable password of the form: foo@bar where
## foo is some short word (less than six letters long), @ is some
## bit of punctuation, and bar is some other word (of any length)
WORDFILE="${1:-/usr/share/dict/words}"
PUNCT='!"#$%&()+,-./:;<=>@[\\]^_`{|}~'"'"
PUNCTLEN="${#PUNCT}"
set -- $( echo $PUNCT | sed 's/\(.\)/\1 /g' )
shift $(( $RANDOM % $PUNCTLEN + 1 ))
WORDLEN=$( wc -l $WORDFILE | { read x y; echo $x;} )
PW=$( sed -n "$(( $RANDOM % $WORDLEN + 1))p" $WORDFILE )$1
PW=$PW$( sed -n "$(( $RANDOM % $WORDLEN + 1))p" $WORDFILE )
echo "$PW"
I wouldn't put it in any programming contests, it's only tested
under bash and not terribly elegant. With a little extra
effort I could remove the dependencies on wc and sed, so it would use
nothing but shell built-ins (for almost all modern Bourne shells).
Besides it will only generate a few hundred billion passwords with
my paltry little 100,000 word list.
--
Jim Dennis,
Starshine: Signed, Sealed, Delivered
[ Post a follow-up to this message ]
|