-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PBKDF2 Example ? #1
Comments
Absolutely! I'll try and post this in the next few days, feel free to nag me if I forget 😄 |
Hi Linus. I've resurrected my project and was re-reading your README which suggests using PBKDF2. Just therefore wanted to drop you a friendly reminder that you were going to share an example implementation for this. Thanks. |
You can see how I'm using it here: and here: Basically it boils down to something like: const pbkdf2 = require('@ctrlpanel/pbkdf2')
const encodeUtf8 = require('encode-utf8')
const PBKDF2_HASH = 'SHA-512'
const PBKDF2_ITERATIONS = 500000
const PBKDF2_KEYLEN = 32
// ...
async function (username, password) {
// get `salt` from server
const salt = '...'
// generate hash
const privateKey = arrayBufferToHex(await pbkdf2(encodeUtf8(`${username}:${password}`), salt, PBKDF2_ITERATIONS, PBKDF2_KEYLEN, PBKDF2_HASH))
// use hash with SRP
const verifier = srp.deriveVerifier(privateKey)
} I would love for this to be improved and added to the readme! |
I made a PR to add this to the README: |
@dobesv @LinusU I used another pbkdf2 hashing using fash-sha256, and I have the output as a Uint8Array. What am I supposed to convert this into? an arrayBuffer then to Hex? coz on trying to login, I am seeing
|
also I have to use the same pbkdf2 while deriving the privateKey in step 3 right? |
Yeah any time you are making a private key from a password input and salt, use the same algorithm. |
@dobesv The key should be in |
You can try converting it to hex. Experiment, look at the source code, you can figure it out. |
I converted it to a hex. after using the pbkdf2 derivation, sometimes, the user is successfully logged in, sometimes it throws this error
Edit: I found this was due to the bogus value sent when user was not found or the verifier/salt was not found in DB |
Do you have an example using PBKDF2 that you can share for reference since that is your recommended implementation?
The text was updated successfully, but these errors were encountered: