Skip to content

jimmyolo/crypt3-passwd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CRYPT(3) for node.js

A nodejs CRYPT(3) N-API module for password encrypt and verify.

Installation

$ npm install crypt3-passwd

Usage

encrypt(password: String, salt: String, algo: String)

  • password (required)
  • salt (optional): if missing, will auto create random salt (length=16) without rounds part
  • algo (optional): 'md5'|'sha256'|'sha512'(default)

verify(password: String, hashed: String)

const crypt3 = require('crypt3-passwd')

crypt3.verify(
  'jimmy',
  crypt3.encrypt('jimmy', 'salt', 'sha512')
) 

// user-supplied hashing rounds support as well
crypt3.verify(
  'jimmy',
  crypt3.encrypt('jimmy', 'rounds=1000$salt')
)
// rounds number should be between `1000` and `999999999`
// see: https://man7.org/linux/man-pages/man3/crypt.3.html for more details