[Zope] Unique IDs
Frank Tegtmeyer
fte@lightwerk.com
10 Jun 2001 13:57:07 +0200
"Daniel Fairs" <daniel.fairs@spiderplant.net> writes:
> What's the best way to generate a secure unique ID in Zope? I've tried
> generating a random integer then md5'ing it, but trying to do an md5.new()
I am using an external Python method for that:
# Token.py
# generate a token for user accounts
# the token is built from a secret key and the users
# first and last name and his email address
# 2001-04-14 Frank Tegtmeyer
import sha, binascii
def GetToken(initstring):
s=sha.new()
s.update("put your secret string here")
s.update(initstring)
return binascii.b2a_base64(s.digest())[:16]
if __name__=='__main__':
print GetToken('abcdefg')
Regards, Frank