@types/bcryptjs
- Version 2.4.6
- Published
- 7.65 kB
- No dependencies
- MIT license
Install
npm i @types/bcryptjs
yarn add @types/bcryptjs
pnpm add @types/bcryptjs
Overview
TypeScript definitions for bcryptjs
Index
Functions
function compare
compare: { (s: string, hash: string): Promise<boolean>; ( s: string, hash: string, callback?: (err: Error, success: boolean) => void, progressCallback?: (percent: number) => void ): void;};
Asynchronously compares the given data against the given hash.
Parameter s
Data to compare
Parameter hash
Data to be compared to Promise, if callback has been omitted
Asynchronously compares the given data against the given hash.
Parameter s
Data to compare
Parameter hash
Data to be compared to
Parameter callback
Callback receiving the error, if any, otherwise the result
Parameter progressCallback
Callback successively called with the percentage of rounds completed (0.0 - 1.0), maximally once per MAX_EXECUTION_TIME = 100 ms.
function compareSync
compareSync: (s: string, hash: string) => boolean;
Synchronously tests a string against a hash.
Parameter s
String to compare
Parameter hash
Hash to test against true if matching, otherwise false
function decodeBase64
decodeBase64: (s: string, len: number) => number[];
Decodes a base64 encoded string to up to len bytes of output, using the custom bcrypt alphabet.
Parameter s
String to decode
Parameter len
Maximum output length
function encodeBase64
encodeBase64: (b: Readonly<ArrayLike<number>>, len: number) => string;
Encodes a byte array to base64 with up to len bytes of input, using the custom bcrypt alphabet.
Parameter b
Byte array
Parameter len
Maximum input length
function genSalt
genSalt: { (rounds?: number): Promise<string>; (callback: (err: Error, salt: string) => void): void; (rounds: number, callback: (err: Error, salt: string) => void): void;};
Asynchronously generates a salt.
Parameter rounds
Number of rounds to use, defaults to 10 if omitted Promise with resulting salt, if callback has been omitted
Asynchronously generates a salt.
Parameter callback
Callback receiving the error, if any, and the resulting salt
Asynchronously generates a salt.
Parameter rounds
Number of rounds to use, defaults to 10 if omitted
Parameter callback
Callback receiving the error, if any, and the resulting salt
function genSaltSync
genSaltSync: (rounds?: number) => string;
Synchronously generates a salt.
Parameter rounds
Number of rounds to use, defaults to 10 if omitted Resulting salt
Throws
If a random fallback is required but not set
function getRounds
getRounds: (hash: string) => number;
Gets the number of rounds used to encrypt the specified hash.
Parameter hash
Hash to extract the used number of rounds from Number of rounds used
function getSalt
getSalt: (hash: string) => string;
Gets the salt portion from a hash. Does not validate the hash.
Parameter hash
Hash to extract the salt from Extracted salt part
function hash
hash: { (s: string, salt: number | string): Promise<string>; ( s: string, salt: string | number, callback?: (err: Error, hash: string) => void, progressCallback?: (percent: number) => void ): void;};
Asynchronously generates a hash for the given string.
Parameter s
String to hash
Parameter salt
Salt length to generate or salt to use Promise with resulting hash, if callback has been omitted
Asynchronously generates a hash for the given string.
Parameter s
String to hash
Parameter salt
Salt length to generate or salt to use
Parameter callback
Callback receiving the error, if any, and the resulting hash
Parameter progressCallback
Callback successively called with the percentage of rounds completed (0.0 - 1.0), maximally once per MAX_EXECUTION_TIME = 100 ms.
function hashSync
hashSync: (s: string, salt?: number | string) => string;
Synchronously generates a hash for the given string.
Parameter s
String to hash
Parameter salt
Salt length to generate or salt to use, default to 10 Resulting hash
function setRandomFallback
setRandomFallback: (random: (random: number) => number[]) => void;
Sets the pseudo random number generator to use as a fallback if neither node's crypto module nor the Web Crypto API is available. Please note: It is highly important that the PRNG used is cryptographically secure and that it is seeded properly!
Parameter random
Function taking the number of bytes to generate as its sole argument, returning the corresponding array of cryptographically secure random byte values.
Package Files (1)
Dependencies (0)
No dependencies.
Dev Dependencies (0)
No dev dependencies.
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@types/bcryptjs
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@types/bcryptjs)
- HTML<a href="https://www.jsdocs.io/package/@types/bcryptjs"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 3249 ms. - Missing or incorrect documentation? Open an issue for this package.