KeyValueEncryptedFileStore

Key-value store backed by file system. Currently uses an in-memory solution for encryption and decryption. While this solution is not particularly good from a memory standpoint, we will need to employ this as a workaround for now, until we figure out how we can achieve acceptable performance with a streaming solution, since CipherInputStream is a lot slower with AES-GCM.

Constructors

Link copied to clipboard
constructor(ctx: Context, storeName: String, encryptionKey: String)
Constructor

Properties

Link copied to clipboard
val KEY_SUFFIX: String = ".key"
Link copied to clipboard
val KEY_VALUE_STORES: String = "keyvaluestores"
Link copied to clipboard
val KV_VERSION: Int = 2
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val VALUE_SUFFIX: String = ".value"
Link copied to clipboard
val VERSION_FILE_NAME: String = "version"

Functions

Link copied to clipboard
open fun changeEncryptionKey(newEncryptionKey: String): Boolean
Change encryption key All files are read/decrypted with old key and encrypted/written back with new key
Link copied to clipboard
open fun computeParentDir(ctx: Context): File
Return parent directory for all key stores
Link copied to clipboard
open fun contains(key: String): Boolean
Return true if store contains a file for the given key
Link copied to clipboard
open fun count(): Int
Link copied to clipboard
open fun deleteAll(): Boolean
Deletes all stored values.
Link copied to clipboard
open fun deleteValue(key: String): Boolean
Deletes stored value for given key.
Link copied to clipboard
open fun getStoreName(): String
Link copied to clipboard
open fun getStoreVersion(): Int
Link copied to clipboard
open fun getStream(key: String): InputStream
Returns stream for value of given key.
Link copied to clipboard
open fun getValue(key: String): String
Returns value stored for given key.
Link copied to clipboard
open fun hasKeyValueStore(ctx: Context, storeName: String): Boolean
Return boolean indicating if a key value store with the given (full) name already exists
Link copied to clipboard
open fun isEmpty(): Boolean
Link copied to clipboard
open fun isValidStoreName(storeName: String): Boolean
Store name can only contain letters, digits and _ and cannot exceed 96 characters
Link copied to clipboard
open fun keySet(): Set<String>
Get all keys.
Link copied to clipboard
open fun removeKeyValueStore(ctx: Context, storeName: String)
Remove key value store with given (full) name
Link copied to clipboard
open fun saveStream(key: String, stream: InputStream): Boolean
Save value given as an input stream for the given key.
Link copied to clipboard
open fun saveValue(key: String, value: String): Boolean
Save value for the given key.