I have been having issues with browserified code using this package because it depends on non-browserified code to implement itself.
Basically, this line is the issue:
exports.randomBytes = exports.rng = exports.pseudoRandomBytes = exports.prng = require('randombytes');
When you require crypto-browserify, you're not using the non-browserified crypto package. But if you go to randombytes' implementation, it requires crypto in its code. This causes two issues:
- If you are resolving requires to
cryptoas crypto-browserify, you get a circular dependency and the randomBytes field becomes undefined.
- If you are not,
randombytes will just require regular crypto, which defeats the whole purpose of using a browserified package in the first place. You probably won't have it available in your environment and just end up with nothing in the randomBytes field anyway.
Maybe this is an issue for randombytes instead. But I figured that most packages that depend on randomBytes usually require crypto instead of randombytes.
I have been having issues with browserified code using this package because it depends on non-browserified code to implement itself.
Basically, this line is the issue:
When you require
crypto-browserify, you're not using the non-browserifiedcryptopackage. But if you go torandombytes' implementation, it requirescryptoin its code. This causes two issues:cryptoascrypto-browserify, you get a circular dependency and therandomBytesfield becomesundefined.randombyteswill just require regularcrypto, which defeats the whole purpose of using a browserified package in the first place. You probably won't have it available in your environment and just end up with nothing in therandomBytesfield anyway.Maybe this is an issue for randombytes instead. But I figured that most packages that depend on
randomBytesusually requirecryptoinstead ofrandombytes.