[erlang-questions] erlang:phash2(make_ref(), 1 bsl 32)

Andy Gross andy@REDACTED
Thu May 8 14:13:06 CEST 2008


I use crypto:sha(term_to_binary({make_ref(), now()}), then hexify it  
with the mochihex module from mochiweb, e.g.

 >> mochihex:to_hex(crypto:sha(term_to_binary({make_ref(), now()}))).
"1477cfafb3ec026ab1c6c6ff0f0fb6c7ee001554"


- Andy



On May 8, 2008, at 7:02 AM, Per Melin wrote:

> 2008/5/8 Darren New <dnew@REDACTED>:
> I'm no expert, but my understanding is that make_ref() doesn't make a
> particularly unique reference.
>
>
> You're right. But for what I need in this particular case it's  
> perfect. It only has to be unique per node, and only a few million  
> times. I could even use a counter, but then I'd have to have a  
> process on each node just to own the counter.
>
> I'll use some combination of make_ref() and now() and it'll be fine.  
> I just wonder if it isn't a weakness in how phash2 works with refs?
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20080508/eb59b5e8/attachment.htm>


More information about the erlang-questions mailing list