File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -3,15 +3,21 @@ import CryptoJS from 'crypto-js'
3
3
export const encrypt = ( valueToEncrypt : string ) =>
4
4
CryptoJS . AES . encrypt (
5
5
valueToEncrypt ,
6
- import . meta. env . VITE_ENCRYPTION_KEY as string ,
6
+ import . meta. env . VITE_APP_ENCRYPTION_KEY as string ,
7
7
) . toString ( )
8
8
9
9
export const decrypt = ( valueToDecrypt : string ) => {
10
- const bytes = CryptoJS . AES . decrypt (
11
- valueToDecrypt ,
12
- import . meta. env . VITE_ENCRYPTION_KEY || '' ,
13
- )
14
- return bytes . toString ( CryptoJS . enc . Utf8 )
10
+ let result = ''
11
+ try {
12
+ const bytes = CryptoJS . AES . decrypt (
13
+ valueToDecrypt ,
14
+ import . meta. env . VITE_APP_ENCRYPTION_KEY || '' ,
15
+ )
16
+ bytes . toString ( CryptoJS . enc . Utf8 )
17
+ } catch ( e ) {
18
+ console . warn ( 'Could not decrypt value.' )
19
+ }
20
+ return result
15
21
}
16
22
17
23
export const useEncryption = ( ) => ( {
You can’t perform that action at this time.
0 commit comments