new Encryptor()
Encryptor has static constants and utility methods for encryption, such as
encryptData.
- Source:
Methods
(static) encryptAsymmetricPromise_(payload, key, keyName, params, useSync) → {Promise|SyncPromise}
Encrypt the payload using the asymmetric key according to params, and
return an EncryptedContent.
Parameters:
Name | Type | Description |
---|---|---|
payload |
Blob | The data to encrypt. The size should be within range of the key. |
key |
Blob | The key value. |
keyName |
Name | The key name for the EncryptedContent key locator. |
params |
EncryptParams | The parameters for encryption. |
useSync |
boolean | (optional) If true then return a SyncPromise which is already fulfilled. If omitted or false, this may return a SyncPromise or an async Promise. |
- Source:
Returns:
A promise which returns a new EncryptedContent.
- Type
- Promise | SyncPromise
(static) encryptData(data, payload, keyName, key, params)
Prepare an encrypted data packet by encrypting the payload using the key
according to the params. In addition, this prepares the encoded
EncryptedContent with the encryption result using keyName and params. The
encoding is set as the content of the data packet. If params defines an
asymmetric encryption algorithm and the payload is larger than the maximum
plaintext size, this encrypts the payload with a symmetric key that is
asymmetrically encrypted and provided as a nonce in the content of the data
packet.
Parameters:
Name | Type | Description |
---|---|---|
data |
Data | The data packet which is updated. |
payload |
Blob | The payload to encrypt. |
keyName |
Name | The key name for the EncryptedContent. |
key |
Blob | The encryption key value. |
params |
EncryptParams | The parameters for encryption. |
- Source:
Throws:
Error If encryptPromise doesn't return a SyncPromise which is
already fulfilled.
(static) encryptDataPromise(data, payload, keyName, key, params, useSync) → {Promise|SyncPromise}
Prepare an encrypted data packet by encrypting the payload using the key
according to the params. In addition, this prepares the encoded
EncryptedContent with the encryption result using keyName and params. The
encoding is set as the content of the data packet. If params defines an
asymmetric encryption algorithm and the payload is larger than the maximum
plaintext size, this encrypts the payload with a symmetric key that is
asymmetrically encrypted and provided as a nonce in the content of the data
packet. The packet's // is updated to be /FOR/.
Parameters:
Name | Type | Description |
---|---|---|
data |
Data | The data packet which is updated. |
payload |
Blob | The payload to encrypt. |
keyName |
Name | The key name for the EncryptedContent. |
key |
Blob | The encryption key value. |
params |
EncryptParams | The parameters for encryption. |
useSync |
boolean | (optional) If true then return a SyncPromise which is already fulfilled. If omitted or false, this may return a SyncPromise or an async Promise. |
- Source:
Returns:
A promise which fulfills when the data packet
is updated.
- Type
- Promise | SyncPromise
(static) encryptSymmetricPromise_(payload, key, keyName, params, useSync) → {Promise|SyncPromise}
Encrypt the payload using the symmetric key according to params, and return
an EncryptedContent.
Parameters:
Name | Type | Description |
---|---|---|
payload |
Blob | The data to encrypt. |
key |
Blob | The key value. |
keyName |
Name | The key name for the EncryptedContent key locator. |
params |
EncryptParams | The parameters for encryption. |
useSync |
boolean | (optional) If true then return a SyncPromise which is already fulfilled. If omitted or false, this may return a SyncPromise or an async Promise. |
- Source:
Returns:
A promise which returns a new EncryptedContent.
- Type
- Promise | SyncPromise