Skip to main content

Storing and encrypting data with the Kotlin Multiplatform Barcode Scanner

Storage and encryption

The Scanbot SDK for Kotlin Multiplatform (KMP) provides built-in file storage and encryption capabilities for managing scanned images, PDFs, and other generated files securely across all supported platforms.

Storage

The Scanbot SDK uses internal storage by default. All files generated by the SDK (images, PDF files, thumbnails, temporary files, etc.) are stored in the platform-specific application data directory.

Using the internal storage provides the following benefits:

  • All stored files can only be accessed by your app
  • No storage permission prompts are required for your users
  • Consistent behavior across iOS, Android, and other platforms

Changing the default storage directory

While it is strongly recommended to use the internal storage, you can override the default storage directory during SDK initialization.

The SdkConfiguration class provides the storageBaseDirectory parameter, which allows you to specify a custom storage location:

Custom storage directory
loading...
caution

When overriding the default storage location, make sure:

  • The value of storageBaseDirectory is a file URL pointing to a valid platform-specific file system path
  • You have implemented suitable storage permissions request handling on Android
  • The storage directory is available (e.g., not on an unmounted SD card)
  • You fully understand the security implications regarding file accessibility

Enabling encryption

Please note

Encryption is not enabled by default.

The Scanbot SDK provides the ability to encrypt all stored images and PDF files, adding another layer of security to the default secure storage locations.

To enable file encryption, configure the encryption mode and password during SDK initialization:

Enable Encryption
loading...

Encryption modes

The SDK supports two encryption modes through the FileEncryptionMode enumeration:

  • AES256 - Advanced Encryption Standard with 256-bit key (recommended)
  • AES128 - Advanced Encryption Standard with 128-bit key

How encryption works

When file encryption is enabled:

  • The SDK uses built-in AES 128 or AES 256 encryption
  • All generated image files (JPG, PNG) including preview images, as well as exported PDF and TIFF files are encrypted in memory
  • Files are stored as encrypted data on the device's storage
  • The SDK derives the AES key from the provided password using the PBKDF2 function with an internal salt value and number of iterations
  • When applying image operations (cropping, rotation, filters), the SDK automatically decrypts the file in memory, applies the changes, and re-encrypts it

Complete initialization example

Complete initialization with encryption
loading...

Want to scan longer than one minute?

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

Get free trial license