Fix #7 - random values should be 0...255 inclusive.

This commit is contained in:
Marek Majkowski
2011-12-16 15:07:20 +00:00
parent 19da8de414
commit 2f4f1cdc8f
+2 -2
View File
@@ -5,7 +5,7 @@ var Handshake = function(uri, stream) {
this._stream = stream;
var buffer = new Buffer(16), i = 16;
while (i--) buffer[i] = Math.floor(Math.random() * 254);
while (i--) buffer[i] = Math.floor(Math.random() * 256);
this._key = buffer.toString('base64');
var SHA1 = crypto.createHash('sha1');
@@ -198,7 +198,7 @@ var instance = {
frame[0] = this.FIN | opcode;
if (this._masking) {
mask = [1,2,3,4].map(function() { return Math.floor(Math.random() * 255) });
mask = [1,2,3,4].map(function() { return Math.floor(Math.random() * 256) });
for (i = 0, n = data.length; i < n; i++)
data[i] = data[i] ^ mask[i % 4];
}