Commit f3780f8c by 初志鑫

修改rsa加密方式

parent 6291db9d
...@@ -15,6 +15,8 @@ export default [ ...@@ -15,6 +15,8 @@ export default [
msg: "success", msg: "success",
data: { data: {
mockServer: true, mockServer: true,
publicKey:
"MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDBT2vr+dhZElF73FJ6xiP181txKWUSNLPQQlid6DUJhGAOZblluafIdLmnUyKE8mMHhT3R+Ib3ssZcJku6Hn72yHYj/qPkCGFv0eFo7G+GJfDIUeDyalBN0QsuiE/XzPHJBuJDfRArOiWvH0BXOv5kpeXSXM8yTt5Na1jAYSiQ/wIDAQAB",
}, },
}; };
}, },
......
...@@ -13,14 +13,13 @@ const privateKey = ...@@ -13,14 +13,13 @@ const privateKey =
export async function encryptedData(data) { export async function encryptedData(data) {
let publicKey = ""; let publicKey = "";
const res = await getPublicKey(); const res = await getPublicKey();
publicKey = res.data; publicKey = res.data.publicKey;
if (publicKey.mockServer) { if (res.data.mockServer) {
publicKey = ""; publicKey = "";
} }
if (publicKey == "") { if (publicKey == "") {
return data; return data;
} }
const encrypt = new JSEncrypt(); const encrypt = new JSEncrypt();
encrypt.setPublicKey( encrypt.setPublicKey(
`-----BEGIN PUBLIC KEY-----${publicKey}-----END PUBLIC KEY-----` `-----BEGIN PUBLIC KEY-----${publicKey}-----END PUBLIC KEY-----`
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment