com.lambdaworks.crypto
Class SCryptUtil
java.lang.Object
com.lambdaworks.crypto.SCryptUtil
public class SCryptUtil
- extends java.lang.Object
Simple SCrypt
interface for hashing passwords using the
scrypt key derivation fuction
and comparing a plain text password to a hashed one. The hashed output is an
extended implementation of the Modular Crypt Format that also includes the scrypt
algorithm parameters.
Format: $s0$PARAMS$SALT$KEY
.
- PARAMS
- 32-bit hex integer containing log2(N) (16 bits), r (8 bits), and p (8 bits)
- SALT
- base64-encoded salt
- KEY
- base64-encoded derived key
s0
identifies version 0 of the scrypt format, using a 128-bit salt and 256-bit derived key.
- Version:
- 1.0
- Author:
- Will Glozer
Method Summary |
static boolean |
check(java.lang.String passwd,
java.lang.String hashed)
Compare the supplied plaintext password to a hashed password. |
static java.lang.String |
scrypt(java.lang.String passwd,
int N,
int r,
int p)
Hash the supplied plaintext password and generate output in the format described
in SCryptUtil . |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SCryptUtil
public SCryptUtil()
scrypt
public static java.lang.String scrypt(java.lang.String passwd,
int N,
int r,
int p)
- Hash the supplied plaintext password and generate output in the format described
in
SCryptUtil
.
- Parameters:
passwd
- Password.N
- CPU cost parameter.r
- Memory cost parameter.p
- Parallelization parameter.
- Returns:
- The hashed password.
check
public static boolean check(java.lang.String passwd,
java.lang.String hashed)
- Compare the supplied plaintext password to a hashed password.
- Parameters:
passwd
- Plaintext password.hashed
- scrypt hashed password.
- Returns:
- true if passwd matches hashed value.
Copyright © 2011. All Rights Reserved.