Storing and encrypting data with the Android Barcode Scanner SDK
Storage
It is strongly recommended to use the internal storage. However, you can override the default storage directory of the Scanbot SDK on initialization.
The ScanbotBarcodeScannerSDKInitializer
class provides the method sdkFilesDirectory(Application application, File sdkFilesDirectory)
, which allows changing the default storage directory.
See the following example:
loading...
When overriding the default storage location, make sure
- you have implemented a suitable storage permissions request handling,
- the storage directory is available (e.g., not on an unmounted SD card).
Encryption
By default, encryption for barcode images is disabled.
The Scanbot Barcode Scanner SDK provides the ability to encrypt all stored barcode images in the SDK app folder.
To do this, follow these steps:
- Add the Scanbot SDK Crypto Persistence library to your app dependencies
implementation("io.scanbot:barcode-sdk-crypto-persistence:VERSION")
- Enable file encryption in
ScanbotBarcodeScannerSDKInitializer
loading...
And that's it!
The default encryptor implementation uses the AndroidX Crypto solution under the hood. You can learn more about it in the Android documentation.
The file encryptor uses the AES256_GCM_HKDF_4KB
file encryption scheme. More about this in the Android documentation.
There are a few limitations to using the encryption libraries:
- The
security-crypto
andsecurity-identity-credential
AndroidX libraries are still in development and have an Alpha version. - Version 1.1.0-alpha02 of the Security library is supported on devices that run Android 7.0 (API level 24) and higher.
Furthermore, the Scanbot SDK provides a custom AES-based encryption solution io.scanbot.sdk.persistence.fileio.AESEncryptedFileIOProcessor
.
To enable it, you have to set it in the SDK initializer in the useFileEncryption()
method:
loading...
AESEncryptedFileIOProcessor
does not save the password in any secure storage between app sessions, so you have to implement this by yourself and reuse it for the SDK initialization.
The Scanbot SDK allows setting up a completely custom encryption implementation. To do this, you have to implement the io.scanbot.sdk.persistence.fileio.FileIOProcessor
interface and pass it to the useFileEncryption(true, your_file_io_processor)
method.
An instance of FileIOProcessor
will be available during the app session and the user can use it to read and copy decrypted image files and Bitmap
.
For example:
loading...
Want to scan longer than one minute?
Generate a free trial license to test the Scanbot SDK thoroughly.
Get free trial license