From f3780f8ccf99787396c6e0e34462a9bbe96af015 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=9D=E5=BF=97=E9=91=AB?= <1204505056@qq.com> Date: Tue, 21 Jul 2020 17:29:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9rsa=E5=8A=A0=E5=AF=86?= =?UTF-8?q?=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mock/controller/user.js | 2 ++ src/utils/encrypt.js | 5 ++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/mock/controller/user.js b/mock/controller/user.js index 97a0bb9..e48ad9e 100644 --- a/mock/controller/user.js +++ b/mock/controller/user.js @@ -15,6 +15,8 @@ export default [ msg: "success", data: { mockServer: true, + publicKey: + "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDBT2vr+dhZElF73FJ6xiP181txKWUSNLPQQlid6DUJhGAOZblluafIdLmnUyKE8mMHhT3R+Ib3ssZcJku6Hn72yHYj/qPkCGFv0eFo7G+GJfDIUeDyalBN0QsuiE/XzPHJBuJDfRArOiWvH0BXOv5kpeXSXM8yTt5Na1jAYSiQ/wIDAQAB", }, }; }, diff --git a/src/utils/encrypt.js b/src/utils/encrypt.js index 740b175..86abe2d 100644 --- a/src/utils/encrypt.js +++ b/src/utils/encrypt.js @@ -13,14 +13,13 @@ const privateKey = export async function encryptedData(data) { let publicKey = ""; const res = await getPublicKey(); - publicKey = res.data; - if (publicKey.mockServer) { + publicKey = res.data.publicKey; + if (res.data.mockServer) { publicKey = ""; } if (publicKey == "") { return data; } - const encrypt = new JSEncrypt(); encrypt.setPublicKey( `-----BEGIN PUBLIC KEY-----${publicKey}-----END PUBLIC KEY-----`