atinux / nuxt-auth-utils

Minimal Auth module for Nuxt 3.
MIT License
818 stars 79 forks source link

Add `hashPassword()` and `verifyPassword()` server utils #155

Open atinux opened 2 weeks ago

atinux commented 2 weeks ago
// import is optional
import { hashPassword, verifyPassword } from '#auth-utils'

const hash = hashPassword('user_password')
// $2a$10$vEdoE9pqBlkJMqWmbk1JWuEYbJoansodgPo7a2GBkXsO8SleGXCr6

if (verifyPassword(existingHash, plainTextValue)) {
  // password is correct
}

Demo from bcrypt-edge on https://github.com/atinux/nuxt-bcrypt-edge

The second argument of hashPassword is the same as hashSync

const hash = hashPassword('use_password', 12)