Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Cannot read property 'randomKey' of undefined #33

Open
carlos03 opened this issue Mar 11, 2020 · 4 comments
Open

TypeError: Cannot read property 'randomKey' of undefined #33

carlos03 opened this issue Mar 11, 2020 · 4 comments

Comments

@carlos03
Copy link

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

@tectiv3
Copy link
Owner

tectiv3 commented Mar 19, 2020

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

@janneman001
Copy link

janneman001 commented Mar 24, 2020

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

@nonameb3
Copy link

nonameb3 commented Apr 16, 2020

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

@MusabBasheer
Copy link

MusabBasheer commented Aug 29, 2021

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;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants