react-native-aes icon indicating copy to clipboard operation
react-native-aes copied to clipboard

TypeError: Cannot read property 'randomKey' of undefined

Open carlos03 opened this issue 5 years ago • 4 comments

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

carlos03 avatar Mar 11 '20 15:03 carlos03

ios? android? if you are on iOS run pod install in ios folder.

tectiv3 avatar Mar 19 '20 04:03 tectiv3

Same here on ios. pod install does not help. android works fine react-native 0.59.9

janneman001 avatar Mar 24 '20 17:03 janneman001

Same here "TypeError: Cannot read property 'pbkdf2' of undefined" on android, react-native 0.62.2

nonameb3 avatar Apr 16 '20 06:04 nonameb3

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;

MusabBasheer avatar Aug 29 '21 12:08 MusabBasheer