<script src="/static/js/libs/jsencrypt.js"></script>
<script src="/static/js/libs/jsbn.js"></script>
//markjs把文本变成html
<script src="/static/js/libs/marked.js" type="text/javascript"></script>
function getPk(){//页面加载时,获取公钥
$ajax({
url:'/api/dummy',
type:'GET',
dataType:'json',
error:function(data){},
success:function(res){
exponent=res.exponent;
moudulus=res.modulus.split('-')[1];
}
})
}
function doLogin(){
var name=$("#user").val();
var pwdVal=encodeURIComponent($("#pwd").val());
crypt.setKey({
e:exponent,
n:new BigInteger(modulus,10),
});
var pkey=crypt.getKey();
var pwd=pkey.encrypt(pwdVal);
$.ajax({
type:"POST",
url:"/apo/login",
async:true,
data:{
user:name,
pwd:pwd
},
dataType:"json",
error:function(data){
var res=JSON.parse(data.responseText);
$(".login-note").html(window.decodeURIComponent(res.Message));
},
success:function(res){
window.location.href="/home.html";
}
});
}
$("#indexNoticeMarked").html(marked(notice.content));
RSA加密的使用
最新推荐文章于 2024-06-23 21:18:46 发布