A simple function that will generate a secure and unique session key.
1 2 3 4 5 6 | def generate_key(self, uid):
import md5, os, base64, random
m = md5.new()
m.update(os.urandom(random.randint(15,25)))
m.update(uid)
return base64.standard_b64encode(m.digest())
|
I'd love some comment on this. I think it does the job well but would like to know if there is any improvement to be made.
What's wrong with:
Sorry: