1.1.0 • Published 7 years ago

crypto-bcrypt v1.1.0

Weekly downloads
4
License
MIT
Repository
github
Last release
7 years ago

基于 crypto 模块开发的用户注册登录插件

crypto-bctypt

hash the password for sign in && hash password for sign up/ 注册密码加密,登录密码比对

Installation

npm install crypto-bcrypt --save

Usage

sign up/ 注册

genPaswd(user1.psw).then(hash => {
  // save the hash
}).catch(err => deal(err))

sign in / 登录

compare(hash, user1.psw).then( bool => {
  if (bool) {
    // just to sigin in}
  else {
    // may your pswd is wrong
  }
}).catch(err=> deal(err))

param

genPaswd(pasw, salt, iterations, keylen, digest)

compare(hashedPsw, pasw, salt, iterations, keylen digest)

// genPaswd(yourpassword, 'a password', 1000, 69, 'sha512')

// default
genPaswd(user1.pasw)
// default
compare(hash, user1.psw)


// custom 
const customSalt = 'custom'
genPaswd(user1.pasw, customSalt)
// compare need custom too
compare(hash, user1.psw, customSalt)
1.1.0

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago

0.0.1

7 years ago