RIPEMD160

Template API RIPEMD160 implementation. See std.digest for differences between template and OOP API.

Members

Functions

finish
ubyte[20] finish()

Returns the finished RIPEMD160 hash. This also calls start to reset the internal state.

put
void put(const(ubyte)[] data)

Use this to feed the digest with data. Also implements the std.range.primitives.isOutputRange interface for ubyte and const(ubyte)[].

start
void start()

Used to (re)initialize the RIPEMD160 digest.

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");
//Using the basic API
RIPEMD160 hash;
hash.start();
ubyte[1024] data;
//Initialize data here...
hash.put(data);
ubyte[20] result = hash.finish();
//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");
//Simple example
RIPEMD160 hash;
hash.start();
hash.put(cast(ubyte) 0);
ubyte[20] result = hash.finish();
assert(toHexString(result) == "C81B94933420221A7AC004A90242D8B1D3E5070D");

Meta