• canvas获取浏览器指纹-唯一的设备标识


    <meta charset="utf-8">
    <title>canvas获取浏览器指纹-唯一的设备标识</title>
    
    <script>
        function bin2hex(str) {
            var result = "";
            for (i = 0; i < str.length; i++ ) {
                result += int16_to_hex(str.charCodeAt(i));
            }
            return result;
        }
        
        function int16_to_hex(i) {
            var result = i.toString(16);
            var j = 0;
            while (j+result.length < 4){
                result = "0" + result;
                j++;
            }
            return result;
        }
    function cans(str){
        var canvas = document.createElement('canvas');
        var ctx = canvas.getContext('2d');
        var txt = 'http://security.tencent.com/';
        ctx.textBaseline = "top";
        ctx.font = "14px 'Arial'";
        ctx.textBaseline = "tencent";
        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);
        
        var b64 = canvas.toDataURL().replace("data:image/png;base64,","");
        var bin = atob(b64);
        var crc = bin2hex(bin.slice(-16,-12));
        //var crc = bin.slice(-16,-12);
    return crc;//alert(crc);
    }
    cans()
    </script>
     
    
    <p>canvas获取浏览器指纹-唯一的设备标识:<span id="cab"></span></p>
    <br /><br />
    
    
    <script>
    document.getElementById("cab").innerHTML=cans("http://security.tencent.com/");
    </script>
  • 相关阅读:
    Android_存储访问框架SAF
    Android_基础之分辨率
    Android_存储之SharedPreferences
    Android_存储之DataBase之Room
    Android_AndroidX简介&Junit4
    Android_四大组件之ContentProvider
    Android_四大组件之BroadcastReceiver
    Android_四大组件之Service
    Android启动过程_大致流程
    福利来袭,赶紧上车!
  • 原文地址:https://www.cnblogs.com/7qin/p/14230903.html
Copyright © 2020-2023  润新知