[erlang-questions] Generating readable unique IDs for use outside erlang

Evans, Matthew mevans@REDACTED
Thu Feb 10 15:47:15 CET 2011


A few ideas come to mind:

1) erlang:term_to_binary/1? (taking your tuple as input)

2) erlang:md5/1 (taking the result of term_to_binary/1 as an input, returning a binary as the result).

3) erlang:phash/2 (with some crazy large number to try to guarantee uniqueness).

4) erlang:crc32/1 (taking the result of term_to_binary/2 as input, this returns an int as the result).

Matt

-----Original Message-----
From: erlang-questions@REDACTED [mailto:erlang-questions@REDACTED] On Behalf Of Dave Challis
Sent: Thursday, February 10, 2011 9:35 AM
To: erlang-questions@REDACTED
Subject: [erlang-questions] Generating readable unique IDs for use outside erlang

Is there a good (and fast) way of generating a unique id for use outside 
Erlang?

The best method I can find for generating a unique id is to use:
{node(), now()}

Which generates something like:
{foo@REDACTED,{1297,347375,276224}}

This works great, and is what I use within erlang.

However, it looks a bit meaningless is likely to confuse users of the 
non-erlang application that uses it - is there a nice way to turn that 
into an integer, or series of integers instead?

E.g. turning the above into:
3473290872_1297_347375_276224
(or ideally a single integer)

would be fine, but I'm not sure how to get an integer from a term.

Chances are I'll be generating hundreds of thousands to several million 
of these, so I'm also a bit concerned about efficiency - turning the 
{node(), now()} tuple into a string would no doubt take up more memory 
(and some processing time).

Any suggestions on this?

-- 
Dave Challis
dsc@REDACTED

________________________________________________________________
erlang-questions (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED



More information about the erlang-questions mailing list