tango.io.stream.Digester

License:

BSD style: see license.txt

Version:

Initial release: Oct 2007

Author:

Kris
class DigestInput : InputFilter, InputFilter.Mutator
Inject a digest filter into an input stream, updating the digest as information flows through it.
this(InputStream stream, Digest digest)
Accepts any input stream, and any digest derivation.
size_t read(void[] dst) [override, final]
Read from conduit into a target array. The provided dst will be populated with content from the conduit.
Returns the number of bytes read, which may be less than requested in dst (or IOStream.Eof for end-of-flow.)
DigestInput slurp(void[] dst = null) [final]
Slurp remaining stream content and return this.
Digest digest() [final]
Return the Digest instance we were created with. Use this to access the resultant binary or hex digest value.
class DigestOutput : OutputFilter, InputFilter.Mutator
Inject a digest filter into an output stream, updating the digest as information flows through it. Here's an example where we calculate an MD5 digest as a side-effect of copying a file:
1
2
3
4
auto output = new DigestOutput(new FileOutput("output"), new Md5);
output.copy (new FileInput("input"));

Stdout.formatln ("hex digest: {}", output.digest.hexDigest);
this(OutputStream stream, Digest digest)
Accepts any output stream, and any digest derivation.
size_t write(const(void)[] src) [override, final]
Write to conduit from a source array. The provided src content will be written to the conduit.
Returns the number of bytes written from src, which may be less than the quantity provided.
Digest digest() [final]
Return the Digest instance we were created with. Use this to access the resultant binary or hex digest value.