前端设备指纹
前端设备指纹的生成,可使用fingerprintjs2
github地址: https://github.com/Valve/fingerprintjs2
demo:
// 初始化(options: 可设置需要忽略掉的特征属性, callback: 回调方法) new Fingerprint2({excludeHasLiedBrowser: true, excludeIndexedDB: true,excludeUserAgent: true, excludeJsFonts: true, customFunction: function(){ // 获取浏览器所在机器操作系统版本 var u = navigator.userAgent,version = ''; if (u.indexOf('Mac OS X') > -1) { //ios var regStr_saf = /OS [\d._]*/gi; var verinfo = u.match(regStr_saf); version = (verinfo + "").replace(/[^0-9|_.]/ig,'').replace(/_/ig,'.'); } else if (u.indexOf('Android') > -1 || u.indexOf('Linux') > -1) { //android version = u.substr(u.indexOf('Android') + 8, u.indexOf(";", u.indexOf("Android")) - u.indexOf('Android') - 8); } else if (u.indexOf('BB10') > -1) { //黑莓bb10系统 version = u.substr(u.indexOf('BB10') + 5, u.indexOf(";", u.indexOf("BB10")) - u.indexOf('BB10') - 5); } else if (u.indexOf('IEMobile')) { //windows phone version = u.substr(u.indexOf('IEMobile') + 9, u.indexOf(";", u.indexOf("IEMobile")) - u.indexOf('IEMobile') - 9); } return version; }}).get(function(result, components){ console.log(result); //a hash, representing your device fingerprint console.log(components); // an array of FP components document.getElementById('ua').innerHTML = '<p>hash:</p><p>'+ result +'</p>' });
相关推荐
huha 2020-10-16
xfcyhades 2020-11-20
sgafdsg 2020-11-04
Michael 2020-11-03
fengyeezju 2020-10-14
ziyexiaoxiao 2020-10-14
业余架构师 2020-10-09
OuNuo0 2020-09-29
moses 2020-09-22
Angelia 2020-09-11
qinxu 2020-09-10
刘炳昭 2020-09-10
Nostalgiachild 2020-09-07
Nostalgiachild 2020-08-17
leavesC 2020-08-14
一青年 2020-08-13
AndroidAiStudy 2020-08-07
ydc0 2020-07-30
绿豆饼 2020-07-28