Large Files Encryption

This feature is not available for Node.js and React Native.

E3Kit provides a method for encryption that allows to encrypt large amount of data through streams. This is useful when the size of data is too large to be encrypted or decrypted all at once.

We recommend using stream encryption with files larger than 1mb.

Before you begin

Be sure to implement the following:

Encrypt large file

To encrypt a large amount of data, use the authEncrypt method (authEncryptFile in JavaScript):

// Listener for keys lookup
OnResultListener<FindUsersResult> lookupKeysListener = new OnResultListener<FindUsersResult>() {
    @Override public void onSuccess(FindUsersResult result) {
        byte[] data = "I was text but became byte array".getBytes();

        try (ByteArrayInputStream inputStream = new ByteArrayInputStream(data);
             ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {

            // Encrypt input stream using user public keys and writes output to the output stream
            ethree.authEncrypt(inputStream, inputStream.available(), outputStream, result);
        } catch (IOException e) {
            // Handle error

    @Override public void onError(@NotNull Throwable throwable) {


// Lookup destination user public keys
List<String> identities = new ArrayList<>(3);

If you don't pass public keys, the file is encrypted with the user's own public key.

Decrypt a large file

To decrypt a large amount of data, use the authDecrypt method (authDecryptFile in Javascript):

try (ByteArrayInputStream inputStream = new ByteArrayInputStream(encryptedData);
     ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {

    // Decrypt input stream and writes output to the output stream
    ethree.authDecrypt(inputStream, outputStream);
} catch (IOException e) {
    // Handle error