Package com.identity4j.util.crypt.impl
Class MessageDigestStringEncoder
- java.lang.Object
-
- com.identity4j.util.crypt.impl.AbstractEncoder
-
- com.identity4j.util.crypt.impl.CompoundEncoder
-
- com.identity4j.util.crypt.impl.MessageDigestStringEncoder
-
- All Implemented Interfaces:
Encoder
- Direct Known Subclasses:
MD5StringEncoder,SHAStringEncoder
public class MessageDigestStringEncoder extends CompoundEncoder
-
-
Constructor Summary
Constructors Constructor Description MessageDigestStringEncoder(String id, String encryptionEncoderId, String hashAlgorithm)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]encode(byte[] toEncode, byte[] salt, byte[] passphrase, String charset)Encode a stringbooleanisOfType(byte[] encodedBytes, String charset)Determine if this encoder may have been used to create the provided encoded bytes.booleanmatch(byte[] encodedData, byte[] unencodedData, byte[] passphrase, String charset)Check if the provide un-encoded data would match the encoded data if it was encoded.-
Methods inherited from class com.identity4j.util.crypt.impl.CompoundEncoder
addEncoder, decode
-
Methods inherited from class com.identity4j.util.crypt.impl.AbstractEncoder
getId, randomBytes
-
-
-
-
Method Detail
-
encode
public byte[] encode(byte[] toEncode, byte[] salt, byte[] passphrase, String charset) throws EncoderExceptionDescription copied from interface:EncoderEncode a string- Specified by:
encodein interfaceEncoder- Overrides:
encodein classCompoundEncoder- Parameters:
toEncode- data to encodesalt- salt if supportedpassphrase- passphrase if supportedcharset- character set- Returns:
- encoded bytes
- Throws:
EncoderException- if encoding fails
-
match
public boolean match(byte[] encodedData, byte[] unencodedData, byte[] passphrase, String charset)Description copied from interface:EncoderCheck if the provide un-encoded data would match the encoded data if it was encoded.- Specified by:
matchin interfaceEncoder- Overrides:
matchin classCompoundEncoder- Parameters:
encodedData- encoded dataunencodedData- un-encoded datapassphrase- passphrase if supportedcharset- character set- Returns:
- matches
-
isOfType
public boolean isOfType(byte[] encodedBytes, String charset)Description copied from interface:EncoderDetermine if this encoder may have been used to create the provided encoded bytes. This method should only be used if it is very likely to be the right encoder.- Specified by:
isOfTypein interfaceEncoder- Overrides:
isOfTypein classCompoundEncoder- Parameters:
encodedBytes- encoded bytescharset- character set- Returns:
- this almost certainly was encoded with a similar encoder
-
-