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 StringcalculateHash(String password, String salt) Generates a hash combining password and a salt using concatenation.static StringgeneratePassword(int length) static StringgeneratePassword(int length, boolean symbols, boolean numbers, boolean lowercase, boolean uppercase, boolean excludeAmbiguousCharacters) Generates a random string.static StringGenerates a random HEX string chars = [0-9a-f]{16}, lowercase onlystatic booleanisPasswordCorrect(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:
Stringrandom 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
-