public class MessageDigestHasher extends Object implements Hasher
Hasher implementation that uses a MessageDigest to create the
hash.| Constructor and Description |
|---|
MessageDigestHasher(MessageDigest messageDigest)
Creates a new message digest hasher.
|
| Modifier and Type | Method and Description |
|---|---|
static Hasher |
getSHA1Hasher()
Returns a hasher using the SHA-1 algorithm.
|
static Hasher |
getSHA256Hasher()
Returns a hasher using the SHA-256 algorithm.
|
static Hasher |
getSHA512Hasher()
Returns a hasher using the SHA-512 algorithm.
|
byte[] |
hash(byte[] data)
Hashes the given data.
|
byte[] |
hash(InputStream inputStream)
Hashes the data from the given input stream.
|
public MessageDigestHasher(MessageDigest messageDigest)
messageDigest - The message digestpublic byte[] hash(byte[] data)
public byte[] hash(InputStream inputStream) throws IOException
InputStream.read() returns -1, or throws an
exception.hash in interface HasherinputStream - The input stream to read fromIOException - if an I/O error occurspublic static Hasher getSHA1Hasher()
public static Hasher getSHA256Hasher()
public static Hasher getSHA512Hasher()
Copyright © 2026. All rights reserved.