Utility classes
Crypt
Crypt allows to encrypt text with different algorithms and verify the resulting hash.
To use this class: com.soffid.iam.crypt.Crypt
All methods are static:
hash(String algorithm, String text) -> String
pBKDF2Sha256(String text, String utf8Salt, int iterations) -> String
pBKDF2Sha256(String text, byte []salt, int iterations) -> String
pBKDF2Sha1(String text, String utf8Salt, int iterations) -> String
pBKDF2Sha1(String text, byte []salt, int iterations) -> String
genSaltBytes() -> byte[] // 8 bytes
genSaltBytes(int size) -> byte[]
genSalt() -> String // 8 bytes
genSalt(int size) -> String
verify(String algorithm, String text, String hash) -> boolean
The algorithms allowed are:
- bcrypt
- pBKDF2Sha256
- pBKDF2Sha1 (or pBKDF2)
- Base64 (used by default is the algorithm is not in the previous list)
One example:
String myText = "abcd";
String myAlgorithm = "bcrypt";
String myHash = com.soffid.iam.crypt.Crypt.hash(myAlgorithm, myText);
boolean isVerified = com.soffid.iam.crypt.Crypt.verify(myAlgorithm, myText, myHash);
if (isVerified) {
return myHash;
} else {
return null;
}
CalendarConverter
CalendarConverter allows to covert Calendar into String.
To use this class: com.soffid.iam.json.CalendarConverter
The methods (non static):
toString(Calendar instance) -> String
fromString(final String text) -> Calendar
One example:
out.println(new com.soffid.iam.json.CalendarConverter().toString(date));