Domanda

I'm trying to save passwords in my database, and I want to hash them with either MD5 or SHA2.

I googled it and found a lot of very different topics with long lines of code all the time, I don't know why.

Isn't it possible to store a password with one line of code with crypto.js ?

e.g.

var crypto = require('crypto-js')  
collection.insert(user: "my user", password: crypto.sha2("my-password")

So later, I can do the simplest auth ever and process the result of this db request:

db.findOne({use:"my user", password: crypto.sha2("my-password") etc...
È stato utile?

Soluzione

You shouldn't use general-purpose hash algorithms such as SHA-2 for storing passwords. See: http://codahale.com/how-to-safely-store-a-password/

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top