Random Password Generation in a Perl One-Liner
published on Wed, 09/16/2009 - 11:43
Say you need a quick random 8 character alpha-numeric password. In sh, there isn't a $RANDOM variable and tr can give different results on different OS's. More than likely you have perl available - use it!
perl -le 'print map { (a..z,A..Z,0..9)[rand 62] } 0..pop' 8
Thanks to Chris Angell's Perl One-Liner page for this one. Do you have a better cross-platform way of doing it? Let me know!
Comments
random passwords
$ openssl rand 6 -base64
VcT0eiM3
This is quick-and-dirty. Using -base64 to get a printable 8 character output means you're only using 6 bytes of random data, but it works anywhere you've got OpenSSL.
Hi. I like your blog. well
Hi. I like your blog. well done!
Add new comment