diff --git a/shared/cryptoutil/cryptoUtil.ts b/shared/cryptoutil/cryptoUtil.ts index b4c0ac0dc4..f620eb9a2e 100644 --- a/shared/cryptoutil/cryptoUtil.ts +++ b/shared/cryptoutil/cryptoUtil.ts @@ -139,6 +139,10 @@ export async function decryptJson( encryptedData: string, ): Promise { try { + if (encryptedData === null || encryptedData === undefined) { + // to avoid crash in case of null or undefined + return ''; + } // Disable Encryption in debug mode if (DEBUG_MODE_ENABLED && __DEV__) { return JSON.parse(encryptedData); @@ -150,11 +154,6 @@ export async function decryptJson( ); } - if (encryptedData === null || encryptedData === undefined) { - // to avoid crash in case of null or undefined - return ''; - } - return await SecureKeystore.decryptData(ENCRYPTION_ID, encryptedData); } catch (e) { console.error('error decryptJson:', e);