From 8b090896403b4b8812849dd7f4f1769979aae8f5 Mon Sep 17 00:00:00 2001 From: Wuriko Date: Sun, 13 Oct 2024 00:01:27 +0200 Subject: [PATCH 1/2] fix: fix decrypt result --- apps/app/src/utils/security.ts | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/apps/app/src/utils/security.ts b/apps/app/src/utils/security.ts index 66d6500a..14b9816b 100644 --- a/apps/app/src/utils/security.ts +++ b/apps/app/src/utils/security.ts @@ -1,26 +1,26 @@ import CryptoJS from 'crypto-js' export const encrypt = (valueToEncrypt: string) => - CryptoJS.AES.encrypt( - valueToEncrypt, - import.meta.env.VITE_APP_ENCRYPTION_KEY as string, - ).toString() + CryptoJS.AES.encrypt( + valueToEncrypt, + import.meta.env.VITE_APP_ENCRYPTION_KEY as string, + ).toString() export const decrypt = (valueToDecrypt: string) => { - let result = '' - try { - const bytes = CryptoJS.AES.decrypt( - valueToDecrypt, - import.meta.env.VITE_APP_ENCRYPTION_KEY || '', - ) - bytes.toString(CryptoJS.enc.Utf8) - } catch (e) { - console.warn('Could not decrypt value.') - } - return result + let result = '' + try { + const bytes = CryptoJS.AES.decrypt( + valueToDecrypt, + import.meta.env.VITE_APP_ENCRYPTION_KEY || '', + ) + result = bytes.toString(CryptoJS.enc.Utf8) + } catch (e) { + console.warn('Could not decrypt value.') + } + return result } export const useEncryption = () => ({ - encrypt, - decrypt, + encrypt, + decrypt, }) From 0bd809166f1751531d44bbf8e1308a283ae18759 Mon Sep 17 00:00:00 2001 From: Wurielle Date: Sat, 12 Oct 2024 22:02:05 +0000 Subject: [PATCH 2/2] style: prettier formatting --- apps/app/src/utils/security.ts | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/apps/app/src/utils/security.ts b/apps/app/src/utils/security.ts index 14b9816b..ceedba0f 100644 --- a/apps/app/src/utils/security.ts +++ b/apps/app/src/utils/security.ts @@ -1,26 +1,26 @@ import CryptoJS from 'crypto-js' export const encrypt = (valueToEncrypt: string) => - CryptoJS.AES.encrypt( - valueToEncrypt, - import.meta.env.VITE_APP_ENCRYPTION_KEY as string, - ).toString() + CryptoJS.AES.encrypt( + valueToEncrypt, + import.meta.env.VITE_APP_ENCRYPTION_KEY as string, + ).toString() export const decrypt = (valueToDecrypt: string) => { - let result = '' - try { - const bytes = CryptoJS.AES.decrypt( - valueToDecrypt, - import.meta.env.VITE_APP_ENCRYPTION_KEY || '', - ) - result = bytes.toString(CryptoJS.enc.Utf8) - } catch (e) { - console.warn('Could not decrypt value.') - } - return result + let result = '' + try { + const bytes = CryptoJS.AES.decrypt( + valueToDecrypt, + import.meta.env.VITE_APP_ENCRYPTION_KEY || '', + ) + result = bytes.toString(CryptoJS.enc.Utf8) + } catch (e) { + console.warn('Could not decrypt value.') + } + return result } export const useEncryption = () => ({ - encrypt, - decrypt, + encrypt, + decrypt, })