How to use the argon2.generateSalt function in argon2

To help you get started, we’ve selected a few argon2 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ranisalt / koa-from-scratch / test / users.spec.js View on Github external
test('edit resource', async t => {
  let user = new User({
    name: 'ademir',
    password: await argon2.hash('123456', await argon2.generateSalt())
  })
  await user.save()

  const {status} = await t.context.request.patch(`/users/${user.get('name')}`).send({
    password: '654321'
  })
  t.is(status, 200)

  user = await User.findById(user.get('_id'))
  t.true(await argon2.verify(user.get('password'), '654321'))
})
github ranisalt / koa-from-scratch / test / todos.spec.js View on Github external
test.before(async () => {
  const user = new User({
    name: 'ademir',
    password: await argon2.hash('123456', await argon2.generateSalt())
  })
  await user.save()
})
github ranisalt / koa-from-scratch / routes / users.js View on Github external
router.post('/', async ctx => {
  const {name, password} = ctx.request.body
  const hash = await argon2.hash(password, await argon2.generateSalt())
  const user = new User({name, password: hash})
  await user.save()
  ctx.body = {user}
  ctx.status = 201
})

argon2

An Argon2 library for Node

MIT
Latest version published 2 months ago

Package Health Score

84 / 100
Full package analysis