Package sk.iway.iwcm.users
Class PasswordSecurity
java.lang.Object
sk.iway.iwcm.users.PasswordSecurity
PasswordSecurity.java
Contains hash functions helping in
users' password managment and verification.
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
calculateHash
(String password, String salt) Generates a hash combining password and a salt using concatenation.static String
generatePassword
(int length) static String
generatePassword
(int length, boolean symbols, boolean numbers, boolean lowercase, boolean uppercase, boolean excludeAmbiguousCharacters) Generates a random string.static String
Generates a random HEX string chars = [0-9a-f]{16}, lowercase onlystatic boolean
isPasswordCorrect
(String password, String salt, String hash)
-
Method Details
-
generatePassword
-
generatePassword
public static String generatePassword(int length, boolean symbols, boolean numbers, boolean lowercase, boolean uppercase, boolean excludeAmbiguousCharacters) Generates a random string.- Parameters:
length
-symbols
- ( e.g. @#$% )numbers
- ( e.g. 123456 )lowercase
- ( e.g. abcdefgh )uppercase
- ( e.g. ABCDEFGH )excludeAmbiguousCharacters
- ( { } [ ] ( ) / \ ' " ` ~ , ; : . < > )- Returns:
-
generateSalt
Generates a random HEX string chars = [0-9a-f]{16}, lowercase only- Returns:
String
random hex string
-
calculateHash
Generates a hash combining password and a salt using concatenation.- Parameters:
password
- any Stringsalt
- Generated by generateSalt, must match ^[0-9a-f]{16}$, otherwise rejected- Returns:
- [0-9a-f]{128} String
-
isPasswordCorrect
-