How to identify unique devices using javascript?

You can use the fingerprintJS2 library for your project too.

How this library gets fingerprints

Fingerprint.js collects all the unique features from a device/browser passing them through a hash function to provide a unique identifier.

Example enter image description here

There are many other ways to get unique browser fingerprint.

The newest method to obtain browser information is called “Canvas Fingerprinting.” Simply put, websites are written in HTML5 code, and inside that code, there is a little piece of code that takes your browser’s fingerprint.

So, how are websites doing that, exactly? Let me explain.

This new tracking method that websites employ to obtain your browser fingerprint is enabled by new coding features in HTML5.

HTML5 is the coding language used to build websites. It’s the core fundamentals of every website. Within the HTML5 coding language, there’s an element which is called “canvas.”

Originally, the HTML element was used to draw graphics on a web page.

Wikipedia provides the following explanation on how exploiting the HTML5 canvas element generates browser fingerprinting:

“When a user visits a page, the fingerprinting script first draws text with the font and size of its choice and adds background colors. Next, the script calls Canvas API’s ToDataURL method to get the canvas pixel data in dataURL format, which is basically a Base64 encoded representation of the binary pixel data. Finally, the script takes the hash of the text-encoded pixel data, which serves as the fingerprint."

In plain English, what this means is that the HTML5 canvas element generates certain data, such as the font size and active background color settings of the visitor’s browser, on a website. This information serves as the unique fingerprint of every visitor.

In contrast to how cookies work, canvas fingerprinting doesn’t load anything onto your computer, so you won’t be able to delete any data, since it’s not stored on your computer or device, but elsewhere.

Source and further reading:

By the way you can get much more information from Googling yourself.

I am using fingerprintjs.library for creating a browser fingerprint it works well with all device but when i test fingerprint in exact configuration device like laptop with exact configuration it generate same fingerprint. Before implementation i read many blogs says canvas fingerprint generate unique base64 string but when i tested in device with same configuration it generate same canvas fingerprint. The canvas fingerprint is not unique in exact or similar device.

While using fingerprint.Js libary, i made some option disable like plugins, enumerate device, browser version because this are dynamic in nature on adding headphone in device fingerprint will read headphone information or generate fingerprint accordingly or same with browser version. fingerprint will vary if any of this thing change in future. My requirement was to create a unique & constant fingerprint that donot change even after opening browser after somedays.