Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 7 Oct 2002 00:07:23 +0200 (CEST)
From:      Oliver Fromme <olli@secnetix.de>
To:        freebsd-questions@FreeBSD.ORG
Subject:   Re: /dev/urandom is randomly cool
Message-ID:  <200210062207.g96M7NgO056867@lurza.secnetix.de>
In-Reply-To: <20021006172402.M71117-100000@earl-grey.cloud9.net>

next in thread | previous in thread | raw e-mail | index | archive | help
Peter Leftwich <Hostmaster@video2video.com> wrote:
 > On Sun, 6 Oct 2002, Fernando Gleiser wrote:
 > > On Sun, 6 Oct 2002, Mikko Työläjärvi wrote:
 > > >  tr -cd a-zA-Z0-9 < /dev/urandom | dd bs=$len count=1 2>/dev/null
 > 
 > It didn't work.  My shell is tcsh so I tried:
 > tr -cd a-zA-Z0-9 < /dev/urandom | dd bs=8 count=1 >& /dev/null
 > And all I got was the next prompt.

Yep, csh and tcsh suck pretty much.  Not being able to
separately redirect stderr easily is one of the reasons.

In this particular case, you can use head instead of dd:

tr -cd a-zA-Z0-9 < /dev/urandom | head -c 8

If your intention is to generate passwords, then you should
also include special characters, not just letters and
digits.  I once wrote a small shell script to generate good
passwords:

http://www.secnetix.de/~olli/scripts/genpwd

After installing it somwhere in yout $PATH (for example in
/usr/local/bin) and making it executable, type "genpwd -h"
for usage information.  It also uses /dev/urandom, if it
exists, but it also works fine without -- you can easily
remove that part from the script (three lines) and it will
still work with sufficient randomness, without having to
touch your kernel's entropy pool.

BTW, the script can also be (ab)used for other things.
There are two examples in the usage message.

Regards
   Oliver

-- 
Oliver Fromme, secnetix GmbH & Co KG, Oettingenstr. 2, 80538 München
Any opinions expressed in this message may be personal to the author
and may not necessarily reflect the opinions of secnetix in any way.

"All that we see or seem is just a dream within a dream" (E. A. Poe)

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200210062207.g96M7NgO056867>