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: 1 day 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 (5 months ago)
- Last Synced: 2024-11-03T01:33:20.812Z (5 days 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: 233
- Watchers: 6
- Forks: 20
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
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.