I am using the following methods to create a salted and hashed password from the crypto lib in nodejs:
crypto.randomBytes(size, [callback])
crypto.pbkdf2(password, salt, iterations, keylen, callback)
For the randomBytes call (creating the SALT) what size should I use? I have heard 128-bit salts, maybe up to 256-bit. It looks like this function uses a size in bytes so can I assume a size of 32 (256 bits) is sufficient?
For the pbkdf2 call, what is a good number of iterations and what is a good length for the key (keylen)?
Also, for storage I have seen examples of storing the salt, length, iterations and derviedkey in the same column. I am using an example which separates the 4 by ::
, i.e.:
salt::derivedKey::keyLength::iterations
Doing this, I can then separate on ::
to get the 4 values, so I can generate a derived key based on a provided password to see if it matches. Is this the correct way to store this? Or should I be a little more "deceptive" in combining these values?