Skip to content

Commit 5ac1471

Browse files
authored
Update demo.html
1 parent b527e34 commit 5ac1471

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

demo.html

+16-2
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,28 @@ <h1>Demonstration of Picasso Canvas</h1>
7777
</form>
7878

7979
<div style="text-align:center;" id="canvasgenerated"></div>
80+
Hash:<div id="hash"></div>
8081
</div>
8182
<div class="col"></div>
82-
Original implementation from: https://antoinevastel.com/browser%20fingerprinting/2019/03/21/picasso-canvas-fingerprinting.html
83+
Original Implementation from:
84+
https://antoinevastel.com/browser%20fingerprinting/2019/03/21/picasso-canvas-fingerprinting.html
8385
</div>
8486
</div>
8587

8688
<script src="canvas.js"></script>
8789

8890
<script>
89-
91+
String.prototype.hashCode = function() {
92+
var hash = 0, i, chr;
93+
if (this.length === 0) return hash;
94+
for (i = 0; i < this.length; i++) {
95+
chr = this.charCodeAt(i);
96+
hash = ((hash << 5) - hash) + chr;
97+
hash |= 0; // Convert to 32bit integer
98+
}
99+
return hash;
100+
};
101+
90102
document.getElementById('canvasbtn')
91103
.addEventListener('click', (e) => {
92104
e.preventDefault();
@@ -119,6 +131,8 @@ <h1>Demonstration of Picasso Canvas</h1>
119131
} else {
120132
document.getElementById('canvasgenerated').innerHTML = '<h2 class="alert alert-danger">An error occured</h2>';
121133
}
134+
135+
document.getElementById("hash").innerHTML = canvasValue.hashCode();
122136

123137
});
124138

0 commit comments

Comments
 (0)