|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.pfsw.security.crypto.HashMechanism
public class HashMechanism
Contains all information about a hashing algorithm.
Field Summary | |
---|---|
static HashMechanism |
MD5
|
static HashMechanism |
SALTED_MD5
|
static HashMechanism |
SALTED_SHA_1
|
static HashMechanism |
SALTED_SHA_2_256
|
static HashMechanism |
SALTED_SHA_2_384
|
static HashMechanism |
SALTED_SHA_2_512
|
static HashMechanism |
SHA_1
|
static HashMechanism |
SHA_2_256
|
static HashMechanism |
SHA_2_384
|
static HashMechanism |
SHA_2_512
|
Constructor Summary | |
---|---|
HashMechanism(java.lang.String hashMechanismName,
CheckedHashAlgorithm algorithm,
boolean isSalted)
Creates a new instance that represents a particular hashing mechanism. |
Method Summary | |
---|---|
static HashMechanism |
create(CheckedHashAlgorithm algorithm)
Creates a new instance that represents a particular unsalted hashing mechanism. |
static HashMechanism |
create(CheckedHashAlgorithm algorithm,
boolean isSalted)
Creates a new instance that represents a particular hashing mechanism. |
static HashMechanism |
create(java.lang.String hashMechanismName,
CheckedHashAlgorithm algorithm,
boolean isSalted)
Creates a new instance that represents a particular hashing mechanism. |
static java.lang.String |
createHashMechanismName(CheckedHashAlgorithm algorithm,
boolean isSalted)
Returns a name for the hashing mechanism that is defined by the given parameters. |
static java.lang.String |
createPrefix(java.lang.String hashMechanismName)
Returns a prefix for the provided hashing mechanism name. |
boolean |
equals(java.lang.Object obj)
|
static HashMechanism |
findHashMechanism(java.lang.String hashType)
Tries to find a known (i.e. registered constant) hash mechanism for the given type name. |
static HashMechanism |
findSaltedHashMechanism(java.lang.String hashType)
|
static HashMechanism |
findUnsaltedHashMechanism(java.lang.String hashType)
|
CheckedHashAlgorithm |
getAlgorithm()
|
java.lang.String |
getAlgorithmName()
|
int |
getBitLength()
|
int |
getByteLength()
|
protected java.lang.String |
getHashMechanismName()
|
java.lang.String |
getName()
Returns the name of this mechanism. |
java.lang.String |
getPrefix()
|
int |
hashCode()
|
boolean |
isSalted()
|
protected void |
setAlgorithm(CheckedHashAlgorithm newValue)
|
protected void |
setHashMechanismName(java.lang.String newValue)
|
protected void |
setIsSalted(boolean newValue)
|
protected void |
setPrefix(java.lang.String newValue)
|
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final HashMechanism MD5
public static final HashMechanism SHA_1
public static final HashMechanism SHA_2_256
public static final HashMechanism SHA_2_384
public static final HashMechanism SHA_2_512
public static final HashMechanism SALTED_MD5
public static final HashMechanism SALTED_SHA_1
public static final HashMechanism SALTED_SHA_2_256
public static final HashMechanism SALTED_SHA_2_384
public static final HashMechanism SALTED_SHA_2_512
Constructor Detail |
---|
public HashMechanism(java.lang.String hashMechanismName, CheckedHashAlgorithm algorithm, boolean isSalted)
hashMechanismName
- The name of the mechanism to be used in the prefix.algorithm
- The underlying hashing algorithm.isSalted
- Defines whether or not the mechanism is salted.Method Detail |
---|
public static java.lang.String createPrefix(java.lang.String hashMechanismName)
hashMechanismName
- The name to be used in the prefix (must not be null).public static java.lang.String createHashMechanismName(CheckedHashAlgorithm algorithm, boolean isSalted)
Example: algorithm is "SHA-256" and isSalted = true. That returns "SSHA256".
algorithm
- Defines the underlying hashing algorithm.isSalted
- Defines whether or not the mechanism is salted.public static HashMechanism create(CheckedHashAlgorithm algorithm)
algorithm
- The underlying hashing algorithm.public static HashMechanism create(CheckedHashAlgorithm algorithm, boolean isSalted)
algorithm
- The underlying hashing algorithm.isSalted
- Defines whether or not the mechanism is salted.public static HashMechanism create(java.lang.String hashMechanismName, CheckedHashAlgorithm algorithm, boolean isSalted)
hashMechanismName
- The name of the mechanism to be used in the prefix.algorithm
- The underlying hashing algorithm.isSalted
- Defines whether or not the mechanism is salted.public static HashMechanism findUnsaltedHashMechanism(java.lang.String hashType)
public static HashMechanism findSaltedHashMechanism(java.lang.String hashType)
public static HashMechanism findHashMechanism(java.lang.String hashType)
hashType
- The name of an hashing algorithm ("SHA-1") or the prefix (e.g. "{SSHA384}").
public java.lang.String getName()
public CheckedHashAlgorithm getAlgorithm()
public int getByteLength()
public java.lang.String getPrefix()
public boolean isSalted()
public java.lang.String getAlgorithmName()
public int getBitLength()
public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
protected java.lang.String getHashMechanismName()
protected void setAlgorithm(CheckedHashAlgorithm newValue)
protected void setHashMechanismName(java.lang.String newValue)
protected void setPrefix(java.lang.String newValue)
protected void setIsSalted(boolean newValue)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |