public class Password extends Object
A utility class for hashing user passwords
A helper class for generating secure passwords based on random salts The algorithm used is PBKDF2WithHmacSHA1 recommended by NIST . The hashed value has 256 bits.
| Modifier and Type | Method and Description |
|---|---|
static byte[] |
getBytes(String string) |
static byte[] |
hash(char[] password,
byte[] salt)
Returns a salted and hashed password using the provided hash.
Note - side effect: the password is destroyed (the char[] is filled with zeros) |
static boolean |
isExpectedPassword(char[] password,
byte[] salt,
byte[] expectedHash)
Returns true if the given password and salt match the hashed value, false otherwise.
Note - side effect: the password is destroyed (the char[] is filled with zeros) |
public static byte[] hash(char[] password,
byte[] salt)
password - the password to be hashedsalt - a 16 bytes salt, ideally obtained with the getNextSalt methodpublic static boolean isExpectedPassword(char[] password,
byte[] salt,
byte[] expectedHash)
password - the password to checksalt - the salt used to hash the passwordexpectedHash - the expected hashed value of the passwordpublic static byte[] getBytes(String string)
Copyright © 2017 Grakn Labs Ltd. All rights reserved.