public class SCryptPasswordEncoder extends java.lang.Object implements PasswordEncoder
Implementation of PasswordEncoder that uses the SCrypt hashing function. Clients can optionally supply a cpu cost parameter, a memory cost parameter and a parallelization parameter.
A few warnings:
|Constructor and Description|
Creates a new instance
|Modifier and Type||Method and Description|
Encode the raw password.
Verify the encoded password obtained from storage matches the submitted raw password after it too is encoded.
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
public SCryptPasswordEncoder(int cpuCost, int memoryCost, int parallelization, int keyLength, int saltLength)
cpuCost- cpu cost of the algorithm (as defined in scrypt this is N). must be power of 2 greater than 1. Default is currently 16,348 or 2^14)
memoryCost- memory cost of the algorithm (as defined in scrypt this is r) Default is currently 8.
parallelization- the parallelization of the algorithm (as defined in scrypt this is p) Default is currently 1. Note that the implementation does not currently take advantage of parallelization.
keyLength- key length for the algorithm (as defined in scrypt this is dkLen). The default is currently 32.
saltLength- salt length (as defined in scrypt this is the length of S). The default is currently 64.
public java.lang.String encode(java.lang.CharSequence rawPassword)
public boolean matches(java.lang.CharSequence rawPassword, java.lang.String encodedPassword)