We cannot directly store user password in the database.

What need to do is creating a hashed & salted string which reperstanting the user password.

This password is not reverable. And very hard for hacker to guess what is the origial password by using Dictionary Attacks.

var crypto = require('crypto');

var password = "monkey";

// randomBytes: generate a salt pre user, salt should be stored with hashed password in the database
crypto.randomBytes(, function(err, salt) { // pbkdf2: combine the salt the hash password algorithm, to generate a safe password
crypto.pbkdf2(password, salt, , , 'sha256',
function(err, hash) { console.log("The result of hashing " + password + " is:\n\n" +
hash.toString('hex') + "\n\n"); }); });

最新文章

  1. ASP.NET Core的配置(4):多样性的配置来源[下篇]
  2. iOS---用Application Loader 上传的时候报错No suitable application records were found. Verify your bundle identifier 'xx' is correct
  3. Socket
  4. aop测试jdk代理机制
  5. eclipse一直卡住,出现 “android sdk content loader 0%” 卡住的错误分析及解决方法
  6. Linux文件管理命令
  7. 27、oracle(三)
  8. 深入浅出ExtJS 第二章 Ext框架基础
  9. MYSQL 5.7 新增150多个新功能
  10. Android UI设计系统---LayoutParams[转]
  11. Asp.net笔记(1)
  12. 《TCP/IP详细解释》札记(23章)-TCP该保活定时器
  13. html自定义调控
  14. mysql随笔
  15. 用分支限界法解决人员安排问题(Personnel assignment problem)
  16. 如何解决svn清理失败 不能更新 cleanup失败 cleanup乱码 更新乱码 svn更新提示清理 清理乱码不能清理 svn故障修复SVN cleanup 陷入死循环 svn cleanup时遇到错误怎么办
  17. linux内核源码目录结构分析
  18. 51Nod1367 完美森林 贪心
  19. Android_编程开发规范
  20. Linux内核剖析(四)为arm内核构建源码树

热门文章

  1. 程序猿的量化交易之路(13)--Cointrader类图(1)
  2. 3.索引与string进行映射实现高效查找
  3. 18.链表管理内存实现c语言自动释放内存
  4. Linear Decoders
  5. sql server 怎样用select语句调用自定义表值函数
  6. read---读取变量值
  7. 今日SGU 5.3
  8. [Angular] Create a custom validator for template driven forms in Angular
  9. cocoapod卡在了analyzing dependencies
  10. <memory>(包括了auto_ptr,shared_ptr等各种指针)