|
|
|
@ -104,7 +104,7 @@
|
|
|
|
|
import { getCodeImg } from "@/api/login";
|
|
|
|
|
import Cookies from "js-cookie";
|
|
|
|
|
import { encrypt, decrypt } from "@/utils/jsencrypt";
|
|
|
|
|
import {KEYUTIL, KJUR} from "jsrsasign"
|
|
|
|
|
import forge from 'node-forge'
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
name: "Login",
|
|
|
|
@ -134,6 +134,7 @@ export default {
|
|
|
|
|
register: false,
|
|
|
|
|
redirect: undefined,
|
|
|
|
|
userType:"01",
|
|
|
|
|
publicKey:`MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAl8bS1kYTiMhIS5MZU253bc0ukaxrA1lfCziABFxQrC2c09tMrQGjuH6V1x2ofNBMGhOD9uWN/qkAQy/HwOe/NKUqCw6N0ov6guSrqMDW/BdZ3Bl0rmM1/95jTC1xffFFvej7xWNffIbaPI+bJ4WLX9NViNi9HmT0BRNzJ4d2R86LPPCa+bxLaPjsh2R2tBkbLkUot9769aJaPPiwPCZHMkuQenjHSmpWL0okleqMH8EGX7j6A5A/4IUXPMNKMMzkiSRpsIJ65GJmDAbnR3ZXRfC8MzVBBJB6zr5N0F4N9xZfF+JS/Yx726tCu+rA6GDCyTxtQ/wnKpPdwFP5nUWCWQIDAQAB`
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
watch: {
|
|
|
|
@ -192,8 +193,29 @@ export default {
|
|
|
|
|
Cookies.remove("mima");
|
|
|
|
|
Cookies.remove("rememberMe");
|
|
|
|
|
}
|
|
|
|
|
// 生成一个 2048 位的 RSA 密钥对
|
|
|
|
|
const lines = [];
|
|
|
|
|
lines.push('-----BEGIN PUBLIC KEY-----');
|
|
|
|
|
for (let i = 0; i < this.publicKey.length; i += 64) {
|
|
|
|
|
lines.push(this.publicKey.slice(i, i + 64));
|
|
|
|
|
}
|
|
|
|
|
lines.push('-----END PUBLIC KEY-----');
|
|
|
|
|
lines.join('\n')
|
|
|
|
|
const publicKey = forge.pki.publicKeyFromPem(lines.join('\n'));
|
|
|
|
|
// 将待加密的字符串转换为字节数组
|
|
|
|
|
var dataBytes = forge.util.encodeUtf8(this.loginForm.mima);
|
|
|
|
|
// 加密数据
|
|
|
|
|
var encryptedBytes = publicKey.encrypt(dataBytes, 'RSA-OAEP', {
|
|
|
|
|
md: forge.md.sha256.create(),
|
|
|
|
|
mgf1: {
|
|
|
|
|
md: forge.md.sha1.create()
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
// 将加密后的字节数组转换为 Base64 编码的字符串
|
|
|
|
|
var encryptedBase64 = forge.util.encode64(encryptedBytes);
|
|
|
|
|
// console.log("加密后数据", encryptedBase64);
|
|
|
|
|
this.$store
|
|
|
|
|
.dispatch("Login", {...this.loginForm,userType:this.userType, password: encrypt(this.loginForm.mima)})
|
|
|
|
|
.dispatch("Login", {...this.loginForm,userType:this.userType, password: encryptedBase64})
|
|
|
|
|
.then(() => {
|
|
|
|
|
Cookies.set("newSysLogininfor", 1);
|
|
|
|
|
this.$router.push({ path: this.redirect || "/" }).catch(() => {});
|
|
|
|
|