1バイトずつ key [0]
~ key [7]
と排他的論理和を取っていくループ。
var k0 = key [0];
var k1 = key [1];
var k2 = key [2];
var k3 = key [3];
var k4 = key [4];
var k5 = key [5];
var k6 = key [6];
var k7 = key [7];
var sb = new StringBuffer (http.data);
var len = sb.length;
sb.append ('*'.multiply (32));
for (i = 0; i < len;) {
sb [i++] = sb.charCodeAt (i) ^ k0;
sb [i++] = sb.charCodeAt (i) ^ k1;
sb [i++] = sb.charCodeAt (i) ^ k2;
sb [i++] = sb.charCodeAt (i) ^ k3;
sb [i++] = sb.charCodeAt (i) ^ k4;
sb [i++] = sb.charCodeAt (i) ^ k5;
sb [i++] = sb.charCodeAt (i) ^ k6;
sb [i++] = sb.charCodeAt (i) ^ k7;
sb [i++] = sb.charCodeAt (i) ^ k0;
// 中略
sb [i++] = sb.charCodeAt (i) ^ k7;
sb [i++] = sb.charCodeAt (i) ^ k0;
sb [i++] = sb.charCodeAt (i) ^ k1;
sb [i++] = sb.charCodeAt (i) ^ k2;
sb [i++] = sb.charCodeAt (i) ^ k3;
sb [i++] = sb.charCodeAt (i) ^ k4;
sb [i++] = sb.charCodeAt (i) ^ k5;
sb [i++] = sb.charCodeAt (i) ^ k6;
sb [i++] = sb.charCodeAt (i) ^ k7;
}
sb.delete (len);
ここは19世紀か。
まったくループを展開しない場合に比べて、ちょっとだけ速くなります。ちょっとだけ。
まじめに速くしたいなら外部プロセスに投げるべき。