Created
March 29, 2020 22:29
-
-
Save mStirner/eced07bddf428f9df2e905987ecac356 to your computer and use it in GitHub Desktop.
canvas fingerprint
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var makeCRCTable = function(){ | |
var c; | |
var crcTable = []; | |
for(var n =0; n < 256; n++){ | |
c = n; | |
for(var k =0; k < 8; k++){ | |
c = ((c&1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1)); | |
} | |
crcTable[n] = c; | |
} | |
return crcTable; | |
} | |
var crc32 = function(str) { | |
var crcTable = window.crcTable || (window.crcTable = makeCRCTable()); | |
var crc = 0 ^ (-1); | |
for (var i = 0; i < str.length; i++ ) { | |
crc = (crc >>> 8) ^ crcTable[(crc ^ str.charCodeAt(i)) & 0xFF]; | |
} | |
return (crc ^ (-1)) >>> 0; | |
}; | |
var canvas = document.createElement('canvas'); | |
var body = document.getElementsByTagName("body")[0]; | |
body.appendChild(canvas); | |
cursorLayer = document.getElementById("CursorLayer"); | |
console.log(cursorLayer); | |
// below is optional | |
var ctx = canvas.getContext("2d"); | |
// Text with lowercase/uppercase/punctuation symbols | |
var txt = "BrowserLeaks,com <canvas> 1.0"; | |
ctx.textBaseline = "top"; | |
// The most common type | |
ctx.font = "14px 'Arial'"; | |
ctx.textBaseline = "alphabetic"; | |
ctx.fillStyle = "#f60"; | |
ctx.fillRect(125,1,62,20); | |
// Some tricks for color mixing to increase the difference in rendering | |
ctx.fillStyle = "#069"; | |
ctx.fillText(txt, 2, 15); | |
ctx.fillStyle = "rgba(102, 204, 0, 0.7)"; | |
ctx.fillText(txt, 4, 17); | |
//console.log(ctx.toDataURL()) | |
let binary = canvas.toDataURL().split(",")[1]; | |
console.log(crc32(binary).toString("16")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment