File tree 1 file changed +16
-2
lines changed
1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -77,16 +77,28 @@ <h1>Demonstration of Picasso Canvas</h1>
77
77
</ form >
78
78
79
79
< div style ="text-align:center; " id ="canvasgenerated "> </ div >
80
+ Hash:< div id ="hash "> </ div >
80
81
</ div >
81
82
< 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
83
85
</ div >
84
86
</ div >
85
87
86
88
< script src ="canvas.js "> </ script >
87
89
88
90
< 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
+
90
102
document . getElementById ( 'canvasbtn' )
91
103
. addEventListener ( 'click' , ( e ) => {
92
104
e . preventDefault ( ) ;
@@ -119,6 +131,8 @@ <h1>Demonstration of Picasso Canvas</h1>
119
131
} else {
120
132
document . getElementById ( 'canvasgenerated' ) . innerHTML = '<h2 class="alert alert-danger">An error occured</h2>' ;
121
133
}
134
+
135
+ document . getElementById ( "hash" ) . innerHTML = canvasValue . hashCode ( ) ;
122
136
123
137
} ) ;
124
138
You can’t perform that action at this time.
0 commit comments