public class Password extends Object
| Modifier and Type | Method and Description |
|---|---|
static byte[] |
getBytes(String string) |
static byte[] |
getNextSalt(GraknGraph graph)
Returns a random salt to be used to hash a password.
|
static String |
getString(byte[] bytes) |
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[] getNextSalt(GraknGraph graph)
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 String getString(byte[] bytes)
public static byte[] getBytes(String string)
Copyright © 2017 Grakn Labs Ltd. All rights reserved.