The review of std.hash package

RivenTheMage riven-mage at id.ru
Wed Aug 15 20:02:58 PDT 2012


On Wednesday, 15 August 2012 at 19:38:34 UTC, José Armando
García Sancio wrote:

> Thats because it is a "password module" and nobody or a small
> percentage of the population uses CRC for password digest.

In turn, that's because CRC is not not a crytographic hash and
not suited for password hashing :)

> The basic point is that std.digest/std.hash (whatever people 
> decide) should probably just have generic digesting algorithm.

Generic digesting algorithm should probably go into std.algorithm.

It could be used like that:

------------
import std.algorithm;
import std.checksum;
import std.crypto.mdc;

ushort num = 1234;
auto hash1 = hash!("(a >>> 20) ^ (a >>> 12) ^ (a >>> 7) ^ (a >>>
4) ^ a")(str); // indexing hash

string str = "abcd";
auto hash3 = hash!(CRC32)(str); // checksum
auto hash2 = hash!(MD5)(str); // crytographic hash
------------

CRC32 and MD5 are ranges and/or classes, derived from
HashAlgorithm interface.


More information about the Digitalmars-d mailing list