安装bcrypt安装不上问题

 加密库bcrypt安装时候遇到报错:

node-pre-gyp ERR! Tried to download(404):......

其实人家的文档里已经给你答案了:

https://www.npmjs.com/package/bcrypt


点进去会发现准对不同平台会有不同的解决办法:
windows平台就:
npm install --global --production windows-build-tools

然后再安装就ok了 

https://github.com/kelektiv/node.bcrypt.js/wiki/Installation-Instructions#microsoft-windows

顺便记录下用法:
let bcrypt = require('bcrypt')
function jiaMi(str){
  return bcrypt.hashSync(str,10)
}
function jieMi(str, hashStr){
  return bcrypt.compareSync(str, hashStr)
}

let res = jiaMi('chou')
console.log('res :>> ', res);// $2b$10$skyd0Y2ERVb2TXYaYQAoJOaEPf.u/XGCDuWrPCnnWP5PlF3NAzZcm
let res2 = jieMi('chou', res)
console.log('res2 :>> ', res2);// true

over









posted on 2020-07-27 17:02  rainbowLover  阅读(677)  评论(0编辑  收藏  举报