From 1eea4dfa85003564e91a76dc28a7051372f0304b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=87=AA=E5=B8=A6=E5=A4=A7=E4=BD=AC=E6=B0=94=E5=9C=BA?= <188633308@qq.com> Date: Thu, 13 May 2021 00:07:42 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E5=89=8D=E7=AB=AF=E5=8A=A0=E5=85=A5RS?= =?UTF-8?q?A=E9=9D=9E=E5=AF=B9=E7=A7=B0=E5=8A=A0=E5=AF=86,=E5=90=8E?= =?UTF-8?q?=E7=AB=AF=E6=9A=82=E6=97=B6=E5=85=B3=E9=97=AD=E5=8A=A0=E5=AF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Api/Ewide.Core/Service/Auth/AuthService.cs | 2 +- Web/package.json | 1 + Web/src/common/login/index.js | 1 + Web/src/util/rsa/index.js | 13 +++++++++++++ Web/yarn.lock | 5 +++++ 5 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 Web/src/util/rsa/index.js diff --git a/Api/Ewide.Core/Service/Auth/AuthService.cs b/Api/Ewide.Core/Service/Auth/AuthService.cs index b9b3773..f57cbd1 100644 --- a/Api/Ewide.Core/Service/Auth/AuthService.cs +++ b/Api/Ewide.Core/Service/Auth/AuthService.cs @@ -70,7 +70,7 @@ namespace Ewide.Core.Service [AllowAnonymous] public async Task LoginAsync([Required] LoginInput input) { - string pwd = RSAHandler.RSADecrypt(input.Password); + var pwd = input.Password; // RSAHandler.RSADecrypt(input.Password); // 获取加密后的密码 var encryptPasswod = MD5Encryption.Encrypt(pwd); diff --git a/Web/package.json b/Web/package.json index b1f0c80..02b1808 100644 --- a/Web/package.json +++ b/Web/package.json @@ -14,6 +14,7 @@ "crypto-js": "^4.0.0", "echarts": "^5.0.2", "highlight.js": "^10.7.2", + "jsencrypt": "^3.2.0", "less": "^3.12.2", "less-loader": "4.1.0", "lodash": "^4.17.21", diff --git a/Web/src/common/login/index.js b/Web/src/common/login/index.js index 27098ce..a1adb23 100644 --- a/Web/src/common/login/index.js +++ b/Web/src/common/login/index.js @@ -1,6 +1,7 @@ import { api } from '@/common/api' import { token } from '@/common/token' import { encryptByDES, decryptByDES } from '@/util/des' +import { encryptByRSA } from '@/util/rsa' import { removeGlobal } from '@/util/global' import app from '@/main' diff --git a/Web/src/util/rsa/index.js b/Web/src/util/rsa/index.js new file mode 100644 index 0000000..8047452 --- /dev/null +++ b/Web/src/util/rsa/index.js @@ -0,0 +1,13 @@ +import { JSEncrypt } from 'jsencrypt' +/** + * RSA加解密 + */ +const encryptByRSA = (message, publicKey) => { + const Encrypt = new JSEncrypt() + Encrypt.setPublicKey(publicKey) + return Encrypt.encrypt(message) +} + +export { + encryptByRSA +} \ No newline at end of file diff --git a/Web/yarn.lock b/Web/yarn.lock index b89bf90..0760d99 100644 --- a/Web/yarn.lock +++ b/Web/yarn.lock @@ -5191,6 +5191,11 @@ jsbn@~0.1.0: resolved "https://registry.npm.taobao.org/jsbn/download/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513" integrity sha1-peZUwuWi3rXyAdls77yoDA7y9RM= +jsencrypt@^3.2.0: + version "3.2.0" + resolved "https://registry.nlark.com/jsencrypt/download/jsencrypt-3.2.0.tgz?cache=0&sync_timestamp=1619388058064&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fjsencrypt%2Fdownload%2Fjsencrypt-3.2.0.tgz#09242aabf1984165dcd7698fe6ed163be77c05f8" + integrity sha1-CSQqq/GYQWXc12mP5u0WO+d8Bfg= + jsesc@^2.5.1: version "2.5.2" resolved "https://registry.npm.taobao.org/jsesc/download/jsesc-2.5.2.tgz?cache=0&sync_timestamp=1603891224688&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fjsesc%2Fdownload%2Fjsesc-2.5.2.tgz#80564d2e483dacf6e8ef209650a67df3f0c283a4"