Skip to main content

Storage and Encryption | Cordova Barcode Scanner

By default, the native Scanbot Barcode Scanner SDKs as well as the Plugin itself use the internal and secure storage locations for all image files.

  • 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 Plugin. The initializeSdk method can take an optional parameter storageBaseDirectory to set a custom storage location.

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 Plugin will try to create it. To work with the file system we recommend the Cordova Plugin cordova-plugin-file

For the full demo code please check out our example app on GitHub.

⚠️ 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-cleaning mechanism in this Plugin because only your app can decide when the perfect time is to remove the image files snapped by this Plugin.

This Plugin provides the method cleanup() to delete all images:

Example:

ScanbotBarcodeSDK.cleanup(function(result) {
// cleanup do
}, sdkErrorCallback);

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).
import ScanbotBarcodeSDK, { ScanbotBarcodeSdkConfiguration } from 'cordova-plugin-scanbot-barcode-scanner';
const config: ScanbotBarcodeSdkConfiguration = {
fileEncryptionPassword: 'SomeSecretPa$$w0rdForFileEncryption',
fileEncryptionMode: 'AES256'
...
};
ScanbotBarcodeSDK.initializeSdk(function(result) {
// success
}, function(err) {
// error
}, config);

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 your free "no-strings-attached" Trial License and properly test the Scanbot SDK.

Get your free Trial License

What do you think of this documentation?