Don't use MD5 for anything. Ever. If someone is asking you to use md5, 
trust it *less*, because they're likely trying to give you the impression 
of security, when in fact none exists. MD5 produces collisions, it's cheap 
to produce collisions, and it's vulnerable to length-extension attacks 
(like SHA-1 and SHA-2). These things combined are disastrous.

Use a dedicated key-derivation function that takes a randomly-generated 
salt like PBKDF2-SHA-256 (Node.js comes with PBKDF-SHA-1 which is 
sufficent). Always use a randomly generated salt.

Even if you're not generating passwords, you still don't use SHA-1 or SHA-2 
by itself. Use HMAC-SHA-256 or similar from the SHA-2 family, or better. 
The HMAC eliminates the length-extension venerability.

In general you shouldn't be programming your own password storage and user 
authentication mechanisms, it's ridiculously difficult to do correctly. 
Search around for existing libraries. If you must, learn from past 
mistakes: http://pdos.csail.mit.edu/papers/webauth:sec10.pdf

Austin Wright.

On Monday, July 30, 2012 12:05:32 PM UTC-7, Yogesh Agrawal wrote:
>
> Which is more preferable to save password in DB, bcrypt or md5 ?
>
> I found https://github.com/ncb000gt/node.bcrypt.js/ lib, which is a addon 
> to node.js to encrypt the passwords.
>
> Also I found that md5 based hashing is not too safe to store passwords in 
> DB.
>

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to