Package org.seedstack.seed.crypto
Interface HashingService
-
public interface HashingServiceSupport for creating a hash and validating passwords. When creating a hash from a string or char[], a random salt will be generated and given with the hash through aHashobject.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description HashcreateHash(char[] toHash)Creates a hash from a char[].HashcreateHash(String toHash)Creates a hash from a string.booleanvalidatePassword(char[] password, Hash correctHash)Validates a password using a hash.booleanvalidatePassword(String password, Hash correctHash)Validates a password using a hash.
-
-
-
Method Detail
-
createHash
Hash createHash(String toHash)
Creates a hash from a string.- Parameters:
toHash- the String to hash.- Returns:
- a
Hashgiving the hash of the String and the Salt used.
-
createHash
Hash createHash(char[] toHash)
Creates a hash from a char[]. This method can be convenient as passwords are often represented in java as char[].- Parameters:
toHash- the char[] to hash.- Returns:
- a
Hashgiving the hash of the char[] and the Salt used.
-
validatePassword
boolean validatePassword(char[] password, Hash correctHash)Validates a password using a hash.- Parameters:
password- the password to check.correctHash- the hash of the valid password.- Returns:
- true if the password is correct, false if not.
-
-