Abrarul8541 commited on
Commit
467146a
·
verified ·
1 Parent(s): a1222b2

Phase 2: API keys encrypted with the vault

Browse files
app/src/main/java/io/github/abrarul/modularai/security/SecretStore.kt ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ package io.github.abrarul.modularai.security
2
+
3
+ import android.content.Context
4
+
5
+ /** Stores API keys as Vault ciphertext in private SharedPreferences. */
6
+ class SecretStore(ctx: Context) {
7
+ private val p = ctx.getSharedPreferences("secrets", Context.MODE_PRIVATE)
8
+ fun put(name: String, value: String) = p.edit().putString(name, Vault.encrypt(value)).apply()
9
+ fun get(name: String): String? = p.getString(name, null)?.let { runCatching { Vault.decrypt(it) }.getOrNull() }
10
+ fun wipe() = p.edit().clear().apply()
11
+ }