### Install StableLib Base64 Package Source: https://www.stablelib.com/index.html Install the base64 package from StableLib using npm. This is a common starting point for using StableLib functionalities. ```bash npm install @stablelib/base64 Copy ``` -------------------------------- ### Poly1305.finish Source: https://www.stablelib.com/classes/_stablelib_poly1305.Poly1305.html Finalizes the Poly1305 computation and writes the resulting authentication tag into a provided buffer. It can optionally take a starting position for writing. ```APIDOC ## finish ### Description Finalizes the authentication tag computation and writes it to a buffer. ### Parameters * **mac** (Uint8Array) - The buffer where the computed authentication tag will be written. * **macpos** (number, optional) - The starting position within the `mac` buffer to write the tag. Defaults to 0. ### Returns this - The current Poly1305 instance, allowing for method chaining. ``` -------------------------------- ### constructor Source: https://www.stablelib.com/classes/_stablelib_xchacha20poly1305.XChaCha20Poly1305.html Creates a new instance of XChaCha20Poly1305 with a given 32-byte key. ```APIDOC ## constructor ### Description Creates a new instance with the given 32-byte key. ### Parameters * **key** (Uint8Array) - The 32-byte secret key. ### Returns XChaCha20Poly1305 - A new instance of the XChaCha20Poly1305 class. ``` -------------------------------- ### SIV Constructor Source: https://www.stablelib.com/classes/_stablelib_siv.SIV.html Initializes a new SIV instance with a specified cipher and key. This is used to set up the authenticated encryption context. ```APIDOC ## constructor ### Description Initializes a new SIV instance. ### Parameters * **cipher**: BlockCipherContructor - The block cipher constructor to use. * **key**: Uint8Array - The secret key for encryption and decryption. ### Returns * **SIV** - A new instance of the SIV class. ``` -------------------------------- ### CBORForbiddenKeyError.key Property Source: https://www.stablelib.com/classes/_stablelib_cbor.CBORForbiddenKeyError.html Gets the forbidden key that caused the CBORForbiddenKeyError. ```APIDOC ## Property key ### Description Represents the forbidden key that was encountered during CBOR decoding, leading to this error. ### Type string ``` -------------------------------- ### URLSafeCoder Constructor Source: https://www.stablelib.com/classes/_stablelib_base64.URLSafeCoder.html Initializes a new instance of the URLSafeCoder class. Optionally accepts a padding character. ```APIDOC ## constructor ### Description Initializes a new instance of the URLSafeCoder class. ### Signature `new URLSafeCoder(_paddingCharacter?: string): URLSafeCoder` ### Parameters * `_paddingCharacter` (string) - Optional - The character to use for padding. Defaults to "=". ### Returns A new instance of URLSafeCoder. ``` -------------------------------- ### Get Shared Key Method Source: https://www.stablelib.com/interfaces/_stablelib_keyagreement.KeyAgreement.html Retrieves the agreed-upon shared key. Should be called after accept() or finish(). ```typescript getSharedKey(): Uint8Array ``` -------------------------------- ### readUint32LE Source: https://www.stablelib.com/functions/_stablelib_binary.readUint32LE.html Reads a 4-byte unsigned 32-bit integer from a Uint8Array in little-endian format, starting at a specified offset. ```APIDOC ## readUint32LE ### Description Reads 4 bytes from an array starting at the specified offset and interprets them as a little-endian unsigned 32-bit integer. ### Method `readUint32LE(array, offset)` ### Parameters #### Path Parameters * **array** (Uint8Array) - The byte array to read from. * **offset** (number) - Optional. The starting offset in the array. Defaults to 0. ### Returns * **number** - The unsigned 32-bit integer read from the array. ``` -------------------------------- ### Coder Constructor Source: https://www.stablelib.com/classes/_stablelib_base64.Coder.html Initializes a new Coder instance. Optionally accepts a padding character. ```APIDOC ## constructor ### Description Initializes a new Coder instance. Optionally accepts a padding character. ### Signature `new Coder(_paddingCharacter?): Coder` ### Parameters * `_paddingCharacter` (string) - Optional - The character to use for padding. Defaults to "=". ### Returns A new Coder instance. ``` -------------------------------- ### readUint32BE Source: https://www.stablelib.com/functions/_stablelib_binary.readUint32BE.html Reads 4 bytes from an array starting at a specified offset as a big-endian unsigned 32-bit integer. ```APIDOC ## Function readUint32BE ### Description Reads 4 bytes from `array` starting at `offset` as a big-endian unsigned 32-bit integer and returns it. ### Parameters * **array** (Uint8Array) - The array to read from. * **offset** (number) - Optional. The starting offset in the array. Defaults to 0. ### Returns * **number** - The unsigned 32-bit integer read from the array. ``` -------------------------------- ### ChaCha20Poly1305 Constructor Source: https://www.stablelib.com/classes/_stablelib_chacha20poly1305.ChaCha20Poly1305.html Creates a new instance of ChaCha20Poly1305 with a given 32-byte key. ```APIDOC ## constructor ### Description Creates a new instance with the given 32-byte key. ### Parameters * **key** (Uint8Array) - The 32-byte secret key. ### Returns ChaCha20Poly1305 - A new instance of the ChaCha20Poly1305 class. ``` -------------------------------- ### readInt32LE Source: https://www.stablelib.com/functions/_stablelib_binary.readInt32LE.html Reads 4 bytes from an array starting at a specified offset as a little-endian signed 32-bit integer. ```APIDOC ## Function readInt32LE ### Description Reads 4 bytes from an array starting at the specified offset as a little-endian signed 32-bit integer and returns it. ### Signature `readInt32LE(array, offset?): number` ### Parameters * **array** (Uint8Array) - The array to read from. * **offset** (number) - Optional. The starting offset in the array. Defaults to 0. ### Returns * **number** - The 32-bit signed integer read from the array. ``` -------------------------------- ### readFloat32LE Source: https://www.stablelib.com/functions/_stablelib_binary.readFloat32LE.html Reads 4 bytes from a Uint8Array starting at a specified offset as a little-endian 32-bit floating-point number. ```APIDOC ## readFloat32LE ### Description Reads 4 bytes from the given `Uint8Array` starting at the specified `offset` and interprets them as a little-endian 32-bit floating-point number. ### Signature `readFloat32LE(array: Uint8Array, offset?: number): number` ### Parameters #### Parameters - **array** (Uint8Array) - The array to read from. - **offset** (number) - Optional. The starting offset in the array. Defaults to 0. ### Returns - **number** - The 32-bit little-endian floating-point number read from the array. ``` -------------------------------- ### SHA384 Constructor Source: https://www.stablelib.com/classes/_stablelib_sha384.SHA384.html Initializes a new instance of the SHA384 class. ```APIDOC ## constructor ### Description Initializes a new instance of the SHA384 class. ### Returns SHA384 - A new SHA384 instance. ``` -------------------------------- ### readFloat32BE Source: https://www.stablelib.com/functions/_stablelib_binary.readFloat32BE.html Reads 4 bytes from an array starting at a specified offset as a big-endian 32-bit floating-point number. ```APIDOC ## readFloat32BE ### Description Reads 4 bytes from an array starting at offset as a big-endian 32-bit floating-point number and returns it. ### Parameters #### Parameters - **array** (Uint8Array) - The Uint8Array to read from. - **offset** (number) - Optional. The starting offset in the array. Defaults to 0. ### Returns - **number** - The 32-bit big-endian floating-point number read from the array. ``` -------------------------------- ### Simple Constructor Source: https://www.stablelib.com/classes/_stablelib_cbor.Simple.html Constructs a new Simple instance. Simple values are predefined or assigned by the IANA "CBOR Simple Values" registry. ```APIDOC ## new Simple(value): Simple ### Description Constructs a new Simple instance with the given numeric value. ### Parameters #### Path Parameters * **value** (number) - Description: The numeric value for the Simple instance. ``` -------------------------------- ### readInt16LE Source: https://www.stablelib.com/functions/_stablelib_binary.readInt16LE.html Reads 2 bytes from an array starting at a specified offset as a little-endian signed 16-bit integer. ```APIDOC ## readInt16LE ### Description Reads 2 bytes from an array starting at offset as little-endian signed 16-bit integer and returns it. ### Parameters #### Path Parameters * None #### Query Parameters * None #### Request Body * None ### Method * None (Function Signature) ### Endpoint * None (Function Signature) ### Parameters #### Parameters - **array** (Uint8Array) - Required - The Uint8Array to read from. - **offset** (number) - Optional - The starting offset in the array. Defaults to 0. ### Returns * **number** - The 16-bit signed integer read from the array. ``` -------------------------------- ### Keccak Constructor Source: https://www.stablelib.com/classes/_stablelib_sha3.Keccak.html Initializes a new Keccak instance. The capacity can be optionally specified. ```APIDOC ## constructor ### Description Initializes a new Keccak instance. The capacity can be optionally specified. ### Method constructor ### Parameters #### Path Parameters * **capacity** (number) - Optional - The capacity of the Keccak instance. Defaults to 32. ### Returns * **Keccak** - A new Keccak instance. ``` -------------------------------- ### readInt16BE Source: https://www.stablelib.com/functions/_stablelib_binary.readInt16BE.html Reads 2 bytes from an array starting at the specified offset as a big-endian signed 16-bit integer. ```APIDOC ## Function readInt16BE ### Description Reads 2 bytes from `array` starting at `offset` as a big-endian signed 16-bit integer and returns it. ### Signature `readInt16BE(array, offset?): number` ### Parameters #### `array` - Type: `Uint8Array` - Description: The byte array to read from. #### `offset` - Type: `number` - Default: `0` - Description: The starting offset in the array. ### Returns - Type: `number` - Description: The signed 16-bit integer read from the array. ``` -------------------------------- ### SHA3256 Constructor Source: https://www.stablelib.com/classes/_stablelib_sha3.SHA3256.html Initializes a new instance of the SHA3256 hash function. ```APIDOC ## SHA3256 Constructor ### Description Initializes a new instance of the SHA3256 hash function. ### Method constructor ### Returns SHA3256 - A new instance of the SHA3256 class. ``` -------------------------------- ### readFloat64BE Source: https://www.stablelib.com/functions/_stablelib_binary.readFloat64BE.html Reads 8 bytes from an array starting at a specified offset as a big-endian 64-bit floating-point number. ```APIDOC ## Function readFloat64BE ### Description Reads 8 bytes from `array` starting at `offset` as a big-endian 64-bit floating-point number ("double") and returns it. ### Parameters #### Parameters - **array** (Uint8Array) - Required - The Uint8Array to read from. - **offset** (number) - Optional - The starting offset in the array. Defaults to 0. ### Returns - **number** - The 64-bit big-endian floating-point number read from the array. ``` -------------------------------- ### HKDF Constructor Source: https://www.stablelib.com/classes/_stablelib_hkdf.HKDF.html Creates a new HKDF instance for a given hash function with a master key, optional salt, and info. The master key should be high-entropy, salt should be a non-secret random value, and info is application-specific context. ```APIDOC ## new HKDF(hash, key, salt?, info?) ### Description Create a new HKDF instance for the given hash function with the master key, optional salt, and info. * Master key is a high-entropy secret key (not a password). * Salt is a non-secret random value. * Info is application- and/or context-specific information. ### Parameters * **hash**: (new () => Hash) * **new ()**: Hash * #### Returns Hash * **key**: Uint8Array * **salt**: Uint8Array (Optional) * **info**: Uint8Array (Optional) ### Returns HKDF ``` -------------------------------- ### readInt32BE Source: https://www.stablelib.com/functions/_stablelib_binary.readInt32BE.html Reads 4 bytes from a Uint8Array starting at a specified offset, interpreting them as a big-endian signed 32-bit integer. ```APIDOC ## readInt32BE ### Description Reads 4 bytes from an array starting at the specified offset as a big-endian signed 32-bit integer and returns it. ### Parameters #### Parameters - **array** (Uint8Array) - The byte array to read from. - **offset** (number) - Optional. The starting offset in the array. Defaults to 0. ### Returns - **number** - The signed 32-bit integer read from the array. ``` -------------------------------- ### compress(src, dst?) Source: https://www.stablelib.com/functions/_stablelib_snappy.compress.html Compresses source data into a destination buffer using the Snappy algorithm. If the destination buffer is not provided or is too small, it will be automatically allocated. The function returns a view into the destination buffer containing the compressed data. It does not automatically store the original data length, which must be handled by the caller. An error is thrown if the input data exceeds the maximum compressed length. ```APIDOC ## compress(src, dst?) ### Description Compresses source data into a destination buffer using the Snappy algorithm. If the destination buffer is not provided or is too small, it will be automatically allocated. The function returns a view into the destination buffer containing the compressed data. It does not automatically store the original data length, which must be handled by the caller. An error is thrown if the input data exceeds the maximum compressed length. ### Parameters #### Path Parameters * None #### Query Parameters * None #### Request Body * None ### Method * Not Applicable (SDK Function) ### Endpoint * Not Applicable (SDK Function) ### Returns * **Uint8Array**: A subarray of `dst` containing the compressed data. ``` -------------------------------- ### readFloat64LE Source: https://www.stablelib.com/functions/_stablelib_binary.readFloat64LE.html Reads 8 bytes from an array starting at a specified offset as a little-endian 64-bit floating-point number (double) and returns it. ```APIDOC ## Function readFloat64LE ### Description Reads 8 bytes from `array` starting at `offset` as a little-endian 64-bit floating-point number ("double") and returns it. ### Parameters #### Parameters - **array** (Uint8Array) - Required - The Uint8Array to read from. - **offset** (number) - Optional - The starting offset in the array. Defaults to 0. ### Returns - **number** - The 64-bit floating-point number read from the array. ``` -------------------------------- ### SHA512_256 Constructor Source: https://www.stablelib.com/classes/_stablelib_sha512_256.SHA512_256.html Initializes a new instance of the SHA512_256 class. ```APIDOC ## SHA512_256 Constructor ### Description Initializes a new instance of the SHA512_256 class. ### Method constructor ### Returns SHA512_256 ``` -------------------------------- ### Scrypt Constructor Source: https://www.stablelib.com/classes/_stablelib_scrypt.Scrypt.html Initializes a new instance of the Scrypt class with specified parameters for the scrypt algorithm. ```APIDOC ## constructor ### Description Initializes a new instance of the Scrypt class. ### Parameters * **N** (number) - The N parameter for the scrypt algorithm. * **r** (number) - The r parameter for the scrypt algorithm. * **p** (number) - The p parameter for the scrypt algorithm. ### Returns * **Scrypt** - A new Scrypt instance. ``` -------------------------------- ### byteSeq Function Source: https://www.stablelib.com/functions/_stablelib_benchmark.byteSeq.html Generates a Uint8Array of a specified length containing a sequence of bytes (0-255) that repeats. An optional starting byte can be provided to offset the sequence. ```APIDOC ## Function byteSeq ### Description Returns a Uint8Array of the given length containing sequence of bytes 0, 1, 2 ... 255, 0, 1, 2, ... If the start byte is given, the sequence starts from it. ### Parameters #### Path Parameters - **length** (number) - Required - The desired length of the Uint8Array. - **start** (number) - Optional - The byte value to start the sequence from. Defaults to 0. ### Returns - **Uint8Array** - A Uint8Array containing the generated byte sequence. ``` -------------------------------- ### offer Source: https://www.stablelib.com/classes/_stablelib_x25519_session.X25519Session.html Generates and returns an offer message to initiate the key agreement process. ```APIDOC ## offer ### Description Generates and returns a new offer message. This message should be sent to the accepting party to initiate the key agreement process. ### Signature `offer(): Uint8Array` ### Returns * `Uint8Array` - The offer message. ``` -------------------------------- ### SHAKE Constructor Source: https://www.stablelib.com/classes/_stablelib_sha3.SHAKE.html Initializes a new instance of the SHAKE class. The bitSize parameter determines the variant (e.g., 128 or 256). ```APIDOC ## constructor ### Description Initializes a new SHAKE instance. ### Parameters * **bitSize** (number) - The desired bit size for the hash function (e.g., 128 or 256). ### Returns * **SHAKE** - A new SHAKE instance. ``` -------------------------------- ### writeUint32LE Source: https://www.stablelib.com/functions/_stablelib_binary.writeUint32LE.html Writes the 4-byte little-endian representation of a 32-bit unsigned value to a byte array, starting at a specified offset. If no byte array is provided, a new one is created. ```APIDOC ## Function writeUint32LE ### Description Writes the 4-byte little-endian representation of a 32-bit unsigned value to a byte array, starting at a specified offset. If no byte array is provided, a new one is created. Returns the output byte array. ### Signature writeUint32LE(value: number, out?: Uint8Array, offset?: number): Uint8Array ### Parameters #### Parameters - **value** (number) - The 32-bit unsigned value to write. - **out** (Uint8Array, optional) - The byte array to write to. If not provided, a new 4-byte array is created. - **offset** (number, optional) - The offset in the byte array where the value should be written. Defaults to 0. ### Returns - **Uint8Array** - The output byte array with the value written. ``` -------------------------------- ### Offer Method Source: https://www.stablelib.com/interfaces/_stablelib_keyagreement.KeyAgreement.html Generates and returns a new offer message to be sent to the accepting party. ```typescript offer(): Uint8Array ``` -------------------------------- ### readUintBE Source: https://www.stablelib.com/functions/_stablelib_binary.readUintBE.html Reads bytes from an array starting at a specified offset as a big-endian unsigned integer of a given bit length. Supports bit lengths divisible by 8, up to 48. ```APIDOC ## readUintBE ### Description Reads bytes from an array starting at offset as big-endian unsigned bitLen-bit integer and returns it. Supports bit lengths divisible by 8, up to 48. ### Signature `readUintBE(bitLength, array, offset?): number` ### Parameters #### Parameters - **bitLength** (number) - The desired bit length of the integer to read. Must be divisible by 8, up to 48. - **array** (Uint8Array) - The array to read bytes from. - **offset** (number) - Optional. The starting offset in the array. Defaults to 0. ### Returns - **number** - The unsigned integer read from the array. ``` -------------------------------- ### readUintLE Source: https://www.stablelib.com/functions/_stablelib_binary.readUintLE.html Reads bytes from an array starting at a specified offset as a little-endian unsigned integer of a given bit length. Supports bit lengths divisible by 8, up to 48. ```APIDOC ## readUintLE ### Description Reads bytes from an array starting at a specified offset as a little-endian unsigned integer of a given bit length. Supports bit lengths divisible by 8, up to 48. ### Parameters #### Parameters - **bitLength** (number) - Required - The desired bit length of the integer to read. Must be divisible by 8, up to 48. - **array** (Uint8Array) - Required - The array to read bytes from. - **offset** (number) - Optional - The starting offset in the array. Defaults to 0. ### Returns number - The read little-endian unsigned integer. ``` -------------------------------- ### ByteWriter Constructor Source: https://www.stablelib.com/classes/_stablelib_bytewriter.ByteWriter.html Creates a new ByteWriter instance. Optionally, an initial capacity can be provided to pre-allocate memory. ```APIDOC ## constructor ### Description Creates a new ByteWriter with the optional initial capacity. ### Parameters * **initialCapacity** (number) - Optional - The initial capacity for the ByteWriter. Defaults to MIN_CAPACITY. ### Returns * ByteWriter - A new instance of ByteWriter. ``` -------------------------------- ### X25519Session Constructor Source: https://www.stablelib.com/classes/_stablelib_x25519_session.X25519Session.html Initializes a new X25519Session instance. You can optionally provide a secret seed and a pseudo-random number generator. ```APIDOC ## constructor ### Description Initializes a new X25519Session instance. You can optionally provide a secret seed and a pseudo-random number generator. ### Signature `new X25519Session(secretSeed?, prng?): X25519Session` ### Parameters * `secretSeed` (Uint8Array) - Optional. The secret seed for the session. * `prng` (RandomSource) - Optional. The pseudo-random number generator to use. ``` -------------------------------- ### readUint64BE Source: https://www.stablelib.com/functions/_stablelib_binary.readUint64BE.html Reads 8 bytes from an array starting at a specified offset as a big-endian unsigned 64-bit integer. Note: Due to JavaScript limitations, it supports values up to 2^53-1. ```APIDOC ## readUint64BE ### Description Reads 8 bytes from `array` starting at `offset` as a big-endian unsigned 64-bit integer. Supports values up to 2^53-1 due to JavaScript limitations. ### Parameters #### Path Parameters * None #### Query Parameters * None #### Request Body * None ### Parameters * **array** (Uint8Array) - The array to read from. * **offset** (number) - Optional. The starting offset in the array. Defaults to 0. ### Returns * **number** - The 64-bit unsigned integer read from the array. ``` -------------------------------- ### BLAKE2Xs Methods Source: https://www.stablelib.com/classes/_stablelib_blake2xs.BLAKE2Xs.html Provides methods for managing the hashing process, including cleaning, digesting, resetting, streaming, and updating the hash state. ```APIDOC ## Methods ### clean * **Signature**: `clean(): void` * **Description**: Resets the internal state of the hash function, discarding any accumulated data. * **Returns**: void ### digest * **Signature**: `digest(): Uint8Array` * **Description**: Computes the final hash digest from the accumulated data. * **Returns**: Uint8Array - The computed hash digest. ### reset * **Signature**: `reset(): this` * **Description**: Resets the hash function to its initial state, allowing for a new hash computation. * **Returns**: this - The current BLAKE2Xs instance for chaining. ### stream * **Signature**: `stream(dst: Uint8Array): this` * **Description**: Writes the current hash state to a destination array. This is typically used for incremental hashing. * **Parameters**: * `dst` (Uint8Array) - The destination array to write the hash state to. * **Returns**: this - The current BLAKE2Xs instance for chaining. ### update * **Signature**: `update(data: Uint8Array, dataLength?: number): this` * **Description**: Updates the hash state with the provided data. The `dataLength` parameter can be used to specify the length of the data to process, defaulting to the entire array length. * **Parameters**: * `data` (Uint8Array) - The data to update the hash with. * `dataLength` (number) - Optional - The length of the data to process. Defaults to `data.length`. * **Returns**: this - The current BLAKE2Xs instance for chaining. ``` -------------------------------- ### readInt64LE Source: https://www.stablelib.com/functions/_stablelib_binary.readInt64LE.html Reads 8 bytes from an array starting at the specified offset as a little-endian signed 64-bit integer. Note: JavaScript's number limitations may affect precision for very large or small numbers. ```APIDOC ## readInt64LE ### Description Reads 8 bytes from an array starting at the specified offset as a little-endian signed 64-bit integer. Due to JavaScript limitations, it supports exact numbers in the range -9007199254740991 to 9007199254740991. Numbers outside this range may not be exact. ### Parameters #### Path Parameters * None #### Query Parameters * None #### Request Body * None ### Method * Not applicable (SDK function) ### Endpoint * Not applicable (SDK function) ### Parameters #### Parameters - **array** (Uint8Array) - Required - The byte array to read from. - **offset** (number) - Optional - The starting offset in the array. Defaults to 0. ### Returns * **number** - The 64-bit signed integer read from the array. ``` -------------------------------- ### BLAKE2s Constructor Source: https://www.stablelib.com/classes/_stablelib_blake2s.BLAKE2s.html Initializes a new BLAKE2s hash object. The digest length can be specified, and an optional configuration can be provided. ```APIDOC ## constructor ### Description Initializes a new BLAKE2s hash object. ### Signature `new BLAKE2s(digestLength?: number, config?: Config): BLAKE2s` ### Parameters * `digestLength` (number) - Optional - The desired length of the hash digest. Defaults to 32. * `config` (Config) - Optional - Configuration options for the BLAKE2s algorithm. ``` -------------------------------- ### writeInt32LE Source: https://www.stablelib.com/functions/_stablelib_binary.writeInt32LE.html Writes the 4-byte little-endian representation of a 32-bit unsigned value to an array, starting at the specified offset. If no byte array is provided, a new 4-byte array is created. The function returns the output byte array. ```APIDOC ## writeInt32LE ### Description Writes a 4-byte little-endian representation of a 32-bit unsigned value to an array, starting at the specified offset. If no byte array is provided, a new 4-byte array is created. The function returns the output byte array. ### Method Not Applicable (SDK Function) ### Signature `writeInt32LE(value: number, out?: Uint8Array, offset?: number): Uint8Array` ### Parameters #### Parameters - **value** (number) - Required - The 32-bit unsigned value to write. - **out** (Uint8Array) - Optional - The byte array to write to. If not provided, a new array is created. - **offset** (number) - Optional - The starting offset in the byte array. Defaults to 0. ### Returns - **Uint8Array** - The output byte array with the value written. ``` -------------------------------- ### writeUint16LE Source: https://www.stablelib.com/functions/_stablelib_binary.writeUint16LE.html Writes a 2-byte little-endian representation of a 16-bit unsigned value to an array starting at the specified offset. If no byte array is provided, a new 2-byte array is created. The function returns the output byte array. ```APIDOC ## Function writeUint16LE ### Description Writes a 2-byte little-endian representation of a 16-bit unsigned value to an array starting at the specified offset. If no byte array is provided, a new 2-byte array is created. The function returns the output byte array. ### Signature `writeUint16LE(value: number, out?: Uint8Array, offset?: number): Uint8Array` ### Parameters #### Parameters * `value` (number) - The 16-bit unsigned value to write. * `out` (Uint8Array, optional) - The byte array to write to. If not provided, a new array is created. * `offset` (number, optional) - The starting offset in the array to write the value. Defaults to 0. ### Returns * `Uint8Array` - The output byte array with the value written. ``` -------------------------------- ### Poly1305 Constructor Source: https://www.stablelib.com/classes/_stablelib_poly1305.Poly1305.html Initializes a new Poly1305 instance with a secret key. The key should be used for only one message and must never be repeated. ```APIDOC ## constructor ### Description Initializes a new Poly1305 instance. ### Parameters * **key** (Uint8Array) - The 32-byte secret key for authentication. This key must be unique for each message. ### Returns Poly1305 - A new instance of the Poly1305 class. ``` -------------------------------- ### writeInt16LE Source: https://www.stablelib.com/functions/_stablelib_binary.writeInt16LE.html Writes the 2-byte little-endian representation of a 16-bit unsigned value to an array, starting at the specified offset. If no array is provided, a new 2-byte array is created. The function returns the modified or newly created byte array. ```APIDOC ## writeInt16LE ### Description Writes a 2-byte little-endian representation of a 16-bit unsigned value to an array starting at the specified offset. If the byte array is not provided, a new 2-byte array is created. Returns the output byte array. ### Signature `writeInt16LE(value: number, out?: Uint8Array, offset?: number): Uint8Array` ### Parameters #### Parameters * **value** (number) - The 16-bit unsigned value to write. * **out** (Uint8Array, optional) - The byte array to write to. If not provided, a new array is created. * **offset** (number, optional) - The offset in the array to start writing at. Defaults to 0. ### Returns * **Uint8Array** - The output byte array with the value written. ``` -------------------------------- ### stream(key, nonce, dst, nonceInplaceCounterLength?) Source: https://www.stablelib.com/functions/_stablelib_salsa20.stream.html Generates a Salsa20/20 stream for a given 32-byte key and 8-byte nonce, writing the output to the provided destination buffer. It's crucial to never reuse the same key and nonce combination for generating multiple streams. The `nonceInplaceCounterLength` parameter modifies the nonce behavior, similar to the `streamXOR` function's documentation. This function is equivalent to `streamXOR` when the source is all zeros. ```APIDOC ## Function stream ### Description Generates a Salsa20/20 stream for the given 32-byte key and 8-byte nonce and writes it into `dst`. This function should never be used with the same key and nonce combination more than once. If `nonceInplaceCounterLength` is non-zero, the nonce behavior is altered as described in the `streamXOR` documentation. The `stream` function is analogous to `streamXOR` when the source data is all zeros. ### Signature `stream(key: Uint8Array, nonce: Uint8Array, dst: Uint8Array, nonceInplaceCounterLength?: number): Uint8Array` ### Parameters * `key` (Uint8Array): The 32-byte secret key for Salsa20 encryption. * `nonce` (Uint8Array): The 8-byte nonce. Must be unique for each stream generated with the same key. * `dst` (Uint8Array): The destination buffer where the generated keystream will be written. * `nonceInplaceCounterLength` (number, optional): If non-zero, modifies the nonce handling. Defaults to 0. ### Returns * `Uint8Array`: The destination buffer (`dst`) containing the generated keystream. ``` -------------------------------- ### writeFloat64LE Source: https://www.stablelib.com/functions/_stablelib_binary.writeFloat64LE.html Writes the 8-byte little-endian floating-point representation of a value to a byte array, starting at a specified offset. If no byte array is provided, a new one is created. The function returns the modified or newly created byte array. ```APIDOC ## Function writeFloat64LE ### Description Writes an 8-byte little-endian floating-point representation of a number to a byte array. ### Signature `writeFloat64LE(value: number, out?: Uint8Array, offset?: number): Uint8Array` ### Parameters * **value** (number) - The floating-point number to write. * **out** (Uint8Array, optional) - The byte array to write to. If not provided, a new 8-byte array is created. * **offset** (number, optional) - The starting offset in the byte array. Defaults to 0. ### Returns * **Uint8Array** - The output byte array containing the written float64 value. ``` -------------------------------- ### BLAKE2Xs Constructor Source: https://www.stablelib.com/classes/_stablelib_blake2xs.BLAKE2Xs.html Creates a new BLAKE2Xs instance. The digest length can be specified, or it can be left unknown to allow for variable output lengths. ```APIDOC ## constructor ### Description Creates a new BLAKE2Xs instance with the given digest length. If digest length is not given, it's considered unknown in advance, thus allowing to generate any number of bytes up to 2^32-1. ### Parameters * `digestLength` (number) - Optional - The desired length of the digest in bytes. Defaults to UNKNOWN_DIGEST_LENGTH. * `config` (Config) - Optional - Configuration options for the BLAKE2Xs instance. ### Returns BLAKE2Xs - A new instance of the BLAKE2Xs class. ``` -------------------------------- ### SHA512 Constructor Source: https://www.stablelib.com/classes/_stablelib_sha512.SHA512.html Initializes a new instance of the SHA512 class. This creates a SHA-512 cryptographic hash algorithm instance. ```APIDOC ## Constructor ### `SHA512()` Initializes a new SHA512 instance. #### Returns * SHA512: A new SHA512 object. ``` -------------------------------- ### writeUintLE Source: https://www.stablelib.com/functions/_stablelib_binary.writeUintLE.html Writes a little-endian representation of a bitLength-bit unsigned value to an array starting at a specified offset. Supports bit lengths divisible by 8, up to 48. If no byte array is provided, a new one is created. Returns the output byte array. ```APIDOC ## Function writeUintLE ### Description Writes a little-endian representation of a bitLength-bit unsigned value to an array starting at a specified offset. Supports bit lengths divisible by 8, up to 48. If no byte array is provided, a new one is created. Returns the output byte array. ### Signature writeUintLE(bitLength, value, out?, offset?): Uint8Array ### Parameters #### Parameters - **bitLength** (number) - The number of bits for the unsigned value. Must be divisible by 8 and up to 48. - **value** (number) - The unsigned value to write. - **out** (Uint8Array) - Optional. The byte array to write to. If not provided, a new Uint8Array is created. - **offset** (number) - Optional. The starting offset in the byte array. Defaults to 0. ### Returns - **Uint8Array** - The output byte array with the value written in little-endian format. ``` -------------------------------- ### writeUintBE Source: https://www.stablelib.com/functions/_stablelib_binary.writeUintBE.html Writes a big-endian representation of a bitLength-bit unsigned value to an array starting at the specified offset. Supports bit lengths divisible by 8, up to 48. If a byte array is not provided, a new one is created. Returns the output byte array. ```APIDOC ## Function writeUintBE ### Description Writes a big-endian representation of a bitLength-bit unsigned value to an array starting at the specified offset. Supports bit lengths divisible by 8, up to 48. If a byte array is not provided, a new one is created. Returns the output byte array. ### Signature `writeUintBE(bitLength, value, out?, offset?): Uint8Array` ### Parameters * **bitLength** (number) - The number of bits for the value (must be divisible by 8, up to 48). * **value** (number) - The unsigned value to write. * **out** (Uint8Array, optional) - The byte array to write to. If not provided, a new array is created. * **offset** (number, optional) - The starting offset in the array. Defaults to 0. ### Returns * **Uint8Array** - The output byte array with the value written. ``` -------------------------------- ### BLAKE2b Constructor Source: https://www.stablelib.com/classes/_stablelib_blake2b.BLAKE2b.html Initializes a new instance of the BLAKE2b hash function. You can specify the digest length and configuration options. ```APIDOC ## constructor ### Description Initializes a new instance of the BLAKE2b hash function. ### Signature `new BLAKE2b(digestLength?: number, config?: Config): BLAKE2b` ### Parameters * **digestLength** (number) - Optional. Defaults to 64. The desired length of the hash digest. * **config** (Config) - Optional. Configuration options for the BLAKE2b algorithm. ``` -------------------------------- ### writeUint32BE Source: https://www.stablelib.com/functions/_stablelib_binary.writeUint32BE.html Writes the 4-byte big-endian representation of a 32-bit unsigned value to a byte array, starting at a specified offset. If no byte array is provided, a new 4-byte array is created. The function returns the modified or newly created byte array. ```APIDOC ## Function writeUint32BE ### Description Writes a 4-byte big-endian representation of a 32-bit unsigned value to a byte array. ### Parameters * `value` (number) - The 32-bit unsigned integer to write. * `out` (Uint8Array, optional) - The byte array to write to. If not provided, a new 4-byte array is created. * `offset` (number, optional) - The starting offset in the byte array. Defaults to 0. ### Returns * Uint8Array - The output byte array with the value written. ``` -------------------------------- ### select(subject, resultIfOne, resultIfZero) Source: https://www.stablelib.com/functions/_stablelib_constant_time.select.html Returns resultIfOne if subject is 1, or resultIfZero if subject is 0. Supports only 32-bit integers, so if resultIfOne or resultIfZero are not integers, they'll be converted to them with bitwise operations. ```APIDOC ## Function select ### Description Returns `resultIfOne` if `subject` is 1, or `resultIfZero` if `subject` is 0. This function operates in constant time. It supports only 32-bit integers. If `resultIfOne` or `resultIfZero` are not integers, they will be converted to integers using bitwise operations. ### Parameters * **subject** (number) - The input number, expected to be 0 or 1. * **resultIfOne** (number) - The number to return if `subject` is 1. * **resultIfZero** (number) - The number to return if `subject` is 0. ### Returns * number - Either `resultIfOne` or `resultIfZero`, depending on the value of `subject`. ``` -------------------------------- ### writeUint16BE Source: https://www.stablelib.com/functions/_stablelib_binary.writeUint16BE.html Writes a 2-byte big-endian representation of a 16-bit unsigned value to a byte array, starting at a specified offset. If no byte array is provided, a new 2-byte array is created. The function returns the modified or newly created byte array. ```APIDOC ## writeUint16BE ### Description Writes a 2-byte big-endian representation of a 16-bit unsigned value to a byte array, starting at a specified offset. If no byte array is provided, a new 2-byte array is created. The function returns the modified or newly created byte array. ### Parameters #### Parameters * **value** (number) - Required - The 16-bit unsigned value to write. * **out** (Uint8Array) - Optional - The byte array to write to. If not provided, a new array is created. * **offset** (number) - Optional - The starting offset in the byte array. Defaults to 0. ### Returns * **Uint8Array** - The output byte array. ``` -------------------------------- ### finish Source: https://www.stablelib.com/classes/_stablelib_x25519_session.X25519Session.html Completes the key agreement process for the offering party by processing the accept message. ```APIDOC ## finish ### Description Completes the key agreement process for the offering party. After calling this method, the offering party can retrieve the shared key using `getSharedKey()`. ### Signature `finish(acceptMsg): this` ### Parameters * `acceptMsg` (Uint8Array) - The accept message received from the accepting party. ### Returns * `this` - The current instance, allowing for method chaining. ``` -------------------------------- ### writeInt32BE Source: https://www.stablelib.com/functions/_stablelib_binary.writeInt32BE.html Writes the 4-byte big-endian representation of a 32-bit unsigned value to a byte array, starting at the specified offset. If no byte array is provided, a new 4-byte array is created. The function returns the modified or newly created byte array. ```APIDOC ## Function writeInt32BE ### Description Writes the 4-byte big-endian representation of a 32-bit unsigned value to a byte array, starting at the specified offset. If no byte array is provided, a new 4-byte array is created. The function returns the modified or newly created byte array. ### Signature `writeInt32BE(value: number, out?: Uint8Array, offset?: number): Uint8Array` ### Parameters * `value` (number): The 32-bit unsigned integer to write. * `out` (Uint8Array, optional): The byte array to write to. If not provided, a new 4-byte array is created. Defaults to a new array. * `offset` (number, optional): The starting offset in the byte array. Defaults to 0. ### Returns * `Uint8Array`: The output byte array with the value written. ``` -------------------------------- ### BLAKE2b Methods Source: https://www.stablelib.com/classes/_stablelib_blake2b.BLAKE2b.html A collection of methods for managing the BLAKE2b hash state, updating the hash with data, and finalizing the hash computation. ```APIDOC ## Methods ### clean * **Signature**: `clean(): void` * **Description**: Clears the internal state of the hash function. * **Returns**: `void` ### cleanSavedState * **Signature**: `cleanSavedState(savedState): void` * **Parameters**: * **savedState** (SavedState) - The state to be cleaned. * **Description**: Cleans a previously saved state. * **Returns**: `void` ### digest * **Signature**: `digest(): Uint8Array` * **Description**: Computes and returns the final hash digest without finalizing the hash state. * **Returns**: `Uint8Array` - The computed hash digest. ### finish * **Signature**: `finish(out): this` * **Parameters**: * **out** (Uint8Array) - The buffer to write the final hash digest into. * **Description**: Finalizes the hash computation and writes the digest to the provided buffer. * **Returns**: `this` - The BLAKE2b instance for chaining. ### reset * **Signature**: `reset(): this` * **Description**: Resets the hash function to its initial state. * **Returns**: `this` - The BLAKE2b instance for chaining. ### restoreState * **Signature**: `restoreState(savedState): this` * **Parameters**: * **savedState** (SavedState) - The state to restore. * **Description**: Restores the hash function's state from a saved state. * **Returns**: `this` - The BLAKE2b instance for chaining. ### saveState * **Signature**: `saveState(): SavedState` * **Description**: Saves the current internal state of the hash function. * **Returns**: `SavedState` - The saved state object. ### update * **Signature**: `update(data, dataLength?): this` * **Parameters**: * **data** (Uint8Array) - The data to update the hash with. * **dataLength** (number) - Optional. The length of the data. Defaults to `data.length`. * **Description**: Updates the hash with the provided data. * **Returns**: `this` - The BLAKE2b instance for chaining. ### validateConfig * **Signature**: `validateConfig(config): void` * **Parameters**: * **config** (Config) - The configuration to validate. * **Description**: Validates the provided configuration object. * **Returns**: `void` ``` -------------------------------- ### readInt64BE Source: https://www.stablelib.com/functions/_stablelib_binary.readInt64BE.html Reads 8 bytes from an array starting at the specified offset as a big-endian signed 64-bit integer. Note that due to JavaScript limitations, exact number support is within the range of -9007199254740991 to 9007199254740991. Numbers outside this range may not be exact. ```APIDOC ## readInt64BE ### Description Reads 8 bytes from an array starting at the specified offset as a big-endian signed 64-bit integer. Due to JavaScript limitations, exact number support is within the range of -9007199254740991 to 9007199254740991. Numbers outside this range may not be exact. ### Method Function ### Signature readInt64BE(array: Uint8Array, offset?: number): number ### Parameters #### Path Parameters - **array** (Uint8Array) - Required - The byte array to read from. - **offset** (number) - Optional - The starting offset in the array. Defaults to 0. ### Returns - **number** - The 64-bit signed integer read from the array. ``` -------------------------------- ### BLAKE2s Methods Source: https://www.stablelib.com/classes/_stablelib_blake2s.BLAKE2s.html Provides essential methods for managing the BLAKE2s hash state and computing the hash. ```APIDOC ## Methods ### clean * **Signature**: `clean(): void` * **Description**: Clears the internal state of the hash object. * **Returns**: void ### cleanSavedState * **Signature**: `cleanSavedState(savedState): void` * **Parameters**: * `savedState` (SavedState) - The state to be cleaned. * **Description**: Cleans a previously saved state. * **Returns**: void ### digest * **Signature**: `digest(): Uint8Array` * **Description**: Computes and returns the final hash digest. * **Returns**: Uint8Array - The computed hash digest. ### finish * **Signature**: `finish(out: Uint8Array): this` * **Parameters**: * `out` (Uint8Array) - The buffer to write the final hash digest into. * **Description**: Finalizes the hash computation and writes the digest to the provided output buffer. * **Returns**: this - The hash object instance. ### reset * **Signature**: `reset(): this` * **Description**: Resets the hash object to its initial state, allowing for a new hash computation. * **Returns**: this - The hash object instance. ### restoreState * **Signature**: `restoreState(savedState): this` * **Parameters**: * `savedState` (SavedState) - The saved state to restore. * **Description**: Restores the hash object's state from a previously saved state. * **Returns**: this - The hash object instance. ### saveState * **Signature**: `saveState(): SavedState` * **Description**: Saves the current internal state of the hash object. * **Returns**: SavedState - The saved state. ### update * **Signature**: `update(data: Uint8Array, dataLength?: number): this` * **Parameters**: * `data` (Uint8Array) - The data to update the hash with. * `dataLength` (number) - Optional - The length of the data to process. Defaults to `data.length`. * **Description**: Updates the hash computation with the provided data. * **Returns**: this - The hash object instance. ### validateConfig * **Signature**: `validateConfig(config): void` * **Parameters**: * `config` (Config) - The configuration to validate. * **Description**: Validates the provided configuration object. * **Returns**: void ```