The review of std.hash package

Chris Cain clcain at uncg.edu
Wed Aug 8 10:47:49 PDT 2012


On Wednesday, 8 August 2012 at 17:33:01 UTC, 
travert at phare.normalesup.org (Christophe Travert) wrote:
> I think you misunderstood me (and it's probably my fault, since 
> I don't
> know much of hash functions), I was wanted to compare two kind 
> of
> concepts:
>
> 1/ message digest functions, like md5, or sha1, used on large 
> files,
> which is what is covered by this std.hash proposal.
> 2/ small hash function. Like what are use in an associative 
> array, and
> are called toHash when used a member function.
>
> And I didn't thought of:
> 3/ cryptographic hash functions

Actually, maybe I'm the one not doing a good job of explaining.

1 and 3 are the same things (what you're calling "message digest" 
functions are cryptographic hash functions). I'm saying that even 
though similar in name, cryptographic hash functions really can't 
(IMO, I suppose I should make clear) be put in the same place as 
normal hash functions because they barely have anything in 
common. You can't use on in the place of another nor are they 
really used in similar manners.

> My opinion was that in a module or package called hash, I 
> expect tools
> concerning #2.

I agree. I'd think similarly (I'd assume std.hash has something 
to do with hash tables or hash functions used for hash tables).


If I were looking to use a cryptographic hash function like SHA1 
or (eh) MD5, I'd look for std.crypto first, and probably pick 
std.digest if I saw that. As a last resort I'd look in std.hash 
and vomit profusely after seeing it grouped with the "times 33" 
hash.


More information about the Digitalmars-d mailing list