Package org.cryptacular.bean
Interface HashBean<T>
- Type Parameters:
T- Type of output (e.g. byte[], string) produced by hash bean.
- All Known Implementing Classes:
BCryptHashBean,EncodingHashBean,SimpleHashBean
public interface HashBean<T>
Strategy interface to support beans that produce hash outputs in various formats, e.g. raw bytes, hex output, etc.
- Author:
- Middleware Services
-
Method Summary
-
Method Details
-
hash
Hashes the given data.- Parameters:
data- Data to hash. Callers should expect support for at least the following types:byte[],CharSequence,InputStream, andResource. Unless otherwise noted, character data is processed in theUTF-8character set; if another character set is desired, the caller should convert tobyte[]and provide the resulting bytes.- Returns:
- Digest output.
- Throws:
CryptoException- on hash computation errors.StreamException- on stream IO errors.
-
compare
Compares a known hash value with the hash of the given data.- Parameters:
hash- Known hash value.data- Data to hash.- Returns:
- True if the hashed data matches the given hash, false otherwise.
- Throws:
CryptoException- on hash computation errors.StreamException- on stream IO errors.
-