Skip to main content

Storage and Encryption | Capacitor Barcode Scanner

Scanbot Barcode Scanner SDK uses the internal and secure storage locations for the images by default.

  • On Android all files will be stored in the internal files directory of your application. No permissions are required for your app to read or write files in this directory.

  • On iOS all files will be stored in the Application Support folder of your application.

Customize Storage Location

caution

It is strongly recommended to use the default storage location.

However, you can override the storage directory on initialization of the SDK Module. The initializeSdk method can take an optional parameter storageBaseDirectory to set a custom storage location.

Scanbot Barcode Scanner SDK Initialization With Custom Storage
loading...

The value of the storageBaseDirectory must be a file URL ('file:///...) pointing to a valid platform-specific file system path. If this directory does not exist yet, the SDK Module will try to create it.

caution

When overriding the default storage location, make sure

  • you have implemented a suitable storage permissions request handling on Android
  • you fully understand the consequences regarding the accessibility (security) of the produced images.

For the full demo code please check out our example app scanbot-barcode-scanner-sdk-example-capacitor-ionic.

👉 For more details about the storage locations on Android and iOS please also see:

Storage Cleanup

There is no automatic file clean mechanism in this SDK Module, because only your App can decide when the perfect time is to remove the image files produced by this SDK.

To avoid storage space issues caused by too many produced image files, it is strongly recommended to implement a suitable cleanup functionality based on the requirements of your app. This SDK Module provides the following helper method to keep the storage clean.

Scanbot Barcode Scanner SDK Cleanup
loading...

Storage Encryption

Scanbot Barcode SDK provides the ability to store the generated image files (JPG, PNG) encrypted. This feature provides an additional level of security to the default secure storage locations of the native SDKs.

By default the file encryption is disabled. To enable it you have to pass the following config parameters on SDK initialization:

  • fileEncryptionPassword: A secure password or passphrase to derive the AES key for encryption/decryption.
  • fileEncryptionMode: Encryption mode, AES128 or AES256 (default and recommended).
Scanbot Barcode Scanner SDK Initialization With Encryption
loading...

By activating storage encryption the native Scanbot SDKs will use the built in AES 128 or AES 256 encryption. All generated image files (JPG, PNG), will be encrypted in memory and stored as encrypted data files on the flash storage of the device.

The Scanbot SDK derives the AES key from the given password, an internal salt value, and the internal number of iterations using the PBKDF2 function.

Handle Encrypted Images

If the file encryption is enabled you will not be able to display preview images via file URIs. Instead, you have to load the decrypted data of a preview image and use it for displaying an image. In order to do this use the API function getImageData({ imageFileUri: string }):

const result = await ScanbotBarcodeSDK.getImageData({ imageFileUri: imageFileUri });
const decryptedImageDataAsBase64 = `data:image/jpeg;base64,${result.base64ImageData}`;
...
<ion-img [src]="decryptedImageDataAsBase64" />

Want to scan longer than one minute?

Generate a free trial license to test the Scanbot SDK thoroughly.

Get your free Trial License

What do you think of this documentation?