|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.pf.security.crypto.HashedString
public class HashedString
Container for a SHA hashed strings including salt for SSHA. Supports SHA-1 (160 bit) as well as SHA-2 (256, 383, 512 bit). SHA-2 224 bit is not supported before Java 8 or with a crypto provider explicitly added to the classpath.
Constructor Summary | |
---|---|
HashedString(byte[] content,
byte[] salt,
HashMechanism mechanism)
|
|
HashedString(byte[] content,
byte[] salt,
String hashType)
|
|
HashedString(byte[] content,
HashMechanism mechanism)
|
|
HashedString(byte[] content,
String hashType)
|
|
HashedString(String string)
Initialize the new instance with a hashed string. |
Method Summary | |
---|---|
String |
asString()
Returns the contents base64 with a curly bracket prefix that defines the used hashing mechanism. |
byte[] |
getHashValue()
Returns the hash value (without appended salt, if any). |
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). |
String |
getHashWithSaltValueBase64()
Returns the hash value with appended salt value (if any) as Base64 encoded string. |
byte[] |
getSaltValue()
Returns the salt that has been used to hash the string or null if no salt was used. |
boolean |
isEqual(byte[] plainText)
Compares the given plain text string with the hashed string. |
boolean |
isEqual(String string)
Compares the given clear text string with the hashed value. |
boolean |
isEqualUTF8(String string)
Compares the given clear text string with the hashed value (which was hashed as UTF-8). |
boolean |
isSalted()
Returns true if the value is salted. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public HashedString(String string)
string
- A base64 encoded hash of a string with a prefix
(e.g. {SHA} or {SSHA} or {SHA256} )public HashedString(byte[] content, String hashType)
public HashedString(byte[] content, HashMechanism mechanism)
public HashedString(byte[] content, byte[] salt, String hashType)
public HashedString(byte[] content, byte[] salt, HashMechanism mechanism)
Method Detail |
---|
public byte[] getHashValue()
public byte[] getSaltValue()
public byte[] getHashWithSaltValue()
getHashValue()
.
public String getHashValueBase64()
public String getHashWithSaltValueBase64()
getHashValueBase64()
.
public boolean isSalted()
public boolean isEqualUTF8(String string)
public boolean isEqual(String string)
public boolean isEqual(byte[] plainText)
public String asString()
Example: "{SSHA256}lKv8GwCDbjB6wvYroiAKaGZXUdWYgtYAnpQWLTrWHPUSzuooRrOT5Yp70mbNwfx0IziQ+g=="
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |