js哈希256加密示例

代码示例如下

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.1.1/core.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.1.1/sha256.js"></script>
<script>
    const data = '😀🐢小可爱';
    const hash = CryptoJS.SHA256(data).toString();
    console.log(hash);
</script>
</body>
</html>

备注:亲测可行,和php加密出的效果一致

未经允许不得转载:肥猫博客 » js哈希256加密示例

赞 (0)
分享到: 更多

评论 0