天行健
君子以自强不息
地势坤
君子以厚德载物

vue sha512加密

  |   0 评论   |   0 浏览

方法1:(待测试)

npm install crypto-js --save

        function stringEncryption(type, txt) {
            if (txt.value.length == 0) {
                alert("要加密的文本不可为空");
                txtRef.value.focus();
                return;
            } else {
                if (type == 1) {
                    cryptTxt.value = CryptoJS.SHA1(txt.value).toString();
                } else if (type == 224) {
                    cryptTxt.value = CryptoJS.SHA224(txt.value).toString();
                } else if (type == 256) {
                    cryptTxt.value = CryptoJS.SHA256(txt.value).toString();
                } else if (type == 384) {
                    cryptTxt.value = CryptoJS.SHA384(txt.value).toString();
                } else if (type == 512) {
                    cryptTxt.value = CryptoJS.SHA512(txt.value).toString();
                }
            }

方法2:(测试可行)

npm install jssha --save

function stringEncryption() {
  // const jsSHA = require("jssha")
  const shaObj = new jsSHA("SHA-512", "TEXT", { encoding: "UTF8" });
  shaObj.update("test");
  return shaObj.getHash("HEX");
}

标题:vue sha512加密
作者:UncleLi
地址:https://www.yyliucha.com/articles/2023/01/09/1673254850285.html