Message Digests

<crypt:digester id="digester" algorithm="SHA1" outputMode="HEX" provider="BC"/>


SHA1 is the default algorithm and can be omitted.


HEX is the default output mode and can be omitted, the other option being BASE64.

provider since 1.3.0

The provider attribute is optional.

Here is an example implementation.

import com.springcryptoutils.core.digest.Digester;

public class MyDigester {

    private Digester digester;

    public void myBusinessMethod() {
        String digest = digester.digest("eat me!");
        // OR, if you prefer obtaining the raw bytes, regardless of outputMode specified
        byte[] digestRawBytes = digester.digest("eat me!".getBytes("UTF-8"));