Skip to content

Instantly share code, notes, and snippets.

@arzzen
Created October 30, 2020 08:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arzzen/d985afe599901183c232c88afb421afa to your computer and use it in GitHub Desktop.
Save arzzen/d985afe599901183c232c88afb421afa to your computer and use it in GitHub Desktop.
simple javascript fingerprint
var fingerprint = (function(window, screen, navigator) {
function checksum(str) {
var hash = 5381,
i = str.length;
while (i--) hash = (hash * 33) ^ str.charCodeAt(i);
return hash >>> 0;
}
function map(arr, fn){
var i = 0, len = arr.length, ret = [];
while(i < len){
ret[i] = fn(arr[i++]);
}
return ret;
}
return checksum([
navigator.userAgent,
[screen.height, screen.width, screen.colorDepth].join('x'),
new Date().getTimezoneOffset(),
!!window.sessionStorage,
!!window.localStorage,
map(navigator.plugins, function (plugin) {
return [
plugin.name,
plugin.description,
map(plugin, function (mime) {
return [mime.type, mime.suffixes].join('~');
}).join(',')
].join("::");
}).join(';')
].join('###'));
}(this, screen, navigator));
document.body.innerHTML = fingerprint;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment