Posted By

alejandrombernardis on 05/13/11


Tagged

secret


Versions (?)

Py | Secret Key


 / Published in: Python
 

URL: http://www.alejandrob.com.ar/

  1. # ref: http://mylesbraithwaite.com/journal/2007/10/secret-key/
  2.  
  3. def secret_key(l=32):
  4. from string import letters, digits, punctuation
  5. from random import choice
  6. from datetime import datetime
  7.  
  8. d = datetime.strftime(datetime.now(), '%Y%m%d%H%M%S%f')
  9. h = '%s%s%s%s' % (letters, digits, punctuation, d)
  10. s = ''.join([choice(h) for i in range(l)])
  11.  
  12. return s

Report this snippet  

You need to login to post a comment.