This commit is contained in:
haozq 2024-11-26 11:56:05 +08:00
parent 6bd80c4120
commit 08e9b2326e
7 changed files with 57 additions and 6 deletions

View File

@ -17,6 +17,11 @@ const login_sg_page = URL_IP+"/sg_login.html" // 施工大屏登录页面
const login_sc_page = URL_IP+"/sc_login.html" // 省侧大屏登录页面
const login_sg_index = URL_IP+"/pages/home/navigation.html" // 施工大屏首页
const login_sc_index = URL_IP+"/pages/web/index.html" // 省侧大屏首页
/**
* 公钥
* @type {string}
*/
const public_key="04211520e8dc6d2051e67e6e770bd5550268c98105cd3b5b58e9c65958e78e627442343c9f237e01b3f316b1b63d7ddd70a8e6c0690a84c620b2903cb44cdfbe64";

View File

@ -15,11 +15,13 @@ layui.use(function () {
} else if (hrefUrl && hrefUrl.indexOf("sc_login") > 0) {
loginType = "1"
}
const params = {
"username": field.username,
"password": field.password,
"username": sm2Encrypt(public_key,field.username),
"password": sm2Encrypt(public_key,field.password),
"loginType": loginType
}
console.log(params)
let encryptStr = encryptCBC(JSON.stringify(params));
ajaxRequest(login_url, "POST", encryptStr, true, function () {

View File

@ -16,10 +16,11 @@ layui.use(function () {
loginType = "1"
}
const params = {
"username": field.username,
"password": field.password,
"username": sm2Encrypt(public_key,field.username),
"password": sm2Encrypt(public_key,field.password),
"loginType": loginType
}
console.log(params)
let encryptStr = encryptCBC(JSON.stringify(params));
ajaxRequest(login_url, "POST", encryptStr, true, function () {
console.log(1)

22
js/smutil/SM2Utils.js Normal file
View File

@ -0,0 +1,22 @@
let sm2CipherUtil = new SM2CipherUtil();
/**
* 加密
*/
function sm2Encrypt(public_key,text){
console.log(public_key,text);
return sm2CipherUtil.sm2Encrypt(public_key, text);
}
/**
* 私钥解密
*/
function sm2Decrypt(private_key,text){
return sm2CipherUtil.sm2Encrypt(private_key, text);
}
/**
* 生成 公钥和你要
* @returns {{privateKey: *, publicKey: *}}
*/
function doGenerate() {
return sm2CipherUtil.sm2GengenerateKeys();
}

8
js/smutil/yahoo-min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="plugin/layui-v2.9.7/layui/css/layui.css">
<link rel="stylesheet" href="css/font.css">
@ -23,6 +23,7 @@
<script src="js/smutil/utils.js"></script>
<script src="js/smutil/sm3.js"></script>
<script src="js/smutil/sm2.js"></script>
<script src="js/smutil/SM2Utils.js"></script>
<title>登录</title>
</head>

View File

@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="plugin/layui-v2.9.7/layui/css/layui.css">
<link rel="stylesheet" href="css/font.css">
@ -12,6 +12,18 @@
<script src="plugin/layui-v2.9.7/layui/layui.js"></script>
<script src="api/commonRequest.js" type="text/javascript"></script>
<script src="js/publics/aescbc.js"></script>
<script src="js/smutil/jsbn.js"></script>
<script src="js/smutil/jsbn2.js"></script>
<script src="js/smutil/prng4.js"></script>
<script src="js/smutil/rng.js"></script>
<script src="js/smutil/ec.js"></script>
<script src="js/smutil/ec-patch.js"></script>
<script src="js/smutil/ecdsa-modified-1.0.js"></script>
<script src="js/smutil/ecparam-1.0.js"></script>
<script src="js/smutil/utils.js"></script>
<script src="js/smutil/sm3.js"></script>
<script src="js/smutil/sm2.js"></script>
<script src="js/smutil/SM2Utils.js"></script>
<title>登录</title>
</head>