tradle / react-native-crypto

partial implementation of node's `crypto` for react-native
MIT License
372 stars 84 forks source link

publicEncrypt TypeError: Cannot convert null value to object, #70

Open eramudeep opened 1 year ago

eramudeep commented 1 year ago

"react": "~18.0.0", "react-native": "~0.70.6",

import crypto  from 'react-native-crypto';
import Buffer from 'buffer'

export function EncryptTheKeyWithRSA() { 
    const publicKey = "MIIBIjANBgkqhkiG9w0BAnhtgAmhKl3E"   
    const aesKey =   crypto.randomBytes(256).toString('hex')); 
    const { Buffer: { from } } = Buffer

    const encryptedAesKey = crypto.publicEncrypt(publicKey,   from(aesKey) );    
}

Getting TypeError: Cannot convert null value to an object,

Any help would be appreciated