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

Error secure random number generation not supported by this browser use chrome, FireFox or Internet Explorer 1 #59

Open
congnt148 opened this issue Jul 9, 2020 · 0 comments

Comments

@congnt148
Copy link

congnt148 commented Jul 9, 2020

Hi.
I use 'crypto.publicEncrypt' in my code RN. Android test, release and Ios test word good, but IOS release error 'Error secure random number generation not supported by this browser use chrome, FireFox or Internet Explorer 1'

System:
React-native-cli: 2.0.1
React-native: 0.61.5
Node: v12.11.1

My code:
RNRandomBytes.randomBytes(24, (err, bytes) => {
const randomAESkey = bytes
const sha256Pass = CryptoJS.HmacSHA256(password, Config.SHARE_KEY)
const key = CryptoJS.enc.Base64.parse(randomAESkey)
let iv = new Buffer(randomAESkey, 'base64').slice(0, 16).toString('base64')
iv = CryptoJS.enc.Base64.parse(iv)
const aes256Pass = CryptoJS.AES.encrypt(sha256Pass, key, { iv: iv, mode: CryptoJS.mode.CBC, })
const deviceId = DeviceInfo.getUniqueId()
const RSA_PKCS1_PADDING = 1
console.log('Buffer.from(randomAESkey) ', Buffer.from(randomAESkey))
const enc = crypto.publicEncrypt( --> Begin error
{
key: Config.APP_PUBLIC_KEY,
padding: RSA_PKCS1_PADDING,
},
Buffer.from(randomAESkey),
)
const data = {
Password: aes256Pass.toString(),
UserName: (registerOrLoginState && registerOrLoginState.Phone) || '',
IsProvideKey: true,
Imei: deviceId,
EncryptKey: enc.toString('base64'),
SessionId: '',
DeviceType: Platform.OS.toUpperCase(),
}
}

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

1 participant