node package manager
Don’t reinvent the wheel. Reuse code within your team. Create a free org »

achim-crypto

How to use

This package designed to help you to hash or encrypt your password. usually used when user login, register, change password etc. this package also comes with other packages "achim-salt"

Install

>> npm i -S achim-crypto achim-salt

Example

const hash = require('achim-crypto');
const salt = require('achim-salt');

var register = (req, res) => {
  secretKey = salt()
  pass = hash(req.body.password, secretKey)
  User.find({username: req.body.username})
  .then(result => {
    if(result.length == 0){
      User.create({
        username: req.body.username,
        password: pass,
        secret: secretKey
      })
      .then(result => res.send(result))
    } else {
      res.send(`${req.body.username} : allready exist`)
    }
  })
}