Class: SalmonEncryptor

SalmonEncryptor(threads, bufferSize)

Encrypts byte arrays. Make sure you use setWorkerPath() with the correct worker script.

Constructor

new SalmonEncryptor(threads, bufferSize)

Instantiate an encryptor 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

SalmonEncryptor

Methods

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

Encrypts a byte array using the provided key and nonce.
Parameters:
Name Type Default Description
data Uint8Array The byte array to be encrypted.
key Uint8Array The AES key to be used.
nonce Uint8Array The nonce to be used.
storeHeaderData boolean True if you want to store a header data with the nonce. False if you store the nonce external. Note that you will need to provide the nonce when decrypting.
integrity boolean false True if you want to calculate and store hash signatures for each chunkSize.
hashKey Uint8Array null Hash key to be used for all chunks.
chunkSize number null The chunk size.
Source:
Throws:
  • SalmonSecurityException Thrown when error with security
  • IOException Thrown if there is an IO error.
  • IntegrityException Thrown if the data are corrupt or tampered with.
Returns:
The byte array with the encrypted data.
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: