Class MessageDigester
java.lang.Object
org.deltava.crypt.MessageDigester
A class to generate MD5/SHA message digests.
- Since:
- 1.0
- Version:
- 11.1
- Author:
- Luke
- 
Constructor SummaryConstructorsConstructorDescriptionMessageDigester(String algorithm) Create a new Message Digester with a specified algorithm.MessageDigester(String algorithm, int bufSize) Create a new Message Digester with a specified algorithm and input buffer size.
- 
Method SummaryModifier and TypeMethodDescriptionstatic Stringconvert(byte[] hash) Converts a message digest into a hexadecimal String.byte[]digest(byte[] data) Returns the message digest value for a given amount of data.byte[]digest(InputStream is) Returns the message digest value for the data within a given stream.final StringReturn the Message Digest algorithm in use.static byte[]Converts a hexadecimal String into a byte array.voidreset()Resets the Message Digester.void"Salts" the message digest by processing a string before the actual data.final voidsetBufferSize(int size) Updates the buffer size.
- 
Constructor Details- 
MessageDigesterCreate a new Message Digester with a specified algorithm.- Parameters:
- algorithm- the algorithm to use; must be supported by the JVM
- Throws:
- CryptoException
 
- 
MessageDigesterCreate a new Message Digester with a specified algorithm and input buffer size.- Parameters:
- algorithm- the algorithm to use; must be supported by the JVM
- bufSize- the buffer Size in bytes.
- See Also:
 
 
- 
- 
Method Details- 
salt"Salts" the message digest by processing a string before the actual data. This is used to protect (somewhat) against reverse engineering the hash through brute force.- Parameters:
- saltValue- the salt string
- Throws:
- NullPointerException- if saltValue is null
 
- 
getAlgorithmReturn the Message Digest algorithm in use.- Returns:
- the algorithm name
 
- 
setBufferSizepublic final void setBufferSize(int size) Updates the buffer size.- Parameters:
- size- the new buffer size in bytes. Must be > 64
 
- 
digestpublic byte[] digest(byte[] data) Returns the message digest value for a given amount of data.- Parameters:
- data- the data to digest
- Returns:
- the message digest
 
- 
digestReturns the message digest value for the data within a given stream.- Parameters:
- is- the stream containing the data
- Returns:
- the message digest
- Throws:
- IOException- if an error occurs reading the data
 
- 
resetpublic void reset()Resets the Message Digester.
- 
convertConverts a message digest into a hexadecimal String.- Parameters:
- hash- the message digest
- Returns:
- the hexadecimal representation of the message digest
 
- 
parseConverts a hexadecimal String into a byte array.- Parameters:
- hash- the hexadecimal message digest
- Returns:
- the message digest
 
 
-