Skip to main content

Storage and Encryption | React Native 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

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

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. To work with the file system we recommend the npm module react-native-fs

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

⚠️ Note: 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 document files.

👉 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.

await ScanbotBarcodeSDK.cleanup();

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

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 Barcode SDK derives the AES key from the given password, an internal salt value, and the internal number of iterations using the PBKDF2 function.

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?