提交 6aa3b4a0 编写于 作者: chengxiang.li's avatar chengxiang.li

update code

上级 5dac938f
import fetch from '@/utils/fetch'
import { getBaseUrl, getReportUrl, getWorkApi } from '@/utils/index'
import { CryptoJS } from '@/plugins/aes'
module.exports = {
data: function () {
......@@ -16,6 +17,32 @@ module.exports = {
},
methods: {
// generate key
getAesKey(len) {
len = len || 16;
var aesKey = "";
var strList = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
var strLen = strList.length;
for(var i=0; i<len; i++){
aesKey += strList.charAt( Math.floor( Math.random()*strLen ) );
};
return aesKey;
},
// AES encrypt
AesEncrypt(content) {
let key = this.getAesKey(16);
let sKey = CryptoJS.enc.Utf8.parse(key);
let sContent = CryptoJS.enc.Utf8.parse(content);
let encrypted = CryptoJS.AES.encrypt(sContent, sKey, {mode:CryptoJS.mode.ECB,padding: CryptoJS.pad.Pkcs7});
return encrypted.toString();
},
// RSA encrypt
RsaEncrypt(data){
let _encrypt = new JSEncrypt();
_encrypt.setPublicKey(boss_public_key);
let encrypted = _encrypt.encrypt(data);
return encrypted;
},
getUrlPara(obj) {
let dataStr = ''
let list = [];
......
......@@ -94,8 +94,6 @@
import { mapActions } from 'vuex';
import md5 from 'js-md5';
import { CryptoJS } from '@/plugins/aes'
export default {
name: "login",
data() {
......@@ -231,32 +229,7 @@
})
},
// generate key
getAesKey(len) {
len = len || 16;
var aesKey = "";
var strList = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
var strLen = strList.length;
for(var i=0; i<len; i++){
aesKey += strList.charAt( Math.floor( Math.random()*strLen ) );
};
return aesKey;
},
// AES encrypt
AesEncrypt(content) {
let key = this.getAesKey(16);
let sKey = CryptoJS.enc.Utf8.parse(key);
let sContent = CryptoJS.enc.Utf8.parse(content);
let encrypted = CryptoJS.AES.encrypt(sContent, sKey, {mode:CryptoJS.mode.ECB,padding: CryptoJS.pad.Pkcs7});
return encrypted.toString();
},
// RSA encrypt
RsaEncrypt(data){
let _encrypt = new JSEncrypt();
_encrypt.setPublicKey(boss_public_key);
let encrypted = _encrypt.encrypt(data);
return encrypted;
},
login() {
if(!this.loginData.mobile) {
this.loginMobileErr = true;
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册