Bouncy Castle scrypt implementation
So that people don't have to go to an external site for an answer:
- Make sure bouncy castle jars are on your build path
Import SCrypt like so:
import org.bouncycastle.crypto.generators.SCrypt;
Use SCrypt like so:
byte[] sCryptHash = SCrypt.generate(plaintext.getBytes(), salt.getBytes(), cpuDifficultyFactor, memoryDifficultyFactor, parallelismDifficultyFactor, outputLength);
You can use the SCrypt
class with its static method generate
like this:
SCrypt.generate(passwordBytes, salt, costParam, blockSize, parallelization, passwordLength);
I can't really say what values you should use for costParam, blockSize or parallelization, the documentation doesn't say much to it. In our studies we used 8 for every of those.
Link to their docus: BCrypt - https://www.bouncycastle.org/docs/docs1.5on/org/bouncycastle/crypto/generators/BCrypt.html SCrypt - https://www.bouncycastle.org/docs/docs1.5on/org/bouncycastle/crypto/generators/SCrypt.html