SecureLocalStorage

A class that provides secure local storage functionalities with encryption and decryption, leveraging a DataStore<Preferences> for persistent key-value storage. This implementation ensures that data is securely saved and retrieved with cryptographic operations.

This class conforms to the KeyValueStorageInterface for standardized key-value storage operations.

Parameters

dataStore

The DataStore instance for storing preferences.

SecureLocalStorage provides a platform-specific implementation for managing key-value storage securely. It extends KeyValueStorageInterface and ensures that stored data remains protected.

This class allows storing, retrieving, deleting, and managing key-value pairs, supporting multiple data types such as String, Int, Double, Float, and ByteArray. Additionally, it provides mechanisms for accessing storage status and performing operations in a secure manner.

This class requires platform-specific implementations to handle secure storage functionality and guarantees compatibility with the KeyValueStorageInterface.

Constructors

Link copied to clipboard
constructor(dataStore: DataStore<Preferences>)

Initializes the SecureLocalStorage with a specified DataStore<Preferences>.

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
actual open override fun delete(key: KeyValueStorageKeys): SecureLocalStorageResult

Deletes the value associated with the given key in the secure key-value storage.

actual open override fun delete(key: String): SecureLocalStorageResult

Deletes a key-value pair from the secure local storage.

expect open override fun delete(key: KeyValueStorageKeys): SecureLocalStorageResult

Deletes the value associated with the given key from the secure local storage.

expect open override fun delete(key: String): SecureLocalStorageResult

Deletes the data associated with the provided key from the secure local storage.

Link copied to clipboard
actual open override fun deleteAll(): SecureLocalStorageResult

Deletes all entries from the secure local storage.

expect open override fun deleteAll(): SecureLocalStorageResult

Deletes all stored key-value entries in the secure local storage.

Link copied to clipboard

Delete multiple keys at once. Returns a list of results for each operation.

Link copied to clipboard
actual open override fun exist(key: KeyValueStorageKeys): Boolean

Checks if a specific key exists in the key-value storage.

expect open override fun exist(key: KeyValueStorageKeys): Boolean

Checks if the specified key exists in the secure local storage.

Link copied to clipboard

Check if all specified keys exist.

Link copied to clipboard

Check if any of the specified keys exist.

Link copied to clipboard
actual open override fun get(key: KeyValueStorageKeys): SecureLocalStorageResult

Retrieves a value associated with the provided key.

actual open override fun get(key: String): SecureLocalStorageResult

Retrieves the value associated with the given key from secure local storage.

expect open override fun get(key: KeyValueStorageKeys): SecureLocalStorageResult

Retrieves the corresponding value associated with the given key from the secure local storage.

expect open override fun get(key: String): SecureLocalStorageResult

Retrieves the value associated with the given key from the secure local storage.

Link copied to clipboard
actual open override fun getAll(): List<Pair<String, Any>>

Retrieves all key-value pairs stored in the secure local storage. The keys are represented as strings, and the values are of type Any.

expect open override fun getAll(): List<Pair<String, Any>>

Retrieves all key-value pairs stored in the secure local storage.

Link copied to clipboard

Get a value as ByteArray or null if not found.

Link copied to clipboard

Get a value as Double or null if not found/invalid.

Link copied to clipboard

Get a value as Double with a default fallback.

Link copied to clipboard

Get a value as Float or null if not found/invalid.

Link copied to clipboard

Get a value as Float with a default fallback.

Link copied to clipboard

Get a value as Int or null if not found/invalid.

Link copied to clipboard

Get a value as Int with a default fallback.

Link copied to clipboard

Get a value as String or null if not found/invalid.

Link copied to clipboard

Get a value as String with a default fallback.

Link copied to clipboard
actual open override fun set(key: KeyValueStorageKeys, value: ByteArray): SecureLocalStorageResult

Stores a byte array value in the secure local storage associated with the specified key.

actual open override fun set(key: KeyValueStorageKeys, value: Double): SecureLocalStorageResult

Stores a key-value pair in the secure local storage where the key is of type KeyValueStorageKeys and the value is a Double.

actual open override fun set(key: KeyValueStorageKeys, value: Float): SecureLocalStorageResult

Stores a float value associated with a specific key in secure local storage.

actual open override fun set(key: KeyValueStorageKeys, value: Int): SecureLocalStorageResult

Saves an integer value associated with the given key in the secure local storage.

actual open override fun set(key: KeyValueStorageKeys, value: String): SecureLocalStorageResult
actual open override fun set(key: String, value: String): SecureLocalStorageResult

Stores a key-value pair in the secure local storage.

actual open override fun set(key: String, value: ByteArray): SecureLocalStorageResult

Stores a byte array value in the secure local storage using the specified key.

expect open override fun set(key: KeyValueStorageKeys, value: ByteArray): SecureLocalStorageResult

Stores a value associated with the specified key in the secure local storage.

expect open override fun set(key: KeyValueStorageKeys, value: Double): SecureLocalStorageResult

Stores a double value associated with a specific key in the secure local storage.

expect open override fun set(key: KeyValueStorageKeys, value: Float): SecureLocalStorageResult
expect open override fun set(key: String, value: String): SecureLocalStorageResult

Stores a key-value pair in the secure local storage.

expect open override fun set(key: KeyValueStorageKeys, value: Int): SecureLocalStorageResult

Stores an integer value in secure local storage corresponding to the given key.

expect open override fun set(key: KeyValueStorageKeys, value: String): SecureLocalStorageResult

Stores a string value in the secure local storage for the specified key.

expect open override fun set(key: String, value: ByteArray): SecureLocalStorageResult

Stores a value in the secure local storage using the given key.

Link copied to clipboard

Set multiple values at once. Returns a list of results for each operation.