You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+38-5Lines changed: 38 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,18 +23,51 @@ Check out my own video about how easy it is to adapt KSafe into your project and
23
23
24
24
## What is KSafe
25
25
26
-
KSafe is the **easiest and most secure** way to persist encrypted data in Kotlin Multiplatform.
26
+
#### KSafe is the
27
+
1.**easiest to use**
28
+
2.**most secure**
29
+
3.**fastest**
30
+
31
+
library to persist encrypted and unencrypted data in Kotlin Multiplatform.
27
32
28
33
With simple property delegation, encrypted values feel like normal variables — you just read and write them, and KSafe handles encryption, decryption, and persistence transparently across all four platforms: **Android**, **iOS**, **JVM/Desktop**, and **WASM/JS (Browser)**.
29
34
35
+
Here's what that looks like in a real app — Ktor bearer authentication with **zero encryption boilerplate**:
36
+
30
37
```kotlin
31
-
var token by ksafe("") // encrypted, persisted, works on all 4 platforms
32
-
token ="abc123"// that's it
38
+
@Serializable
39
+
data classAuthTokens(
40
+
valaccessToken:String = "",
41
+
valrefreshToken:String = ""
42
+
)
43
+
44
+
// One line to encrypt, persist, and serialize the whole object
45
+
var tokens by ksafe(AuthTokens())
46
+
47
+
install(Auth) {
48
+
bearer {
49
+
loadTokens {
50
+
// Reads atomic object from hot cache (~0.002ms). No disk. No suspend.
Under the hood, each platform uses its native crypto engine — Android Keystore, iOS Keychain + CryptoKit, JVM's javax.crypto, and browser WebCrypto — unified behind a single API. Values are AES-256-GCM encrypted and persisted to DataStore (or localStorage on WASM). Beyond property delegation, KSafe also offers Compose state integration (`ksafe.mutableStateOf()`), reactive flows (`getFlow()` / `getStateFlow()`), built-in biometric authentication, configurable memory policies, and runtime security detection (root/jailbreak, debugger, emulator) — all out of the box.
68
+
No explicit encrypt/decrypt calls. No DataStore boilerplate. No `runBlocking`. Tokens are AES-256-GCM encrypted at rest, served from the hot cache at runtime, and survive process death — all through regular Kotlin property access.
36
69
37
-
Whether you need to secure OAuth tokens in a banking app or remember the last-visited screen of your game, KSafe stores the data encrypted with platform-specific secure key storage and hands it back to you like a normal variable.
70
+
Under the hood, each platform uses its native crypto engine — Android Keystore, iOS Keychain + CryptoKit, JVM's javax.crypto, and browser WebCrypto — unified behind a single API. Values are AES-256-GCM encrypted and persisted to DataStore (or localStorage on WASM). Beyond property delegation, KSafe also offers Compose state integration (`ksafe.mutableStateOf()`), reactive flows (`getFlow()` / `getStateFlow()`), built-in biometric authentication, configurable memory policies, and runtime security detection (root/jailbreak, debugger, emulator) — all out of the box.
0 commit comments