The review of std.hash package
Martin Nowak
dawg at dawgfoto.de
Wed Aug 8 05:13:06 PDT 2012
> It should accept an input range. But using an Output Range confuses me.
> A hash function is a reduce algorithm - it accepts a sequence of input
> values, and produces a single value. You should be able to write code
> like:
>
> ubyte[] data;
> ...
> auto crc = data.crc32();
>
> For example, the hash example given is:
>
> foreach (buffer; file.byChunk(4096 * 1024))
> hash.put(buffer);
> auto result = hash.finish();
>
> Instead it should be something like:
>
> auto result = file.byChunk(4096 * 1025).joiner.hash();
>
I think sha1Of/digest!SHA1 should do this.
It's also important to have a stateful hash implementation that can be
updated incrementally, e.g. from a callback.
More information about the Digitalmars-d
mailing list