[erlang-questions] Warning: erlang:phash2 output

Paulo Sérgio Almeida psa@REDACTED
Thu May 7 00:38:42 CEST 2009


Martin Bjorklund wrote:

> Actually, phash2 uses a great hash function (by Robert Jenkins), if
> you know how to invoke it -- you need to call it with a binary to get
> this algorithm.

This is good news. It is a pity this precious knowledge is nowhere in 
the documentation. Anyway, there should be a warning somewhere, as 
looking at

erlang:phash2(Term [, Range]) -> Hash

one expects to be able to pass it any term without having to do 
something like

erlang:phash2(term_to_binary(Term))

to get good results, contrary to the crypto functions

sha(Data) -> Digest
md5(Data) -> Digest

where we must have

Data = iolist() | binary()

Thanks for the info,
psa



More information about the erlang-questions mailing list