View source code
Display the source code in std/digest/package.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.

Class std.digest.WrapperDigest

Wraps a template API hash struct into a Digest interface. Modules providing digest implementations will usually provide an alias for this template (e.g. MD5Digest, SHA1Digest, ...).

class WrapperDigest(T)
  
if (isDigest!T);

Constructors

NameDescription
this () Initializes the digest.

Properties

NameTypeDescription
length[get] size_tThis is the length in bytes of the hash value which is returned by finish. It's also the required size of a buffer passed to finish.

Methods

NameDescription
finish (buf) The finish function returns the hash value. It takes an optional buffer to copy the data into. If a buffer is passed, it must have a length at least length bytes.
peek (buf) Works like finish but does not reset the internal state, so it's possible to continue putting data into this WrapperDigest after a call to peek.
put () Use this to feed the digest with data. Also implements the isOutputRange interface for ubyte and const(ubyte)[].
reset () Resets the internal state of the digest.
factory (classname) Create instance of class specified by the fully qualified name classname. The class must either have no constructors or have a default constructor.
opCmp (o) Compare with another Object obj.
opEquals (o) Test whether this is equal to o. The default implementation only compares by identity (using the is operator). Generally, overrides for opEquals should attempt to compare objects by their contents.
toHash () Compute hash function for Object.
toString () Convert Object to a human readable string.

Example

import std.digest.md;
//Simple example
auto hash = new WrapperDigest!MD5();
hash.put(cast(ubyte) 0);
auto result = hash.finish();

Example

//using a supplied buffer
import std.digest.md;
ubyte[16] buf;
auto hash = new WrapperDigest!MD5();
hash.put(cast(ubyte) 0);
auto result = hash.finish(buf[]);
//The result is now in result (and in buf). If you pass a buffer which is bigger than
//necessary, result will have the correct length, but buf will still have it's original
//length

Authors

Johannes Pfau

License

Boost License 1.0.