MD5

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

Members

Functions

finish
ubyte[16] finish()

* Returns the finished MD5 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 MD5 digest.

Examples

//Simple example, hashing a string using md5Of helper function
ubyte[16] hash = md5Of("abc");
//Let's get a hash string
assert(toHexString(hash) == "900150983CD24FB0D6963F7D28E17F72");
//Using the basic API
MD5 hash;
hash.start();
ubyte[1024] data;
//Initialize data here...
hash.put(data);
ubyte[16] result = hash.finish();
//Let's use the template features:
void doSomething(T)(ref T hash)
if (isDigest!T)
{
    hash.put(cast(ubyte) 0);
}
MD5 md5;
md5.start();
doSomething(md5);
assert(toHexString(md5.finish()) == "93B885ADFE0DA089CDF634904FD59F71");

Meta