public class Checksum
extends java.lang.Object
Constructor and Description |
---|
Checksum()
Initializes a new Checksum generator using the default SHA-1 algorithm.
|
Checksum(java.lang.String algorithm)
Initializes a new Checksum generator using the specified algorithm.
|
Modifier and Type | Method and Description |
---|---|
java.security.MessageDigest |
getMessageDigest()
Retrieves the MessageDigest instance used by this Checksum generator.
|
byte[] |
hash(byte[] bytes)
Produce a checksum/hashsum of a given block of data.
|
java.lang.String |
hashToHexString(byte[] hash)
Convert a hash to a hexidecimal String.
|
public Checksum()
public Checksum(java.lang.String algorithm) throws java.security.NoSuchAlgorithmException
algorithm
- algorithm to use to generate checksums.java.security.NoSuchAlgorithmException
public byte[] hash(byte[] bytes)
bytes
- data bytes to checksum.public java.lang.String hashToHexString(byte[] hash)
hash
- the hash value to convertpublic java.security.MessageDigest getMessageDigest()