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

NodeJS中sm2加密报错 #2

Open
kwonganding opened this issue Jul 6, 2023 · 1 comment
Open

NodeJS中sm2加密报错 #2

kwonganding opened this issue Jul 6, 2023 · 1 comment

Comments

@kwonganding
Copy link

sm2加密在浏览器中运行正常,在NodeJS中运行报错:

throw new Error("random number pool is not ready or insufficient, prevent getting too long random values or too often.");

已复现:
1、发现是“async function initRNGPool() {” 初始化中用了异步,而我的方法调用时,一些初始化还没完成。
2、setTimeout延迟执行一下,就OK了

@Cubelrti
Copy link
Owner

默认使用的 node webcrypto 需要在 node 18 以上,更低的版本需要改成 require('crypto')。可以考虑自行 replace 一下或者先异步处理。

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

2 participants