Re: Generating a unique identifier



On Fri, 07 Sep 2007 08:47:58 -0700, Paul Rubin wrote:

Paul Rubin <http://phr.cx@xxxxxxxxxxxxxx> writes:
def unique_id():
return os.urandom(10).encode('hex')

Sorry, make that 32 or 40 instead of 10, if the number of id's is large,
to make birthday collisions unlikely.

I did a small empirical test, and with 16 million ids, I found no
collisions.

However, I did find that trying to dispose of a set of 16 million short
strings caused my Python session to lock up for twenty minutes until I
got fed up and killed the process. Should garbage-collecting 16 million
strings really take 20+ minutes?


If you don't want the id's to be that large, you can implement a Feistel
cipher using md5 or sha as the round function pretty straightforwardly,
then just feed successive integers through it. That also guarantees
uniqueness, at least within one run of the program. I have some sample
code around for that, let me know if you need it.

I'm not sure that I need it, but I would certainly be curious to see it.


Thanks,


--
Steven.
.



Relevant Pages

  • Re: [Full-Disclosure] RE: [ISN] DARPA pulls OpenBSD funding
    ... >> customer decided to get rid of american crypto software, ... IDEA, but also MD5. ... cipher is interesting, we are to move to AES, - belgian, made by these very ... for its various roles, so going around MD5 or SHA will be harder, SHA being ...
    (Full-Disclosure)
  • Re: eCryptfs Design Document
    ... the root IV is the first N bytes of that MD5 sum, ... eCryptfs, since eCryptfs only hashes secret values). ... allow the user to select the cipher and key length. ... Should this functionality be high desired / required, ...
    (Linux-Kernel)
  • Re: Kryptor for Linux released
    ... ARCS is a simple stream cipher. ... MD5 and MD5 is today considered to be pretty weak and to be ... This "cipher" is using as base a hashing method. ... Do you believe cryptographers with years of knowledge ...
    (Focus-Linux)
  • RE: where to download md5.py?
    ... md5 is a standard Python module. ... I don't have sha either, but my system administrators don't know a thing ...
    (comp.lang.python)
  • IPSec VPN NAT-T Multiple Clients to same Destination
    ... The ISA is connected directly to the Internet. ... If there are more than one client behind a NAT then ... MD5 ... SHA ...
    (microsoft.public.isa)