2.0.6 • Published 5 years ago
@coolgk/bcrypt v2.0.6
@coolgk/bcrypt
a javascript / typescript module
npm install @coolgk/bcrypt
just a promise wrapper
Report bugs here: https://github.com/coolgk/node-utils/issues
Examples
import { encrypt, verify } from '@coolgk/bcrypt';
// OR
// const { encrypt, verify } = require('@coolgk/bcrypt');
const password = 'abc123';
encrypt(password).then((hash) => {
verify(password, hash).then(console.log); // true
verify(password, 'invalidhash').then(console.log, console.error); // Not a valid BCrypt hash.
verify('invalidpass', hash).then(console.log); // false
});
Functions
encrypt(value, salt) ⇒ promise.<string>
Kind: global function
Param | Type | Description |
---|---|---|
value | string | string to encrypt |
salt | string | salt |
verify(value, hashedString) ⇒ promise.<boolean>
Kind: global function
Param | Type | Description |
---|---|---|
value | string | string to check |
hashedString | string | encrypted hash |