rsa
链接:https://pan.baidu.com/s/1cbxUl4dBdVgtNvUxsajQUA
提取码:9elm
复制这段内容后打开百度网盘手机App,操作更方便哦
aes
链接:https://pan.baidu.com/s/1zQAMIkHciB8UT2tW6qd1eA
提取码:ogt4
复制这段内容后打开百度网盘手机App,操作更方便哦
使用方式
aesJm() {
// AES加密
let str = CryptoJS.encrypt("123", 'A1FF913678E8BBE1CC7BC9111E09BD7C', 256).toString();
console.log(str);
// AES解密
str = CryptoJS.decrypt(str, 'wwwA1FF913678E8BBE1CC7BC9111E09BD7C', 256);
//str = str.toString(CryptoJS.enc.Utf8).toString();
console.log(str);
}
rsaJm() {
// 加密前的原文
// console.log('这是原文' + $('#input').val())
let gg = '123456';
let a = 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC8JU1nBDZ5PgRNAxksTC/MlaBX37vjTH84ppzmuEpH7e6G43QXd7Zof8apIJ4efk6Uiw2/OJfkyMGDsAJTv/zWnuKm6UeyBYxtgP5JFGtTMKTBVuGzH8UzYWdPzybIOCmj55Qku3nYEZyro38dGhSFLSPaU3eoY1tblm5ZFJ+8ewIDAQAB';
// 进行RSA加密
var encrypt = new JSEncrypt();
encrypt.setPublicKey(a);
var encrypted = encrypt.encrypt(gg);
// 加密后的密文
console.log('这是加密之后的' + encrypted);
let b = 'MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBALwlTWcENnk+BE0DGSxML8yVoFffu+NMfzimnOa4Skft7objdBd3tmh/xqkgnh5+TpSLDb84l+TIwYOwAlO//Nae4qbpR7IFjG2A/kkUa1MwpMFW4bMfxTNhZ0/PJsg4KaPnlCS7edgRnKujfx0aFIUtI9pTd6hjW1uWblkUn7x7AgMBAAECgYEAsoOaK1Jd9S+YmRGFgvhOqgiV+Ip6FTJxy2iamnblU9Y3aZjKf7HASuphrfsay8f/+wTs6DBkPlkU80O/EYOp+r46UIKq5KChW2ErUVaMyxO4f8l0PW2RFHFYWq54SbRa73DepPeC3o9LRinEaJ7/rk13EHiS6RAPkFr/ZyTOYdECQQD0BNI4Wg4gJqZHC1QCHOQUaF2cDWh5cadWT9FOXKdgRUrP+2W67BJP/RjNPT++/cyP3pdNc8vMCkF8IGgJ7Pk/AkEAxWIwCK3prAxupNrlUhPNT+nfG05Bs0SYIQHSiwUykXkcUZAcAveNk2g8XlhAQ4fEZG9BQ0+MlA246FV90NlRxQJAJEm7QWoTA7D7tUD4A0BsoqRKl3Re/wBp1CoWhEK/GU/0qi1GmZ+VsZN/5rWfDzYK/7Ioafo4amV0C5N+JUu6XQJANbDuxf2guYcsNbXBeWEfkSRZ5xCTeJMpGplnTx+b0Mxz8o/Tvs7d+QH6oeM5n+T3fCZzRz8FS2SsLq7KqZvjzQJADLfcfxaYd3V7e0/Op08ifDyCjpLa3rviNFss/msOR3Mzfg7J05wD3oVHut+g+RVF7+Gnia07pV5YnFVd0WA1UA==';
//解密
var decrypt = new JSEncrypt();
decrypt.setPrivateKey(b);
var uncrypted = decrypt.decrypt(encrypted);
console.log('这是解密后的密文' + uncrypted);
}