>>> from hashlib import sha1 >>> sha1('GangGreene-20120203-1012').hexdigest() 'ef764a2fe44532008dc9a99c391c70cd85ec9d82'
It is too long and not verifiable. >>> from uuid import uuid4 >>> uuid4() UUID('2c14484b-5a0c-4f4b-b7bc-8187548b4888') Pretty much the same what you suggest but simpler and shorter. Not quite elegant for humans. Here are examples per this post: http://mindref.blogspot.com/2012/11/generate-account-number.html >>> account_number(1) 'Z05738521581' >>> account_number(2) 'Z17888279480' >>> account_number(3) 'Z07395350007' Short, human readable and satisfy original requirements. Andriy ---------------------------------------- > From: ganggre...@example.com > Subject: Re: How to generate account number? > Date: Fri, 2 Nov 2012 18:02:09 -0400 > To: python-list@python.org > > On Sat, 03 Nov 2012 00:13:19 +0300, Andriy Kornatskyy wrote: > >> Requirements for `account number` generator: >> >> 1. Issue pseudo random consistent number (must be unique for dozen >> millions of records) >> 2. Easy check validity (without a need to make a database call) >> >> Interested? Read more here: >> >> http://mindref.blogspot.com/2012/11/generate-account-number.html >> >> Comments or suggestions are welcome. >> >> Thanks. >> >> Andriy Kornatskyy > > generate sha1sum on the ((key database record(s))+date+timeofday) > Should be unique for billions/trillions of records. > -- > http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list