randBitsSync
This commit is contained in:
parent
7e792b5e2e
commit
c89d507a64
|
@ -150,6 +150,7 @@ The sync version is NOT RECOMMENDED since it won't use workers and thus it&#
|
||||||
</dd>
|
</dd>
|
||||||
<dt><a href="#randBits">randBits(bitLength, [forceLength])</a> ⇒ <code>Promise.<(Buffer|Uint8Array)></code></dt>
|
<dt><a href="#randBits">randBits(bitLength, [forceLength])</a> ⇒ <code>Promise.<(Buffer|Uint8Array)></code></dt>
|
||||||
<dd><p>Secure random bits for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues()</p>
|
<dd><p>Secure random bits for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues()</p>
|
||||||
|
<p>Since version 3.0.0 this is an async function and a new randBitsSync function has been added. If you are migrating from version 2 call randBitsSync instead.</p>
|
||||||
</dd>
|
</dd>
|
||||||
<dt><a href="#randBitsSync">randBitsSync(bitLength, [forceLength])</a> ⇒ <code>Buffer</code> | <code>Uint8Array</code></dt>
|
<dt><a href="#randBitsSync">randBitsSync(bitLength, [forceLength])</a> ⇒ <code>Buffer</code> | <code>Uint8Array</code></dt>
|
||||||
<dd><p>Secure random bits for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues()</p>
|
<dd><p>Secure random bits for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues()</p>
|
||||||
|
@ -363,8 +364,11 @@ Returns a cryptographically secure random integer between [min,max]
|
||||||
### randBits(bitLength, [forceLength]) ⇒ <code>Promise.<(Buffer\|Uint8Array)></code>
|
### randBits(bitLength, [forceLength]) ⇒ <code>Promise.<(Buffer\|Uint8Array)></code>
|
||||||
Secure random bits for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues()
|
Secure random bits for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues()
|
||||||
|
|
||||||
|
Since version 3.0.0 this is an async function and a new randBitsSync function has been added. If you are migrating from version 2 call randBitsSync instead.
|
||||||
|
|
||||||
**Kind**: global function
|
**Kind**: global function
|
||||||
**Returns**: <code>Promise.<(Buffer\|Uint8Array)></code> - A Promise that resolves to a Buffer/UInt8Array (Node.js/Browser) filled with cryptographically secure random bits
|
**Returns**: <code>Promise.<(Buffer\|Uint8Array)></code> - A Promise that resolves to a Buffer/UInt8Array (Node.js/Browser) filled with cryptographically secure random bits
|
||||||
|
**Since**: 3.0.0
|
||||||
|
|
||||||
| Param | Type | Default | Description |
|
| Param | Type | Default | Description |
|
||||||
| --- | --- | --- | --- |
|
| --- | --- | --- | --- |
|
||||||
|
@ -378,6 +382,7 @@ Secure random bits for both node and browsers. Node version uses crypto.randomFi
|
||||||
|
|
||||||
**Kind**: global function
|
**Kind**: global function
|
||||||
**Returns**: <code>Buffer</code> \| <code>Uint8Array</code> - A Buffer/UInt8Array (Node.js/Browser) filled with cryptographically secure random bits
|
**Returns**: <code>Buffer</code> \| <code>Uint8Array</code> - A Buffer/UInt8Array (Node.js/Browser) filled with cryptographically secure random bits
|
||||||
|
**Since**: 3.0.0
|
||||||
|
|
||||||
| Param | Type | Default | Description |
|
| Param | Type | Default | Description |
|
||||||
| --- | --- | --- | --- |
|
| --- | --- | --- | --- |
|
||||||
|
|
|
@ -348,6 +348,8 @@ function randBetween (max, min = 1n) {
|
||||||
/**
|
/**
|
||||||
* Secure random bits for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues()
|
* Secure random bits for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues()
|
||||||
*
|
*
|
||||||
|
* Since version 3.0.0 this is an async function and a new randBitsSync function has been added. If you are migrating from version 2 call randBitsSync instead.
|
||||||
|
* @since 3.0.0
|
||||||
* @param {number} bitLength The desired number of random bits
|
* @param {number} bitLength The desired number of random bits
|
||||||
* @param {boolean} [forceLength = false] If we want to force the output to have a specific bit length. It basically forces the msb to be 1
|
* @param {boolean} [forceLength = false] If we want to force the output to have a specific bit length. It basically forces the msb to be 1
|
||||||
*
|
*
|
||||||
|
@ -375,7 +377,7 @@ async function randBits (bitLength, forceLength = false) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Secure random bits for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues()
|
* Secure random bits for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues()
|
||||||
*
|
* @since 3.0.0
|
||||||
* @param {number} bitLength The desired number of random bits
|
* @param {number} bitLength The desired number of random bits
|
||||||
* @param {boolean} [forceLength = false] If we want to force the output to have a specific bit length. It basically forces the msb to be 1
|
* @param {boolean} [forceLength = false] If we want to force the output to have a specific bit length. It basically forces the msb to be 1
|
||||||
*
|
*
|
||||||
|
|
|
@ -140,6 +140,8 @@ function randBetween (max, min = 1n) {
|
||||||
/**
|
/**
|
||||||
* Secure random bits for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues()
|
* Secure random bits for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues()
|
||||||
*
|
*
|
||||||
|
* Since version 3.0.0 this is an async function and a new randBitsSync function has been added. If you are migrating from version 2 call randBitsSync instead.
|
||||||
|
* @since 3.0.0
|
||||||
* @param {number} bitLength The desired number of random bits
|
* @param {number} bitLength The desired number of random bits
|
||||||
* @param {boolean} [forceLength = false] If we want to force the output to have a specific bit length. It basically forces the msb to be 1
|
* @param {boolean} [forceLength = false] If we want to force the output to have a specific bit length. It basically forces the msb to be 1
|
||||||
*
|
*
|
||||||
|
@ -167,7 +169,7 @@ async function randBits (bitLength, forceLength = false) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Secure random bits for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues()
|
* Secure random bits for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues()
|
||||||
*
|
* @since 3.0.0
|
||||||
* @param {number} bitLength The desired number of random bits
|
* @param {number} bitLength The desired number of random bits
|
||||||
* @param {boolean} [forceLength = false] If we want to force the output to have a specific bit length. It basically forces the msb to be 1
|
* @param {boolean} [forceLength = false] If we want to force the output to have a specific bit length. It basically forces the msb to be 1
|
||||||
*
|
*
|
||||||
|
|
|
@ -158,6 +158,8 @@ function randBetween (max, min = 1n) {
|
||||||
/**
|
/**
|
||||||
* Secure random bits for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues()
|
* Secure random bits for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues()
|
||||||
*
|
*
|
||||||
|
* Since version 3.0.0 this is an async function and a new randBitsSync function has been added. If you are migrating from version 2 call randBitsSync instead.
|
||||||
|
* @since 3.0.0
|
||||||
* @param {number} bitLength The desired number of random bits
|
* @param {number} bitLength The desired number of random bits
|
||||||
* @param {boolean} [forceLength = false] If we want to force the output to have a specific bit length. It basically forces the msb to be 1
|
* @param {boolean} [forceLength = false] If we want to force the output to have a specific bit length. It basically forces the msb to be 1
|
||||||
*
|
*
|
||||||
|
@ -185,7 +187,7 @@ async function randBits (bitLength, forceLength = false) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Secure random bits for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues()
|
* Secure random bits for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues()
|
||||||
*
|
* @since 3.0.0
|
||||||
* @param {number} bitLength The desired number of random bits
|
* @param {number} bitLength The desired number of random bits
|
||||||
* @param {boolean} [forceLength = false] If we want to force the output to have a specific bit length. It basically forces the msb to be 1
|
* @param {boolean} [forceLength = false] If we want to force the output to have a specific bit length. It basically forces the msb to be 1
|
||||||
*
|
*
|
||||||
|
|
|
@ -181,6 +181,8 @@ export function randBetween (max, min = 1n) {
|
||||||
/**
|
/**
|
||||||
* Secure random bits for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues()
|
* Secure random bits for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues()
|
||||||
*
|
*
|
||||||
|
* Since version 3.0.0 this is an async function and a new randBitsSync function has been added. If you are migrating from version 2 call randBitsSync instead.
|
||||||
|
* @since 3.0.0
|
||||||
* @param {number} bitLength The desired number of random bits
|
* @param {number} bitLength The desired number of random bits
|
||||||
* @param {boolean} [forceLength = false] If we want to force the output to have a specific bit length. It basically forces the msb to be 1
|
* @param {boolean} [forceLength = false] If we want to force the output to have a specific bit length. It basically forces the msb to be 1
|
||||||
*
|
*
|
||||||
|
@ -208,7 +210,7 @@ export async function randBits (bitLength, forceLength = false) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Secure random bits for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues()
|
* Secure random bits for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues()
|
||||||
*
|
* @since 3.0.0
|
||||||
* @param {number} bitLength The desired number of random bits
|
* @param {number} bitLength The desired number of random bits
|
||||||
* @param {boolean} [forceLength = false] If we want to force the output to have a specific bit length. It basically forces the msb to be 1
|
* @param {boolean} [forceLength = false] If we want to force the output to have a specific bit length. It basically forces the msb to be 1
|
||||||
*
|
*
|
||||||
|
|
|
@ -135,6 +135,8 @@ export function randBetween(max: bigint, min?: bigint): bigint;
|
||||||
/**
|
/**
|
||||||
* Secure random bits for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues()
|
* Secure random bits for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues()
|
||||||
*
|
*
|
||||||
|
* Since version 3.0.0 this is an async function and a new randBitsSync function has been added. If you are migrating from version 2 call randBitsSync instead.
|
||||||
|
* @since 3.0.0
|
||||||
* @param {number} bitLength The desired number of random bits
|
* @param {number} bitLength The desired number of random bits
|
||||||
* @param {boolean} [forceLength = false] If we want to force the output to have a specific bit length. It basically forces the msb to be 1
|
* @param {boolean} [forceLength = false] If we want to force the output to have a specific bit length. It basically forces the msb to be 1
|
||||||
*
|
*
|
||||||
|
@ -143,7 +145,7 @@ export function randBetween(max: bigint, min?: bigint): bigint;
|
||||||
export function randBits(bitLength: number, forceLength?: boolean): Promise<Uint8Array | Buffer>;
|
export function randBits(bitLength: number, forceLength?: boolean): Promise<Uint8Array | Buffer>;
|
||||||
/**
|
/**
|
||||||
* Secure random bits for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues()
|
* Secure random bits for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues()
|
||||||
*
|
* @since 3.0.0
|
||||||
* @param {number} bitLength The desired number of random bits
|
* @param {number} bitLength The desired number of random bits
|
||||||
* @param {boolean} [forceLength = false] If we want to force the output to have a specific bit length. It basically forces the msb to be 1
|
* @param {boolean} [forceLength = false] If we want to force the output to have a specific bit length. It basically forces the msb to be 1
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue