diff options
author | Harsh Shandilya <me@msfjarvis.dev> | 2023-05-19 18:58:48 +0530 |
---|---|---|
committer | Harsh Shandilya <me@msfjarvis.dev> | 2023-05-19 18:58:48 +0530 |
commit | 5420faff34b8626fa65430b945c1bb098c26e40f (patch) | |
tree | 101cf4505d204024240aff7ffccc844947359e30 /app/src | |
parent | 65509eaa54ea5fa8e363e3d6b1c044b1383a2c31 (diff) |
feat(gpg): add methods to clear entries from GPG passphrase cache
Diffstat (limited to 'app/src')
-rw-r--r-- | app/src/main/java/app/passwordstore/data/crypto/GPGPassphraseCache.kt | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/app/src/main/java/app/passwordstore/data/crypto/GPGPassphraseCache.kt b/app/src/main/java/app/passwordstore/data/crypto/GPGPassphraseCache.kt index 193c363c..e00809a8 100644 --- a/app/src/main/java/app/passwordstore/data/crypto/GPGPassphraseCache.kt +++ b/app/src/main/java/app/passwordstore/data/crypto/GPGPassphraseCache.kt @@ -37,6 +37,19 @@ constructor( } } + suspend fun clearCachedPassphrase( + context: Context, + identifier: GpgIdentifier, + ) { + withContext(dispatcherProvider.io()) { + getPreferences(context).edit { remove(identifier.toString()) } + } + } + + suspend fun clearAllCachedPassphrases(context: Context) { + withContext(dispatcherProvider.io()) { getPreferences(context).edit { clear() } } + } + private suspend fun getPreferences(context: Context) = withContext(dispatcherProvider.io()) { EncryptedSharedPreferences.create( |