public class SSHA extends Object
Salted SHA (aka SSHA) is computed as follows:
result = {SSHA}BASE64(SHA(password,salt),salt)
Methods are also provided to return partial results, such as SHA( password , salt) without Base64 encoding.
| Modifier and Type | Field and Description |
|---|---|
static String |
defaultAlgo |
| Constructor and Description |
|---|
SSHA() |
| Modifier and Type | Method and Description |
|---|---|
static byte[] |
compute(byte[] salt,
byte[] password,
String algo)
Compute a salted SHA hash.
|
static byte[] |
decode(String encoded,
byte[] hashResult,
String algo)
Decodes an encoded SSHA string.
|
static String |
encode(byte[] salt,
byte[] hash,
String algo)
Perform encoding of salt and computed hash.
|
static boolean |
verify(byte[] salt,
byte[] hash,
byte[] password,
String algo)
Verifies a password.
|
static boolean |
verify(String encoded,
byte[] password)
Verifies a password.
|
public static final String defaultAlgo
public static byte[] compute(byte[] salt,
byte[] password,
String algo)
throws IllegalArgumentException
salt - Salt bytes.password - Password bytes.IllegalArgumentException - Thrown if there is an error.public static String encode(byte[] salt, byte[] hash, String algo)
salt - Salt bytes.hash - Result of prior compute() operation.public static boolean verify(String encoded, byte[] password) throws IllegalArgumentException
The given password is verified against the provided encoded SSHA result string.
encoded - Encoded SSHA value (e.g. output of computeAndEncode())password - Password bytes of the password to verify.IllegalArgumentException - Thrown if there is an error.public static boolean verify(byte[] salt,
byte[] hash,
byte[] password,
String algo)
throws IllegalArgumentException
The given password is verified against the provided salt and hash buffers.
salt - Salt bytes used in the hash result.hash - Hash result to compare against.password - Password bytes of the password to verify.IllegalArgumentException - Thrown if there is an error.public static byte[] decode(String encoded, byte[] hashResult, String algo) throws IllegalArgumentException
encoded - Encoded SSHA value (e.g. output of computeAndEncode())hashResult - A byte array which must contain 20 elements. Upon
succesful return from method, it will be filled by the hash
value decoded from the given SSHA string. Existing values are
not used and will be overwritten.IllegalArgumentException - Thrown if there is an error.Copyright © 2017–2020 Eclipse Foundation. All rights reserved.