public class HashedString
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected static CryptoUtil |
CRYPTU |
Constructor and Description |
---|
HashedString(byte[] content,
byte[] salt,
HashMechanism mechanism) |
HashedString(byte[] content,
byte[] salt,
java.lang.String hashType) |
HashedString(byte[] content,
HashMechanism mechanism) |
HashedString(byte[] content,
java.lang.String hashType) |
HashedString(java.lang.String string)
Initialize the new instance with a hashed string.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
asString()
Returns the contents base64 with a curly bracket prefix that defines
the used hashing mechanism.
|
protected HashMechanism |
getHashMechanism() |
byte[] |
getHashValue()
Returns the hash value (without appended salt, if any).
|
java.lang.String |
getHashValueBase64()
Returns the hash value (without appended salt, if any) as Base64 encoded string.
|
byte[] |
getHashWithSaltValue()
Returns the hash value with appended salt value (if any).
|
java.lang.String |
getHashWithSaltValueBase64()
Returns the hash value with appended salt value (if any) as Base64 encoded string.
|
protected byte[] |
getSalt() |
byte[] |
getSaltValue()
Returns the salt that has been used to hash the string or null if
no salt was used.
|
protected byte[] |
getStrHash() |
protected void |
init(byte[] content,
byte[] saltData,
HashMechanism mechanism) |
protected void |
init(java.lang.String string)
Initialized this HashedString instance from a Base64 encoded hash that is
prefixed with an algorithm identifier.
|
boolean |
isEqual(byte[] plainText)
Compares the given plain text string with the hashed string.
|
boolean |
isEqual(java.lang.String string)
Compares the given clear text string with the hashed value.
|
boolean |
isEqualUTF8(java.lang.String string)
Compares the given clear text string with the hashed value (which was hashed as UTF-8).
|
protected boolean |
isHashed() |
boolean |
isSalted()
Returns true if the value is salted.
|
protected void |
setHashMechanism(HashMechanism info) |
protected void |
setIsHashed(boolean newValue) |
protected void |
setSalt(byte[] newValue) |
protected void |
setStrHash(byte[] newValue) |
protected byte[][] |
split(byte[] src,
int n) |
protected StringUtil |
str() |
protected byte[] |
stringToBytes(java.lang.String string)
Converts the given string to a byte array.
|
java.lang.String |
toString() |
protected static final CryptoUtil CRYPTU
public HashedString(java.lang.String string)
string
- A base64 encoded hash of a string with a prefix
(e.g. {SHA} or {SSHA} or {SHA256} )public HashedString(byte[] content, java.lang.String hashType)
public HashedString(byte[] content, HashMechanism mechanism)
public HashedString(byte[] content, byte[] salt, java.lang.String hashType)
public HashedString(byte[] content, byte[] salt, HashMechanism mechanism)
public byte[] getHashValue()
public byte[] getSaltValue()
public byte[] getHashWithSaltValue()
getHashValue()
.public java.lang.String getHashValueBase64()
public java.lang.String getHashWithSaltValueBase64()
getHashValueBase64()
.public boolean isSalted()
public boolean isEqualUTF8(java.lang.String string)
public boolean isEqual(java.lang.String string)
public boolean isEqual(byte[] plainText)
public java.lang.String asString()
Example: "{SSHA256}lKv8GwCDbjB6wvYroiAKaGZXUdWYgtYAnpQWLTrWHPUSzuooRrOT5Yp70mbNwfx0IziQ+g=="
public java.lang.String toString()
toString
in class java.lang.Object
protected void init(java.lang.String string)
string
- Base64 encoded hash with prefix.protected void init(byte[] content, byte[] saltData, HashMechanism mechanism)
protected byte[][] split(byte[] src, int n)
protected byte[] stringToBytes(java.lang.String string)
protected byte[] getStrHash()
protected void setStrHash(byte[] newValue)
protected byte[] getSalt()
protected void setSalt(byte[] newValue)
protected boolean isHashed()
protected void setIsHashed(boolean newValue)
protected HashMechanism getHashMechanism()
protected void setHashMechanism(HashMechanism info)
protected StringUtil str()