| 95 | |
| 96 | // encrption |
| 97 | const encrypt = async plainText => { |
| 98 | try { |
| 99 | const encryptedData = await AesGcmCrypto.encrypt( |
| 100 | plainText, |
| 101 | false, |
| 102 | await getDataFromAsyncStorage('hashed_password'), |
| 103 | ); |
| 104 | return JSON.stringify({ |
| 105 | nonce: Buffer.from(encryptedData.iv, 'hex').toString('base64'), |
| 106 | ciphertext: encryptedData.content, |
| 107 | tag: Buffer.from(encryptedData.tag, 'hex').toString('base64'), |
| 108 | }); |
| 109 | } catch (e) { |
| 110 | throw new Error('Failed to encrypt: ' + e); |
| 111 | } |
| 112 | }; |
| 113 | |
| 114 | // decryption |
| 115 | const decrypt = async encryptedData => { |
no test coverage detected