Skip to main content

EncryptionKey

The EncryptionKey class is designed for encrypting and decrypting data between the mobile client and a Cloud node. The encryption algorithm used in this class is ChaChaBox.

Accessors

decryptKey

Get Signature

get decryptKey(): number

Gets the decryption key memory pointer handle.

Returns

number

The handle for the decryption key.


encryptPubKey

Get Signature

get encryptPubKey(): string

Gets the encryption public key in base64 format.

Returns

string

The base64 encoded encryption public key.

Methods

decryptData()

decryptData(data, senderEncKey): Promise<string>

Decrypts the data using the sender's encryption public key.

Parameters

data

string

Encrypted data to decrypt.

senderEncKey

string

The sender's hex encoded encryption public key.

Returns

Promise<string>

A promise that resolves to the decrypted data in base64 format.

Throws

If the native module fails to decrypt the data.


encryptData()

encryptData(data, receiverEncKey): Promise<string>

Hideconstructor

Encrypts the data using the receiver's encryption public key.

Parameters

data

string

The data to encrypt.

receiverEncKey

string

The receiver's hex encoded encryption public key.

Returns

Promise<string>

A promise that resolves to the encrypted data in base64 format.

Throws

If the native module fails to encrypt the data.


free()

free(): Promise<boolean>

Frees up the memory used by the decryption key.

Returns

Promise<boolean>

A promise that resolves to true if the memory is freed successfully.


create()

static create(): Promise<EncryptionKey>

Creates a new encryption key for the mobile client.

Returns

Promise<EncryptionKey>

A promise that resolves to a new EncryptionKey instance.

Throws

If the native module fails to create a new encryption key.