Skip to content

cristovao-trevisan/bcrypt-cached

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bcrypt-cached

Use memory cached results for bcrypt

Example:

const bcryptCached = require('bcrypt-cached')

var myCache = new bcryptCached({
  ttl: 60, // default = 600
  checkperiod: 20 // default = 60
})

const plainTextPassword = '12345678'
const hash = '$2a$10$EotbI1GgQMZMg3siykIgKeSZe4MwF52pYj5FBd1fGdNiszP7RQGNu'

console.log(process.hrtime())
// saving to cache
myCache.compare(hash, plainTextPassword).then((res) => {
  console.log(process.hrtime(), res)
  // running really fast (≃ 1000 faster for a single core)
  myCache.compare(hash, plainTextPassword).then((res) => {
    console.log(process.hrtime(), res)
  })
})

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published