|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Objectorg.jasypt.util.digest.Digester
public final class Digester
Utility class for creating digests without using a salt or iterating
the hash function. This means that digests created by this class will
be compatible (and equivalent) to the ones which could be created by
the user by directly using a MessageDigest
object.
This class can be thought of as convenience wrapper for
MessageDigest
, adding thread-safety and
a more javabean-like interface to it. These two features enable a more
adequate use from an IoC container like Spring.
This class internally holds a StandardByteDigester
configured this way:
This class is thread-safe
Field Summary | |
---|---|
static String |
DEFAULT_ALGORITHM
MD5 will be the default algorithm to be used if none is specified. |
Constructor Summary | |
---|---|
Digester()
Creates a new instance of Digester. |
|
Digester(String algorithm)
Creates a new instance of Digester, specifying the algorithm to be used. |
|
Digester(String algorithm,
Provider provider)
Creates a new instance of Digester, specifying the algorithm to be used. |
|
Digester(String algorithm,
String providerName)
Creates a new instance of Digester, specifying the algorithm to be used. |
Method Summary | |
---|---|
byte[] |
digest(byte[] binary)
Creates a digest. |
void |
setAlgorithm(String algorithm)
Sets the algorithm to be used for digesting, like MD5 or SHA-1. |
void |
setProvider(Provider provider)
Sets the security provider to be asked for the digest algorithm. |
void |
setProviderName(String providerName)
Sets the name of the security provider to be asked for the digest algorithm. |
Methods inherited from class Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String DEFAULT_ALGORITHM
Constructor Detail |
---|
public Digester()
setAlgorithm(String)
.
public Digester(String algorithm)
Creates a new instance of Digester, specifying the algorithm to be used.
public Digester(String algorithm, String providerName)
Creates a new instance of Digester, specifying the algorithm to be used.
public Digester(String algorithm, Provider provider)
Creates a new instance of Digester, specifying the algorithm to be used.
Method Detail |
---|
public void setAlgorithm(String algorithm)
Sets the algorithm to be used for digesting, like MD5 or SHA-1.
This algorithm has to be supported by your security infrastructure, and it should be allowed as an algorithm for creating java.security.MessageDigest instances.
If you are specifying a security provider with setProvider(Provider)
or
setProviderName(String)
, this algorithm should be
supported by your specified provider.
If you are not specifying a provider, you will be able to use those algorithms provided by the default security provider of your JVM vendor. For valid names in the Sun JVM, see Java Cryptography Architecture API Specification & Reference.
algorithm
- the name of the algorithm to be used.
AlreadyInitializedException
- if it has already been initialized,
this is, if digest(byte[])
has been called at least
once.public void setProviderName(String providerName)
Sets the name of the security provider to be asked for the digest algorithm. This security provider has to be registered beforehand at the JVM security framework.
The provider can also be set with the setProvider(Provider)
method, in which case it will not be necessary neither registering
the provider beforehand,
nor calling this setProviderName(String)
method to specify
a provider name.
Note that a call to setProvider(Provider)
overrides any value
set by this method.
If no provider name / provider is explicitly set, the default JVM provider will be used.
providerName
- the name of the security provider to be asked
for the digest algorithm.
AlreadyInitializedException
- if it has already been initialized,
this is, if digest(byte[])
has been called at least
once.public void setProvider(Provider provider)
Sets the security provider to be asked for the digest algorithm. The provider does not have to be registered at the security infrastructure beforehand, and its being used here will not result in it being registered.
If this method is called, calling setProviderName(String)
becomes unnecessary.
If no provider name / provider is explicitly set, the default JVM provider will be used.
provider
- the provider to be asked for the chosen algorithm
AlreadyInitializedException
- if it has already been initialized,
this is, if digest(byte[])
has been called at least
once.public byte[] digest(byte[] binary)
binary
- the byte array to be digested.
StandardByteDigester.digest(byte[])
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |