crypto-js HMACSHA256加密 前端js加密

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/xss392795158/article/details/78863418
<script src="core.js"></script>
<script src="hmac.js"></script>
<script src="sha256.js"></script>
<script src="enc-base64.js"></script>

<input type="text" id="pwd" />
<button onclick="aa()">jiami</button>
<script type="text/javascript">
    function aa() {
        var val = document.getElementById('pwd').value;
        //此处只能是"Message",不然会加密结果不对
        var hash = CryptoJS.HmacSHA256("Message", val);
        var hashInBase64 = CryptoJS.enc.Base64.stringify(hash);
        console.log(hashInBase64)
    }
</script>

crypto-js加密,只关注加载依赖顺序
sha256 > hmac > core,
enc-base64 > core

猜你喜欢

转载自blog.csdn.net/xss392795158/article/details/78863418