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

Use forge.min.js tell me n.randomBytes is not a function #537

Closed
zishang520 opened this issue Sep 3, 2017 · 3 comments
Closed

Use forge.min.js tell me n.randomBytes is not a function #537

zishang520 opened this issue Sep 3, 2017 · 3 comments

Comments

@zishang520
Copy link

zishang520 commented Sep 3, 2017

forge.random.getBytesSync(32);

TypeError: n.randomBytes is not a function
at Object.o.seedFileSync (E:\cache\crypto.js:7:4534)
at r (E:\cache\crypto.js:7:2210)
at Object.o.generateSync (E:\cache\crypto.js:7:4259)
at Object.o.generate (E:\cache\crypto.js:7:3898)
at Object.e.getBytesSync (E:\cache\crypto.js:1:25919)
at Object. (E:\cache\index.js:18:23)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)

@zishang520 zishang520 changed the title Use forge.min.js tell Use forge.min.js tell me n.randomBytes Sep 3, 2017
@zishang520 zishang520 changed the title Use forge.min.js tell me n.randomBytes Use forge.min.js tell me n.randomBytes is not a function Sep 3, 2017
@davidlehn
Copy link
Member

What version of Node.js is this? Or is this some other environment? The code in lib/prng.js sets _crypto to require('crypto') and later calls randomBytes() on that, so it should work with the standard API.

@zishang520
Copy link
Author

Thank you for your guidance, I read the source code, know where the problem lies, and my operating environment is WeChat small program, no window.crypto or window.msCrypto

@mahdipakravan-dev
Copy link

i fixed up this problem in this pull request
#1007

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

3 participants