juliangruber / keypair

Generate a RSA PEM key pair from pure JS
Other
274 stars 51 forks source link

ERROR TypeError: crypto.randomBytes is not a function #23

Closed is-tongben closed 7 months ago

is-tongben commented 7 months ago

问题:

keypire使用报错

测试步骤:

import keypair from 'keypair';
const pair = keypair();

现状:

core.mjs:11754 ERROR TypeError: crypto.randomBytes is not a function at ctx.seedFileSync (index.js:1032:21) at _reseedSync (index.js:921:21) at ctx.generateSync (index.js:874:9) at ctx.generate (index.js:801:18) at forge.random.getBytes (index.js:1831:23) at Object.nextBytes (index.js:1858:28) at BigInteger.bnpFromNumber [as fromNumber] (index.js:2552:4) at new BigInteger (index.js:1898:35) at pki.rsa.stepKeyPairGenerationState (index.js:3972:21) at pki.rsa.generateKeyPair (index.js:4322:13)

image

版本信息:

v1.0.4

期望:

成功

snowy008 commented 7 months ago

你好,邮件已经收到,我会尽快处理的~~~

juliangruber commented 7 months ago

For browser environments, this needs a crypto polyfill, like https://www.npmjs.com/package/crypto-browserify