The review of std.hash package
David
d at dav1d.de
Tue Aug 7 11:07:07 PDT 2012
Is the API already set in stone?
Using .start and .finish, feels like the use of OpenSSL. Why not making
a Hash object not "restartable" (since e.g. MD5.start() sets `this` just
to MD5.init) and making finish private and implementing a digest and
hexdigest property which calls finish and returns an ubyte[] array (or
string for hexdigest), this would also eliminate the need of the
`digest` wrapper (e.g. you can mixin these properties with template
mixins, so no code duplication)
Also I am not sure if we want to use `hash.put` instead of `hash.update`
(which is used by python and openssl). But that's just a minor point
(e.g. perl uses .add)
Furthermore, I don't like the `sha1Of` and `md5Of` etc. functions, why
not having a static method? e.g. MD5.hexdigest("input"), which returns
the hexdigest and not a MD5 object.
One more thing, `.reset` does the same as `start`? If so, why do both
exist? (I also find the examples quite confusing, why do you want to
reset the hash onject? I would documentate the function but wouldn't use
it in the examples)
Well, that's it from my side :)
More information about the Digitalmars-d
mailing list