Js实现AES/RSA加密

1.
function aesEncrypt(text, secKey) {
    var key = CryptoJS.enc.Utf8.parse(secKey);
    var iv = CryptoJS.enc.Utf8.parse("0102030405060708");
    var srcs = CryptoJS.enc.Utf8.parse(text);
    var encrypted = CryptoJS.AES.encrypt(srcs, key, {
        iv: iv,
        mode: CryptoJS.mode.CBC
    });
    return encrypted.toString()
}
function rsaEncrypt(text, pubKey, modulus) {
    setMaxDigits(131);
    var keys = new RSAKeyPair(pubKey,"",modulus);
    var encText = encryptedString(keys, text);
    return encText
}

2.   

function b(a, b) {
        var c = CryptoJS.enc.Utf8.parse(b),
            d = CryptoJS.enc.Utf8.parse("0102030405060708"),
            e = CryptoJS.enc.Utf8.parse(a),
            f = CryptoJS.AES.encrypt(e, c, {
                iv: d,
                mode: CryptoJS.mode.CBC
            });
        return f.toString()
    }
    function c(a, b, c) {
        var d,
            e;
        return setMaxDigits(131), d = new RSAKeyPair(b, "", c), e = encryptedString(d, a)
    }

  

posted @ 2016-02-25 17:38  sofootball  阅读(6512)  评论(0编辑  收藏  举报