Capture mouse movements for entropy

This commit is contained in:
bip32jp
2014-12-31 22:33:22 +09:00
parent 184635fb34
commit d819a10067
3 changed files with 30 additions and 2 deletions
+26
View File
@@ -813,4 +813,30 @@ $(document).ready(function() {
$("#newKeysBtn").click();
validateOutputAmount();
/* capture mouse movement to add entropy */
var IE = document.all?true:false // Boolean, is browser IE?
if (!IE) document.captureEvents(Event.MOUSEMOVE)
document.onmousemove = getMouseXY;
function getMouseXY(e) {
var tempX = 0;
var tempY = 0;
if (IE) { // If browser is IE
tempX = event.clientX + document.body.scrollLeft;
tempY = event.clientY + document.body.scrollTop;
} else {
tempX = e.pageX;
tempY = e.pageY;
};
if (tempX < 0){tempX = 0};
if (tempY < 0){tempY = 0};
var xEnt = Crypto.util.bytesToHex([tempX]);
var yEnt = Crypto.util.bytesToHex([tempY]);
var addEnt = xEnt.concat(yEnt);
if ($("#entropybucket").html().indexOf(xEnt) == -1 && $("#entropybucket").html().indexOf(yEnt) == -1) {
$("#entropybucket").html(addEnt + $("#entropybucket").html());
};
if ($("#entropybucket").html().length > 128) {$("#entropybucket").html($("#entropybucket").html().slice(0, 128))};
return true;
};
});