diff --git a/shared/cryptoutil/cryptoUtil.ts b/shared/cryptoutil/cryptoUtil.ts index 3f1b3652ac..f36c6fb9a9 100644 --- a/shared/cryptoutil/cryptoUtil.ts +++ b/shared/cryptoutil/cryptoUtil.ts @@ -115,6 +115,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); @@ -126,11 +130,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);