Skip to content
Browse files

Fixing a bug that decoded key was not 16 bytes.

  • Loading branch information...
1 parent b54ae42 commit ba3d7af433aabb94c58a9f13416d81bb5b0c5762 @gimite committed Sep 19, 2011
View
BIN WebSocketMain.swf
Binary file not shown.
View
BIN WebSocketMainInsecure.zip
Binary file not shown.
View
9 flash-src/src/net/gimite/websocket/WebSocket.as
@@ -474,12 +474,13 @@ public class WebSocket extends EventDispatcher {
}
private function generateKey():String {
- var vals:String = "";
- for (var i:int = 0; i < 16; i++) {
- vals = vals + randomInt(0, 127).toString();
+ var vals:ByteArray = new ByteArray();
+ vals.length = 16;
+ for (var i:int = 0; i < vals.length; ++i) {
+ vals[i] = randomInt(0, 127);
}
base64Encoder.reset();
- base64Encoder.encode(vals);
+ base64Encoder.encodeBytes(vals);
return base64Encoder.toString();
}

0 comments on commit ba3d7af

Please sign in to comment.
Something went wrong with that request. Please try again.