Skip to content

Commit

Permalink
[fix] Use crypto.randomBytes() to generate the masking key
Browse files Browse the repository at this point in the history
  • Loading branch information
AJ ONeal authored and lpinca committed Nov 25, 2016
1 parent 269dff8 commit 7253f06
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions lib/Sender.js
Expand Up @@ -6,6 +6,8 @@

'use strict';

const crypto = require('crypto');

const PerMessageDeflate = require('./PerMessageDeflate');
const bufferUtil = require('./BufferUtil').BufferUtil;
const ErrorCodes = require('./ErrorCodes');
Expand Down Expand Up @@ -364,12 +366,7 @@ function toBuffer (data) {
* @private
*/
function getRandomMask () {
return new Buffer([
~~(Math.random() * 255),
~~(Math.random() * 255),
~~(Math.random() * 255),
~~(Math.random() * 255)
]);
return crypto.randomBytes(4);
}

/**
Expand Down

0 comments on commit 7253f06

Please sign in to comment.