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

bcryptjs fails on browser context #27

Closed
lewispham opened this issue Aug 14, 2015 · 4 comments
Closed

bcryptjs fails on browser context #27

lewispham opened this issue Aug 14, 2015 · 4 comments

Comments

@lewispham
Copy link

I got the error Neither WebCryptoAPI nor a crypto module is available. Use bcrypt.setRandomFallback to set an alternative when I was trying to generate salt with bcryptjs. After taking a brief look at the source, I've found that global variable is actually not defined on browser context.

@lewispham
Copy link
Author

Consider using self instead of window object since it's not available on web workers context.

@dcodeIO
Copy link
Owner

dcodeIO commented Sep 23, 2015

Good point, thanks!

@hqinnus
Copy link

hqinnus commented Jun 23, 2016

Hi, I'm using bcryptjs in browser, for WCA mode.
After you change window back to self, that call of "random(1)" to test random library will always fail. How to resolve it?
Also the random call inside genSaltSync also cannot identify self. It will always prompt error.
Can you provide a API to define self?

@hqinnus
Copy link

hqinnus commented Jun 24, 2016

I find the bcrypt.js I download from the source dist folder directly is correct.
But the file I download from the "Downloads" section in the readme has problem. Basically, that lead to this link "https://github.com/dcodeIO/bcrypt.js/archive/master.zip".
I guess this is an outdated file, the readme.md should be updated to reflect updated download link.

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