View source code
Display the source code in std/digest/md.d from which this
page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a
Bugzilla issue.
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.
Struct std.digest.md.MD5
Template API MD5 implementation.
See std
for differences between template and OOP API.
struct MD5
;
Methods
Name | Description |
---|---|
finish
()
|
Returns the finished MD5 hash. This also calls start to
reset the internal state.
|
put
(data)
|
Use this to feed the digest with data.
Also implements the 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
writeln(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);
writeln(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.
License
Copyright © 1999-2024 by the D Language Foundation | Page generated by ddox.