| | BouncyScrypt |
---|
| | === |
---|
| | # BouncyScrypt |
---|
| | |
---|
| | A facade for salted password hashing with scrypt using Bouncy Castle. |
---|
| | |
---|
| | Generates output that is in a format similar to Modular Crypt Format (MCF). The output includes the following fields (separated by a `$` character): |
---|
| |
---|
| | * The Base64 encoded derived hash. |
---|
| | |
---|
| | The result looks like: |
---|
| | |
---|
| | ```$919553$mshp5K/vaKkdSzbRqqMTLwr76eSurBsTuVCIIDxuZEE6u093MHBk0Miaq3Qp/Vd7QdP/WeOglVg6W/omiNfC8g==$eV7FfnHnmwyCU8i4rAHQ6NO5RZp53/V1Wr3jsFCc1BqM6yvmGp6BfG7VFrmz21cFlzf4F/aPkgRuO5DRBHgIPQ==$``` |
---|
| | ``` |
---|
| | $919553$mshp5K/vaKkdSzbRqqMTLwr76eSurBsTuVCIIDxuZEE6u093MHBk0Miaq3Qp/Vd7QdP/WeOglVg6W/omiNfC8g==$eV7FfnHnmwyCU8i4rAHQ6NO5RZp53/V1Wr3jsFCc1BqM6yvmGp6BfG7VFrmz21cFlzf4F/aPkgRuO5DRBHgIPQ==$ |
---|
| | ``` |
---|
| | |
---|
| | The salts are generated using Java's SHA1PRNG secure psuedo-random number generator. |
---|
| | |
---|
| | The standard scrypt work factors are used: |
---|
| |
---|
| | * p = 1 |
---|
| | |
---|
| | Both the generated salt and the derived hash (`dkLen`) are 64 bytes. The generated output is 186 characters. |
---|
| | |
---|
| | #API |
---|
| | # API |
---|
| | |
---|
| | ```java |
---|
| | // generate a hash |
---|
| | public static CharBuffer hash(CharSequence password) |
---|
| |
---|
| | // check a password against a hash |
---|
| | public static boolean check(CharSequence mcfHash, CharSequence password) |
---|
| | ``` |
---|
| | |
---|
| | #Usage |
---|
| | # Usage |
---|
| | |
---|
| | The API uses `CharSequence` objects as input and `CharBuffer` objects as output. This gives us a couple of choices: |
---|
| | |
---|
| | * Use `String` objects for simplicity. The downside of `String` objects is that they are immutable meaning that we can't overwrite the sensitive data when we are finished with it. |
---|
| |
---|
| | |
---|
| | FreeBSD License (BSD-2-Clause) |
---|
| | |
---|
| | https://opensource.org/licenses/BSD-2-Clause |
---|
| | |
---|