Home Reference Source
public class | source

Crypt

Direct Subclass:

PBKDF2, SCRYPT

Abstract class for taking care of password hashing and verification.

Method Summary

Public Methods
public

async hash(password: string): string

Hash a password.

public abstract

async hashImplementation(password_: string): string

Implementation of hash() minus checks.

public

async verify(password: String, hash: String): boolean

Verify a password against previously hashed password

public

async verifyImplementation(password: String, hash: String): boolean

Implementation of verify() minus checks.

Public Methods

public async hash(password: string): string source

Hash a password.

Params:

NameTypeAttributeDescription
password string

Password to hash

Return:

string

Promise should return hash as string or error

public abstract async hashImplementation(password_: string): string source

Implementation of hash() minus checks.

Params:

NameTypeAttributeDescription
password_ string

Password to hash

Return:

string

Promise should return hash as string or error

public async verify(password: String, hash: String): boolean source

Verify a password against previously hashed password

Params:

NameTypeAttributeDescription
password String

Password to compare

hash String

Previously hashed password

Return:

boolean

Promise should return boolean result.

public async verifyImplementation(password: String, hash: String): boolean source

Implementation of verify() minus checks.

Default implementation hashes new password and does string compare. This'll work for weaker hashes like md5 but won't work for stronger ones like scrypt.

Params:

NameTypeAttributeDescription
password String

Password to compare

hash String

Previously hashed password

Return:

boolean

Promise should return boolean result.