From a21a0490e1157d88aa753e5a483bebe29dbc773a Mon Sep 17 00:00:00 2001 From: a0049873 <79py69t9wb@privaterelay.appleid.com> Date: Fri, 24 Jun 2022 17:58:43 +0800 Subject: [PATCH] =?UTF-8?q?BUG=E4=BF=AE=E6=94=B9=20=20=E4=BB=A5=E5=8F=8A?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=20=E5=AF=86=E7=A0=81=E5=8A=A0=E5=AF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back/package.json | 1 + back/src/i18n/zh-CN.js | 57 +++++++++--------- back/src/utils/crypto.js | 58 +++++++++++++++++++ .../src/views/main-navbar-update-password.vue | 57 ++++++++++++++++-- .../views/modules/sys/user-add-or-update.vue | 41 +++++++++++-- back/src/views/pages/login.vue | 7 ++- front/package.json | 1 + front/src/utils/crypto.js | 58 +++++++++++++++++++ .../components/DataResources.vue | 31 +++++----- front/src/views/login/index.vue | 11 +++- 10 files changed, 265 insertions(+), 57 deletions(-) create mode 100644 back/src/utils/crypto.js create mode 100644 front/src/utils/crypto.js diff --git a/back/package.json b/back/package.json index 9cb83932..d6d934e7 100644 --- a/back/package.json +++ b/back/package.json @@ -56,6 +56,7 @@ "@vue/cli-service": "^4.4.6", "@vue/eslint-config-standard": "^5.1.2", "babel-eslint": "^10.1.0", + "crypto-js": "^4.1.1", "element-theme-chalk": "^2.13.2", "eslint": "^7.5.0", "eslint-plugin-import": "^2.22.0", diff --git a/back/src/i18n/zh-CN.js b/back/src/i18n/zh-CN.js index ac57932d..acefdd06 100644 --- a/back/src/i18n/zh-CN.js +++ b/back/src/i18n/zh-CN.js @@ -25,7 +25,7 @@ t.choose = '请选择' t.fileName = '文件名' t.design = '在线设计' t.preview = '预览' -t.reset='重置' +t.reset = '重置' t.prompt = {} t.prompt.title = '提示' @@ -36,6 +36,7 @@ t.prompt.deleteBatch = '请选择删除项' t.validate = {} t.validate.required = '必填项不能为空' +t.validate.pwdStrength = '密码需包含字母、数字、标点符号,并超过8位' t.validate.format = '{attr}格式错误' t.upload = {} @@ -547,36 +548,32 @@ t.notice.disconnect = '连接断开' t.notice.disconnectMessage = 'WebSocket连接已断开,请检查网络' t.projectList = {} -t.projectList.projectName='项目名称' -t.projectList.projectUnit='申请单位' -t.projectList.department='责任处室' -t.projectList.applydate='申请日期' -t.projectList.district='所属区市' -t.projectList.contacts='业务联系人' -t.projectList.contactstel='业务联系人电话' -t.projectList.technology='技术联系人电话' -t.projectList.technologytel='技术联系人电话' - -t.dataresources={} -t.dataresources.componentType="组件类型" -t.dataresources.componentName="组件名称" -t.dataresources.putOnDate="上架时间" -t.dataresources.resourcesName="数据资源名称" -t.dataresources.resourcesCode="数据资源代码" -t.dataresources.resourcesProvide="数据资源提供方" -t.dataresources.resourcesAbstract="数据资源摘要" -t.dataresources.associatedApplication="关联应用" - -t.infrastructure={} -t.infrastructure.resourceCategory="资源类别" -t.infrastructure.resourceName="摄像头名称" -t.infrastructure.district="所在区市" -t.infrastructure.street="所在街道" -t.infrastructure.department="所属部门" -t.infrastructure.associatedApplication="关联应用" - - +t.projectList.projectName = '项目名称' +t.projectList.projectUnit = '申请单位' +t.projectList.department = '责任处室' +t.projectList.applydate = '申请日期' +t.projectList.district = '所属区市' +t.projectList.contacts = '业务联系人' +t.projectList.contactstel = '业务联系人电话' +t.projectList.technology = '技术联系人电话' +t.projectList.technologytel = '技术联系人电话' +t.dataresources = {} +t.dataresources.componentType = '组件类型' +t.dataresources.componentName = '组件名称' +t.dataresources.putOnDate = '上架时间' +t.dataresources.resourcesName = '数据资源名称' +t.dataresources.resourcesCode = '数据资源代码' +t.dataresources.resourcesProvide = '数据资源提供方' +t.dataresources.resourcesAbstract = '数据资源摘要' +t.dataresources.associatedApplication = '关联应用' +t.infrastructure = {} +t.infrastructure.resourceCategory = '资源类别' +t.infrastructure.resourceName = '摄像头名称' +t.infrastructure.district = '所在区市' +t.infrastructure.street = '所在街道' +t.infrastructure.department = '所属部门' +t.infrastructure.associatedApplication = '关联应用' export default t diff --git a/back/src/utils/crypto.js b/back/src/utils/crypto.js new file mode 100644 index 00000000..2be42882 --- /dev/null +++ b/back/src/utils/crypto.js @@ -0,0 +1,58 @@ +/* + * @Author: hisense.liangjunhua + * @Date: 2022-06-24 16:00:58 + * @LastEditors: hisense.liangjunhua + * @LastEditTime: 2022-06-24 16:44:28 + * @Description: 告诉大家这是什么 + */ +import CryptoJS from 'crypto-js/crypto-js' + +// 默认的 KEY 与 iv 与后端保持一致 ,不采用后端传值密钥 上上下下左右左右BABA 一往无前虎山行拨开云雾见光明梦里花开牡丹亭幻想成真歌舞升平 +const KEY = CryptoJS.enc.Utf8.parse('YwwqhsxBkywjgm01') // 密钥 +const IV = CryptoJS.enc.Utf8.parse('SSXXZYZYBABA30TM') // 偏移量 +/** + * AES加密 :字符串 key iv 返回base64 + */ +export function Encrypt(word, keyStr, ivStr) { + let key = KEY + let iv = IV + + if (keyStr) { + key = CryptoJS.enc.Utf8.parse(keyStr) + iv = CryptoJS.enc.Utf8.parse(ivStr) + } + + const srcs = CryptoJS.enc.Utf8.parse(word) + var encrypted = CryptoJS.AES.encrypt(srcs, key, { + iv: iv, + mode: CryptoJS.mode.CBC, + padding: CryptoJS.pad.ZeroPadding, + }) + + return CryptoJS.enc.Base64.stringify(encrypted.ciphertext) +} +/** + * AES 解密 :字符串 key iv 返回base64 + * + */ +export function Decrypt(word, keyStr, ivStr) { + let key = KEY + let iv = IV + + if (keyStr) { + key = CryptoJS.enc.Utf8.parse(keyStr) + iv = CryptoJS.enc.Utf8.parse(ivStr) + } + + const base64 = CryptoJS.enc.Base64.parse(word) + const src = CryptoJS.enc.Base64.stringify(base64) + + var decrypt = CryptoJS.AES.decrypt(src, key, { + iv: iv, + mode: CryptoJS.mode.CBC, + padding: CryptoJS.pad.ZeroPadding, + }) + + var decryptedStr = decrypt.toString(CryptoJS.enc.Utf8) + return decryptedStr.toString() +} diff --git a/back/src/views/main-navbar-update-password.vue b/back/src/views/main-navbar-update-password.vue index 6f90d85e..11cab773 100644 --- a/back/src/views/main-navbar-update-password.vue +++ b/back/src/views/main-navbar-update-password.vue @@ -1,3 +1,10 @@ +