Skip to content
This repository was archived by the owner on Mar 7, 2019. It is now read-only.

Using digests

Ivan Zaera Avellon edited this page Feb 17, 2014 · 3 revisions

To use a digest you can use the following code:

    var digest = new Digest( "RIPEMD-160" );

    var plainText = inputPlainText();

    var digestValue = digest.process( plainText );

    outputDigestValue( digestValue );

In general, you construct the Digest with the factory constructor which receives the standard algorithm name. See Algorithm nomenclature for documentation on standard algorithm names.

To digest data you call process() which returns the hash of the digested data. Alternatively, if you want more performance, you can make successive calls to update() with the plain text buffer, the offset and the length to read. Finally, when you have exhausted all data, you call doFinal() with the output buffer and the offset to write to.

You can reset the digest to its initial state with the reset() method.

Clone this wiki locally