-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Closed
Description
https://github.com/websockets/ws/blob/master/lib/Sender.js#L309
function getRandomMask() {
return new Buffer([
~~(Math.random() * 255),
~~(Math.random() * 255),
~~(Math.random() * 255),
~~(Math.random() * 255)
]);
}
should be replaced with
function getRandomMask() {
return require('crypto').randomBytes(4);
}
If the desire is to be more performant this can be accomplished by pooling random data like this:
var rlen = 256;
var rbytes = crypto.randomBytes(rlen);
var rcounter = 4;
function getRandomMask() {
var result;
if (rcounter >= rbytes.length) {
rbytes = crypto.randomBytes(rlen);
rcounter = 4;
}
result = rbytes.slice(rcounter - 4, rcountner);
rcounter += 4;
return result;
}
Metadata
Metadata
Assignees
Labels
No labels