根据浏览器信息
生成浏览器唯一识别码
转自: 点赞需求使用canvas fingerprinting(画布指纹追踪)的过程
function bin2hex(s) {
var i, l, o = '', n;
s += '';
for (i = 0, l = s.length; i < l; i++) {
n = s.charCodeAt(i).toString(16);
o += n.length < 2 ? '0' + n : n;
}
return o;
}
function getUUID(domain) {
var canvas = document.createElement('canvas');
var ctx = canvas.getContext("2d");
ctx.font = "24px Arial";
ctx.fillText("Hello Panda", 22, 33);
ctx.moveTo(0, 60);
ctx.lineTo(100, 60);
ctx.stroke();
var b64 = canvas.toDataURL().replace("data:image/png;base64,","");
var bin = atob(b64);
var crc = bin2hex(bin.slice(-16, -12));
return crc;
}
console.log(getUUID("chenxiaomo"));