View source code
Display the source code in std/digest/md.d from which this page was generated on
github.
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.
Struct std.digest.md.MD5
Template API MD5 implementation.
See for differences between template and OOP API.
std.digest.digest
Methods
| Name | Description |
|---|---|
finish
|
Returns the finished MD5 hash. This also calls start to
reset the internal state.
|
put
|
Use this to feed the digest with data.
Also implements the std.range.primitives.isOutputRange
interface for ubyte and const(ubyte)[].
|
start
|
Used to (re)initialize the MD5 digest.
|
Example
//Simple example, hashing a string using md5Of helper function ubyte[16] hash = md5Of("abc"); //Let's get a hash string assert(toHexString(hash) == "900150983CD24FB0D6963F7D28E17F72");
Example
//Using the basic API MD5 hash; hash.start(); ubyte[1024] data; //Initialize data here... hash.put(data); ubyte[16] result = hash.finish();
Example
//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");
Authors
Piotr Szturmaj, Kai Nacke, Johannes Pfau
The routines and algorithms are derived from the RSA Data Security, Inc. MD5 Message-Digest Algorithm.