DefinitelyTyped/types/bcrypt-nodejs/bcrypt-nodejs-tests.ts
2017-03-24 14:27:52 -07:00

29 lines
808 B
TypeScript

import bCrypt = require("bcrypt-nodejs");
function test_sync() {
var salt1 = bCrypt.genSaltSync();
var salt2 = bCrypt.genSaltSync(8);
var hash1 = bCrypt.hashSync('super secret');
var hash2 = bCrypt.hashSync('super secret', salt1);
var compare1 = bCrypt.compareSync('super secret', hash1);
var rounds1 = bCrypt.getRounds(hash2);
}
function test_async() {
var cbString = (error: Error, result: string) => {};
var cbVoid = () => {};
var cbBoolean = (error: Error, result: boolean) => {};
bCrypt.genSalt(8, cbString);
var salt = bCrypt.genSaltSync();
bCrypt.hash('super secret', salt, cbString);
bCrypt.hash('super secret', salt, cbVoid, cbString);
var hash = bCrypt.hashSync('super secret');
bCrypt.compare('super secret', hash, cbBoolean);
}