Class: SalmonDecryptor

SalmonDecryptor(threads, bufferSize)

Utility class that decrypts byte arrays. Make sure you use setWorkerPath() with the correct worker script.

Constructor

new SalmonDecryptor(threads, bufferSize)

Instantiate a decryptor with parallel tasks and buffer size.
Parameters:
Name Type Default Description
threads number 0 The number of threads to use.
bufferSize number 0 The buffer size to use. It is recommended for performance to use a multiple of the chunk size if you enabled integrity otherwise a multiple of the AES block size (16 bytes).
Source:

Classes

SalmonDecryptor

Methods

close()

Close the decryptor and release associated resources
Source:

(async) decrypt(data, key, nonce, hasHeaderData, integrity, hashKey, chunkSize) → {Promise.<Uint8Array>}

Decrypt a byte array using AES256 based on the provided key and nonce.
Parameters:
Name Type Default Description
data Uint8Array The input data to be decrypted.
key Uint8Array The AES key to use for decryption.
nonce Uint8Array | null The nonce to use for decryption.
hasHeaderData boolean The header data.
integrity boolean false Verify hash integrity in the data.
hashKey Uint8Array | null null The hash key to be used for integrity.
chunkSize number | null null The chunk size.
Source:
Throws:
  • SalmonSecurityException Thrown if the key and nonce are not provided.
  • IOException Thrown if there is an IO error.
  • IntegrityException Thrown if the data are corrupt or tampered with.
Returns:
The byte array with the decrypted data. @ Thrown if there is a problem with decoding the array.
Type
Promise.<Uint8Array>

getWorkerPath() → {string}

Get the current path for the worker javascript.
Source:
Returns:
The path to the worker javascript.
Type
string

setWorkerPath(path)

Set the path where the decryptor worker. This needs to be a relative path starting from the root of your main javascript app.
Parameters:
Name Type Description
path string The path to the worker javascript.
Source: