Parameters for the new encryption

The source of the extra size overhead

The file content is actually base64 encoded twice during the encryption flow.

  1. When reading the file data, the result is a base64 encoded string. (source code)
  2. When encrypting, The sjcl.json.encrypt() will treat the plainText as a normal UTF-8 string rather than a bunch of base64 encoded data. After the encryption, the ciphertext is base64 encoded. (source code)

To reduce the unnecessary size overflow, we could convert the base64 string from Step 1 to the bitArray first, then encrypt it with sjcl.json.encrypt(). However, this introduces an extra step and slows down the encryption process.

1 Like