Skip to content

React-Native accelerator

It is possible to use the Seald SDK in React Native. However, its use can be slow, especially when encrypting and decrypting particularly large files. To overcome this, we recommend the use of our package: @seald-io/react-native-accelerator.

This package exposes functions to natively encrypt and decrypt files. This allows for significant gains in file handling speed, RAM requirements, and the speed of the encryption itself.

Before using this package, we advise you to familiarise yourself with our SDK, in particular with the concept of encryption session

Installation

The package requires a React Native application, using the Seald SDK.

Documentation specific to the installation of the SDK for React Native can be found here. Before using this package, it is necessary to do all the steps described in the First steps Guide

The package is available on NPM.

bash
npm install -S @seald-io/react-native-accelerator

Usage

The package exposes four functions: encryptString, decryptString, encryptURI, decryptURI.

The two functions encryptURI, decryptURI allow you to encrypt and decrypt a file directly via its URI. These functions return a URI of a new file. The URI returned is in string format.

The encryptString, decryptString functions encrypt and decrypt a string. They are useful in the case where a file is already present in the application's JavaScript engine.

TIP

We recommend minimizing the number of data transfers between the JavaScript engine and the native file system, as these transfers are slow and consume a lot of RAM.

The import of functions is done in the classic way:

js
import { encryptString, decryptString, encryptURI, decryptURI } from '@seald-io/react-native-accelerator'

To use these functions, you need an encryption session.

js
let encryptionSession // An instance of a Seald encryptionSession

const encryptedString = await encryptString(FILE_CONTENT, 'MyFilename', encryptionSession)
// encryptedString is the encrypted version of the given input string
const clearStringObject = await decryptString(ENCRYPTED_FILE_CONTENT, encryptionSession)
// clearStringObject is of type: Object<{filename: string, messageId: string, path: string }>

const encryptedFileURI = await encryptURI(FILE_TO_ENCRYPT_URI, 'MyFilename', encryptionSession)
// encryptedFileURI is a stringified URI pointing to the encrypted file
const decryptedFileObject = await decryptURI(FILE_TO_DECRYPT_URI, encryptionSession)
// decryptedFileObject is of type: Object<{filename: string, messageId: string, path: string }>

You will find the reference for this package here.

Example project

A detailed example project is available at github.