Py | Secret Key


/ Published in: Python
Save to your folder(s)



Copy this code and paste it in your HTML
  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

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.