1
0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2024-12-22 21:00:23 +01:00

Only alter last bit also in non persistent rng mode.

Fixes #99.
This commit is contained in:
kkapsner 2017-01-18 08:46:45 +01:00
parent 6d7a9fc22a
commit 960f3c4f36
2 changed files with 4 additions and 23 deletions

View File

@ -46,7 +46,7 @@
var l = desc.length; var l = desc.length;
var rng = randomSupply.getRng(l, window); var rng = randomSupply.getRng(l, window);
for (var i = 0; i < l; i += 10){ for (var i = 0; i < l; i += 1){
desc[i] = rng(source[i], i); desc[i] = rng(source[i], i);
} }
var canvas = original.cloneNode(true); var canvas = original.cloneNode(true);

View File

@ -28,7 +28,7 @@
// extract the bit // extract the bit
var bit = (bitSet[index] >>> bitIndex) & 0x01; var bit = (bitSet[index] >>> bitIndex) & 0x01;
// XOR the bit the the value to alter the last bit of it... or not // XOR the bit and the value to alter the last bit of it... or not
return value ^ bit; return value ^ bit;
}; };
} }
@ -52,27 +52,8 @@
var rnd = randomNumbers[randomI]; var rnd = randomNumbers[randomI];
randomI += 1; randomI += 1;
// do not alter the most significant bit that is set and // XOR the last bit to alter it... or not
// the bit after it, to not disturb the image too much. return value ^ (rnd & 0x01);
if (value >= 0x80){
value = value ^ (rnd & 0x1F);
}
else if (value >= 0x40){
value = value ^ (rnd & 0x0F);
}
else if (value >= 0x20){
value = value ^ (rnd & 0x07);
}
else if (value >= 0x10){
value = value ^ (rnd & 0x03);
}
else if (value >= 0x08){
value = value ^ (rnd & 0x01);
}
// else if (value >= 0x04){
// value = value ^ (rnd * 0x00);
// }
return value;
}; };
} }
}; };