Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Liftric/KVault
Secure key-value storage for Kotlin Multiplatform projects.
https://github.com/Liftric/KVault
android encrypted-sharedpreferences ios key-value-store keychain keychain-wrapper kotlin kotlin-multiplatform kotlin-native liftric secure-key-storage sharedpreferences storage
Last synced: about 1 month ago
JSON representation
Secure key-value storage for Kotlin Multiplatform projects.
- Host: GitHub
- URL: https://github.com/Liftric/KVault
- Owner: Liftric
- License: mit
- Created: 2020-07-14T10:42:53.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-06-07T12:23:49.000Z (6 months ago)
- Last Synced: 2024-08-02T09:26:28.465Z (4 months ago)
- Topics: android, encrypted-sharedpreferences, ios, key-value-store, keychain, keychain-wrapper, kotlin, kotlin-multiplatform, kotlin-native, liftric, secure-key-storage, sharedpreferences, storage
- Language: Kotlin
- Homepage:
- Size: 309 KB
- Stars: 213
- Watchers: 6
- Forks: 19
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-kotlin-multiplatform - KVault - Secure key-value storage for Kotlin Multiplatform projects. (Libraries / Storage)
- kmp-awesome - KVault - secure key-value storage (Libraries / 📦 Storage)
- awesome-kotlin-multiplatform - KVault - Secure key-value storage for Kotlin Multiplatform projects. (Database)
README
![CI](https://github.com/Liftric/kvault/workflows/CI/badge.svg) ![maven-central](https://img.shields.io/maven-central/v/com.liftric/kvault?label=Maven%20Central) ![OSS Sonatype (Releases)](https://img.shields.io/nexus/r/com.liftric/kvault?label=Sonatype%20OSSRH%20%28Releases%29&server=https%3A%2F%2Fs01.oss.sonatype.org)
# KVault
KVault is a secure key-value storage for Kotlin Multiplatform projects. It acts as an iOS Keychain wrapper and implements encrypted SharedPreferences for Android.
## Import
```kotlin
sourceSets {
val commonMain by getting {
dependencies {
implementation("com.liftric:kvault:")
}
}
}
```## How-to
### Init
#### Android
```kotlin
val store = KVault(context, "")
```| Parameter | Description |
| :------------------ | :---------------------------------- |
| fileName (optional) | Name of the shared preferences file |#### iOS
```kotlin
val store = KVault("", "")
```| Parameter | Description |
| :--------------------- | :---------------------------------- |
| serviceName (optional) | Used to categories objects |
| accessGroup (optional) | Used to share objects between apps |### Setting
```kotlin
val stringStored: Boolean = store.set(key = "LEET", stringValue = "1337")
val intStored: Boolean = store.set(key = "ANSWER", intValue = 42)
val floatStored: Boolean = store.set(key = "PI", floatValue = 3.14)
```#### Supported Types
- String
- Int
- Long
- Float
- Double
- Bool
- ByteArray### Getting
```kotlin
val stringValue: String? = store.string(forKey = "PASSWORD")
val intValue: Int? = store.int(forKey = "SECRET")
```To check if an object is stored you can use:
```kotlin
val existsObject: Boolean = store.existsObject(forKey = "PASSWORD")
```To check for which keys objects are stored:
```kotlin
val allKeys: List = store.allKeys()
```### Deleting
#### Single object
```kotlin
val isRemoved: Boolean = store.removeObject(forKey = "PASSWORD")
```#### All objects
```kotlin
val isCleared: Boolean = store.clear()
```## License
KVault is available under the MIT license. See the LICENSE file for more info.