Fingerprint is a tiny web page which lets you instantly generate canvas fingerprints for your browser! This is useful in discovering the extent to which your browser is susceptible to cross-site tracking via canvas-based techniques. The implementation really is tiny, with the core fingerprinting code only requiring about 300 bytes.
$ npx serve .
You can also driectly copy-and-paste the code below into your projects to add fingerprinting functionality. Note that code requires a secure execution context to run correctly.
async function createCanvasFingerprint() {
let canvasElement = document.createElement('canvas')
let canvasContext = canvasElement.getContext('2d')
canvasContext.fillText('abc', 0, 100)
canvasContext.beginPath()
canvasContext.arc(20, 20, 20, 0, 6)
canvasContext.fillStyle = 'red'
canvasContext.fill()
let canvasData = (new TextEncoder).encode(canvasElement.toDataURL())
let canvasFingerprint = await crypto.subtle.digest('sha-1', canvasData)
canvasFingerprint = new Uint8Array(canvasFingerprint)
canvasFingerprint = String.fromCharCode(...canvasFingerprint)
canvasFingerprint = btoa(canvasFingerprint)
return canvasFingerprint
}