Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #32687

RE: How to generate account number?

From Andriy Kornatskyy <andriy.kornatskyy@live.com>
Subject RE: How to generate account number?
Date 2012-11-03 11:38 +0300
References <1gsdm9-r2c.ln1@crazy-horse.bildanet.com>
Newsgroups comp.lang.python
Message-ID <mailman.3234.1351931985.27098.python-list@python.org> (permalink)

Show all headers | View raw


>>> 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: GangGreene@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
 		 	   		  

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

How to generate account number? Andriy Kornatskyy <andriy.kornatskyy@live.com> - 2012-11-03 00:13 +0300
  Re: How to generate account number? GangGreene <GangGreene@example.com> - 2012-11-02 18:02 -0400
    RE: How to generate account number? Andriy Kornatskyy <andriy.kornatskyy@live.com> - 2012-11-03 11:38 +0300
      Re: How to generate account number? Roy Smith <roy@panix.com> - 2012-11-03 09:22 -0400
        Re: How to generate account number? Tim Chase <python.list@tim.thechases.com> - 2012-11-03 10:34 -0500
        RE: How to generate account number? Andriy Kornatskyy <andriy.kornatskyy@live.com> - 2012-11-03 19:18 +0300
        RE: How to generate account number? Andriy Kornatskyy <andriy.kornatskyy@live.com> - 2012-11-03 19:23 +0300
  Re: How to generate account number? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-11-02 22:39 +0000
    RE: How to generate account number? Andriy Kornatskyy <andriy.kornatskyy@live.com> - 2012-11-03 11:42 +0300

csiph-web