From-wh 2 лет назад
Родитель
Сommit
e18022e00e

+ 6 - 0
template/admin/package-lock.json

@@ -15642,6 +15642,12 @@
       "integrity": "sha1-a9KZwTsMRiay2iwDk81DhdYGrLk=",
       "dev": true
     },
+    "jsencrypt": {
+      "version": "3.3.2",
+      "resolved": "https://registry.npmmirror.com/jsencrypt/-/jsencrypt-3.3.2.tgz",
+      "integrity": "sha512-arQR1R1ESGdAxY7ZheWr12wCaF2yF47v5qpB76TtV64H1pyGudk9Hvw8Y9tb/FiTIaaTRUyaSnm5T/Y53Ghm/A==",
+      "dev": true
+    },
     "jsesc": {
       "version": "2.5.2",
       "resolved": "https://registry.npmmirror.com/jsesc/-/jsesc-2.5.2.tgz",

+ 1 - 0
template/admin/package.json

@@ -100,6 +100,7 @@
     "eslint-plugin-prettier": "^3.4.1",
     "eslint-plugin-vue": "^7.2.0",
     "iview-loader": "^1.3.0",
+    "jsencrypt": "^3.3.2",
     "less": "^2.7.3",
     "less-loader": "^4.1.0",
     "lint-staged": "^6.0.0",

+ 11 - 0
template/admin/src/components/verifition/utils/ase.js

@@ -9,3 +9,14 @@ export function aesEncrypt(word, keyWord = 'XwKsGlMcdPMEhR1B') {
   var encrypted = CryptoJS.AES.encrypt(srcs, key, { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7 });
   return encrypted.toString();
 }
+
+/**
+ * @word hash256要加密的内容
+ * @keyWord String  服务器随机返回的关键字
+ *  */
+export function aesEncryptHash(word, keyWord = 'XwKsGlMcdPMEhR1B') {
+  var key = CryptoJS.enc.Utf8.parse(keyWord);
+  var srcs = CryptoJS.enc.Utf8.parse(word);
+  var encrypted = CryptoJS.HmacSHA256(srcs, key);
+  return CryptoJS.enc.Hex.stringify(encrypted);
+}

+ 5 - 1
template/admin/src/pages/account/login/index.vue

@@ -75,6 +75,8 @@ import '@/assets/js/canvas-nest.min';
 import Verify from '@/components/verifition/Verify';
 import { PrevLoading } from '@/utils/loading.js';
 import { formatFlatteningRoutes, findFirstNonNullChildren } from '@/libs/system';
+import { encryptWithKey } from '@/utils/ase.js';
+
 export default {
   components: {
     Verify,
@@ -106,6 +108,7 @@ export default {
       key: '',
       copyright: '',
       version: '',
+      publicKey: '',
     };
   },
   created() {
@@ -169,6 +172,7 @@ export default {
           this.swiperList = data.slide.length ? data.slide : [{ slide: this.defaultSwiperList }];
           this.key = data.key;
           this.copyright = data.copyright;
+          this.publicKey = data.publicKey;
           this.version = data.version;
           this.login_captcha = data.login_captcha;
         })
@@ -192,7 +196,7 @@ export default {
       this.loading = true;
       AccountLogin({
         account: this.formInline.username,
-        pwd: this.formInline.password,
+        pwd: encryptWithKey(this.formInline.password, this.publicKey),
         key: this.key,
         captchaType: 'blockPuzzle',
         captchaVerification: params ? params.captchaVerification : '',

+ 22 - 0
template/admin/src/utils/ase.js

@@ -0,0 +1,22 @@
+import CryptoJS from 'crypto-js';
+import JSEncrypt from 'jsencrypt';
+
+/**
+ * @word hash256要加密的内容
+ * @keyWord String  服务器随机返回的关键字
+ *  */
+export function aesEncryptHash(word, keyWord = 'XwKsGlMcdPMEhR1B') {
+  var key = CryptoJS.enc.Utf8.parse(keyWord);
+  var srcs = CryptoJS.enc.Utf8.parse(word);
+  var encrypted = CryptoJS.HmacSHA256(srcs, key, { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7 });
+  return encrypted.toString();
+}
+/**
+ * @word key加密
+ * @keyWord String  服务器随机返回的关键字
+ *  */
+export function encryptWithKey(password, publicKey) {
+  const encryptor = new JSEncrypt();
+  encryptor.setPublicKey(publicKey);
+  return encryptor.encrypt(password);
+}