Add definition for password-hash

npm: https://www.npmjs.com/package/password-hash
project: https://github.com/davidwood/node-password-hash
This commit is contained in:
TANAKA Koichi
2016-03-30 18:02:12 +09:00
parent dbb2d9f1f1
commit 2058a1951c
2 changed files with 34 additions and 0 deletions
+18
View File
@@ -0,0 +1,18 @@
/// <reference path="password-hash.d.ts" />
'use strict';
import {generate, verify, isHashed} from 'password-hash';
let password = 'raw-password';
let hashed: string;
hashed = generate(password);
hashed = generate(password, {algorithm: 'sha256'});
hashed = generate(password, {saltLength: 10});
hashed = generate(password, {iterations: 11});
hashed = generate(password, {algorithm: 'sha512', saltLength: 9, iterations: 11});
let isOk: boolean;
isOk = verify(password, hashed);
isOk = isHashed(password);
+16
View File
@@ -0,0 +1,16 @@
// Type definitions for password-hash 1.2.x
// Project: https://github.com/davidwood/node-password-hash
// Definitions by: TANAKA Koichi <https://github.com/mugeso/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare module 'password-hash' {
export function generate(password: string, options?: Options): string;
export function verify(password: string, hashedPassword: string): boolean;
export function isHashed(password: string): boolean;
export interface Options {
algorithm?: string;
saltLength?: number;
iterations?: number;
}
}