react-native-aes
react-native-aes copied to clipboard
TypeError: Cannot read property 'randomKey' of undefined
I am using react-native 0.61.5
I follow the example of the documentation
import {NativeModules, Platform} from 'react-native'
var Aes = NativeModules.Aes
and I have the following error:
TypeError: Cannot read property 'randomKey' of undefined
please help
ios? android?
if you are on iOS run pod install in ios folder.
Same here on ios. pod install does not help. android works fine react-native 0.59.9
Same here "TypeError: Cannot read property 'pbkdf2' of undefined" on android, react-native 0.62.2
You can use it like this and it will work
import { NativeModules } from 'react-native' const EncryptionHelper = { generateKey: async (password: any, salt: any, cost: any, length: any) => await NativeModules.Aes.pbkdf2(password, salt, cost, length), decryptData: async (encryptedData: { cipher: any; iv: any; }, key: any) => await NativeModules.Aes.decrypt(encryptedData.cipher, key, encryptedData.iv), generateIV: async () => await NativeModules.Aes.randomKey(16), encryptData: async (text: any, key: any, iv: any) => await NativeModules.Aes.encrypt(text, key, iv) } export default EncryptionHelper;