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 |
---|---|
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() throws java.security.NoSuchAlgorithmException
java.security.NoSuchAlgorithmException
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 convert