From 5ea143bdb9c783c2d8d1d46beedb66f47a11490d Mon Sep 17 00:00:00 2001 From: Artem Chepurnoy Date: Sat, 9 Mar 2024 08:41:02 +0200 Subject: [PATCH] improvement: Decrypt empty string as empty string --- .../keyguard/provider/bitwarden/crypto/BitwardenCrypto.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/common/src/commonMain/kotlin/com/artemchep/keyguard/provider/bitwarden/crypto/BitwardenCrypto.kt b/common/src/commonMain/kotlin/com/artemchep/keyguard/provider/bitwarden/crypto/BitwardenCrypto.kt index b4092f8a..d0484c2b 100644 --- a/common/src/commonMain/kotlin/com/artemchep/keyguard/provider/bitwarden/crypto/BitwardenCrypto.kt +++ b/common/src/commonMain/kotlin/com/artemchep/keyguard/provider/bitwarden/crypto/BitwardenCrypto.kt @@ -87,6 +87,11 @@ fun BitwardenCrCta.transformString( encoder(env.key).invoke(encryptionType, data) }, isDecrypt = { + // This should never happen, but just in case to not + // fail the decryption process we fall back to an empty string. + if (value.isEmpty()) { + return@whatIf value + } val data = decoder(env.key).invoke(value).data String(data) },