simplified
This commit is contained in:
parent
3a33bb0fad
commit
df41d19f26
1 changed files with 0 additions and 69 deletions
|
|
@ -21,75 +21,6 @@ if ( hasharray.length > 0 ) {
|
||||||
|
|
||||||
// fingerprint user
|
// fingerprint user
|
||||||
|
|
||||||
function cyrb53(str, seed = 0){
|
|
||||||
let h1 = 0xdeadbeef ^ seed, h2 = 0x41c6ce57 ^ seed;
|
|
||||||
for (let i = 0, ch; i < str.length; i++) {
|
|
||||||
ch = str.charCodeAt(i);
|
|
||||||
h1 = Math.imul(h1 ^ ch, 2654435761);
|
|
||||||
h2 = Math.imul(h2 ^ ch, 1597334677);
|
|
||||||
}
|
|
||||||
h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507) ^ Math.imul(h2 ^ (h2 >>> 13), 3266489909);
|
|
||||||
h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507) ^ Math.imul(h1 ^ (h1 >>> 13), 3266489909);
|
|
||||||
return 4294967296 * (2097151 & h2) + (h1 >>> 0);
|
|
||||||
};
|
|
||||||
|
|
||||||
function audioFingerprint() {
|
|
||||||
const AudioContext = window.OfflineAudioContext || window.webkitOfflineAudioContex;
|
|
||||||
const context = new AudioContext(1, 5000, 44100);
|
|
||||||
const oscillator = context.createOscillator();
|
|
||||||
oscillator.type = "triangle";
|
|
||||||
oscillator.frequency.value = 1000;
|
|
||||||
const compressor = context.createDynamicsCompressor()
|
|
||||||
compressor.threshold.value = -50;
|
|
||||||
compressor.knee.value = 40;
|
|
||||||
compressor.ratio.value = 12;
|
|
||||||
compressor.reduction.value = 20;
|
|
||||||
compressor.attack.value = 0;
|
|
||||||
compressor.release.value = 0.2;
|
|
||||||
oscillator.connect(compressor);
|
|
||||||
compressor.connect(context.destination);
|
|
||||||
oscillator.start()
|
|
||||||
context.oncomplete = event => {
|
|
||||||
const samples = event.renderedBuffer.getChannelData(0);
|
|
||||||
let hash = 0;
|
|
||||||
for (let i = 0; i < samples.length; ++i) {
|
|
||||||
hash += Math.abs(samples[i]);
|
|
||||||
}
|
|
||||||
return hash;
|
|
||||||
};
|
|
||||||
context.startRendering();
|
|
||||||
}
|
|
||||||
|
|
||||||
function canvasFingerprint() {
|
|
||||||
var canvas = document.createElement('canvas');
|
|
||||||
var ctx = canvas.getContext('2d');
|
|
||||||
var txt = 'Numinous Field Communication';
|
|
||||||
ctx.textBaseline = "top";
|
|
||||||
ctx.font = "14px 'Arial'";
|
|
||||||
ctx.textBaseline = "alphabetic";
|
|
||||||
ctx.fillStyle = "#f60";
|
|
||||||
ctx.fillRect(125, 1, 62, 20);
|
|
||||||
ctx.fillStyle = "#069";
|
|
||||||
ctx.fillText(txt, 2, 15);
|
|
||||||
ctx.fillStyle = "rgba(102, 204, 0, 0.7)";
|
|
||||||
ctx.fillText(txt, 4, 17);
|
|
||||||
src = canvas.toDataURL();
|
|
||||||
var hash;
|
|
||||||
for (i = 0; i < src.length; i++) {
|
|
||||||
char = src.charCodeAt(i);
|
|
||||||
hash = ((hash<<5)-hash)+char;
|
|
||||||
hash = hash & hash;
|
|
||||||
}
|
|
||||||
return hash;
|
|
||||||
};
|
|
||||||
|
|
||||||
function getFingerprint() {
|
|
||||||
const audioFp = audioFingerprint();
|
|
||||||
const canvasFp = canvasFingerprint();
|
|
||||||
const hash = cyrb53(audioFp + canvasFp);
|
|
||||||
return hash;
|
|
||||||
};
|
|
||||||
|
|
||||||
const generateUUID = () => {
|
const generateUUID = () => {
|
||||||
let
|
let
|
||||||
d = new Date().getTime(),
|
d = new Date().getTime(),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue