public class PasswordHash
extends java.lang.Object
PasswordHash(String, byte[], byte[]) to package and manipulate
secrets that have already been hashed, and PasswordHash(String) for
plaintext secrets. Compare a plaintext candidate to a hashed secret with
matches(String).| Constructor and Description |
|---|
PasswordHash(java.lang.String password)
Construct a hash structure from a cleartext password using the configured
digest algorithm.
|
PasswordHash(java.lang.String algorithm,
byte[] salt,
byte[] hash)
Construct a hash structure from existing data, just for passing around.
|
PasswordHash(java.lang.String algorithm,
java.lang.String salt,
java.lang.String hash)
Convenience: like
PasswordHash(String, byte[], byte[]) but with
hexadecimal-encoded Strings. |
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getAlgorithm()
Get the value of algorithm
|
static java.lang.String |
getDefaultAlgorithm()
The digest algorithm used if none is configured.
|
byte[] |
getHash()
Get the hash.
|
java.lang.String |
getHashString()
Get the hash, as a String.
|
byte[] |
getSalt()
Get the salt.
|
java.lang.String |
getSaltString()
Get the salt, as a String.
|
boolean |
matches(java.lang.String secret)
Is this the string whose hash I hold?
|
public PasswordHash(java.lang.String algorithm,
byte[] salt,
byte[] hash)
algorithm - the digest algorithm used in producing hash.
If empty, set to null. Other methods will treat this as unsalted MD5.
If you want salted multi-round MD5, specify "MD5".salt - the salt hashed with the secret, or null.hash - the hashed secret.public PasswordHash(java.lang.String algorithm,
java.lang.String salt,
java.lang.String hash)
throws org.apache.commons.codec.DecoderException
PasswordHash(String, byte[], byte[]) but with
hexadecimal-encoded Strings.algorithm - the digest algorithm used in producing hash.
If empty, set to null. Other methods will treat this as unsalted MD5.
If you want salted multi-round MD5, specify "MD5".salt - hexadecimal digits encoding the bytes of the salt, or null.hash - hexadecimal digits encoding the bytes of the hash.org.apache.commons.codec.DecoderException - if salt or hash is not proper hexadecimal.public PasswordHash(java.lang.String password)
password - the secret to be hashed.public boolean matches(java.lang.String secret)
secret - string to be hashed and compared to this hash.public byte[] getHash()
public java.lang.String getHashString()
public byte[] getSalt()
public java.lang.String getSaltString()
public java.lang.String getAlgorithm()
public static java.lang.String getDefaultAlgorithm()
Copyright © 2018 DuraSpace. All Rights Reserved.