Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
local clone.
Page wiki
View or edit the community-maintained wiki page associated with this page.
std.digest.ripemd
Category | Functions |
---|---|
Template API | RIPEMD160 |
OOP API | RIPEMD160Digest |
Helpers | ripemd160Of |
Boost License 1.0 CTFE:
Digests do not work in CTFE Authors:
Kai Nacke
The algorithm was designed by Hans Dobbertin, Antoon Bosselaers, and Bart Preneel.
The D implementation is a direct translation of the ANSI C implementation by Antoon Bosselaers. References:
Source:
std/digest/ripemd.d
- struct RIPEMD160;
- Template API RIPEMD160 implementation.
See std.digest.digest for differences between template and OOP API.
Examples:
//Simple example, hashing a string using ripemd160Of helper function ubyte[20] hash = ripemd160Of("abc"); //Let's get a hash string assert(toHexString(hash) == "8EB208F7E05D987A9B044A8E98C6B087F15A0BFC");
Examples://Using the basic API RIPEMD160 hash; hash.start(); ubyte[1024] data; //Initialize data here... hash.put(data); ubyte[20] result = hash.finish();
Examples://Let's use the template features: void doSomething(T)(ref T hash) if(isDigest!T) { hash.put(cast(ubyte)0); } RIPEMD160 md; md.start(); doSomething(md); assert(toHexString(md.finish()) == "C81B94933420221A7AC004A90242D8B1D3E5070D");
Examples://Simple example RIPEMD160 hash; hash.start(); hash.put(cast(ubyte)0); ubyte[20] result = hash.finish(); assert(toHexString(result) == "C81B94933420221A7AC004A90242D8B1D3E5070D");
- auto ripemd160Of(T...)(T data);
- This is a convenience alias for std.digest.digest.digest using the
RIPEMD160 implementation.
Examples:
ubyte[20] hash = ripemd160Of("abc"); assert(hash == digest!RIPEMD160("abc"));
- alias RIPEMD160Digest = std.digest.digest.WrapperDigest!(RIPEMD160).WrapperDigest;
- OOP API RIPEMD160 implementation.
See std.digest.digest for differences between template and OOP API.
This is an alias for std.digest.digest.WrapperDigest!RIPEMD160, see
std.digest.digest.WrapperDigest for more information.
Examples:
//Simple example, hashing a string using Digest.digest helper function auto md = new RIPEMD160Digest(); ubyte[] hash = md.digest("abc"); //Let's get a hash string assert(toHexString(hash) == "8EB208F7E05D987A9B044A8E98C6B087F15A0BFC");
Examples://Let's use the OOP features: void test(Digest dig) { dig.put(cast(ubyte)0); } auto md = new RIPEMD160Digest(); test(md); //Let's use a custom buffer: ubyte[20] buf; ubyte[] result = md.finish(buf[]); assert(toHexString(result) == "C81B94933420221A7AC004A90242D8B1D3E5070D");