Friday, October 24, 2008

Programming in Python - Generating a random string

A quick, simple password generator.

Obviously there's no real crypto here. It is usefull, for example, regenerating and emailing a user password.

  1. import string
  2. from random import choice

  3. size=9
  4. pwd = ''.join ( [ choice (string.letters + string.digits ) for i in range ( size ) ]

  5. # Putting in practice the string module
  6. print pwd.lower

There's an application written in Python to generate random passwords for use wherever good (or bad) passwords are required. It is PyKey.

No comments: