Wednesday, December 10, 2008

quick random password generator

Need a random password in a hurry?
someguy@workstation:~> python
Python 2.5.2 (r252:60911, Jul 31 2008, 17:31:22) 
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import string
>>> from random import Random
>>> "".join(Random().sample(string.letters+string.digits, 8))
'GAZcEFIy'
>>> 
Update, here it is in a one-liner:
import string; from random import Random; "".join(Random().sample(string.letters+string.digits, 8))