diff --git a/package.json b/package.json index 33d0c94a..b717b782 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "base64-js": "^1.5.1", "blueimp-md5": "^2.19.0", "core-js": "^3.6.5", + "crypto-js": "^4.2.0", "dateformat": "^5.0.2", "dayjs": "^1.10.4", "echarts": "^5.2.2", diff --git a/src/i18n/common.ts b/src/i18n/common.ts index aeb9635e..e2b3f28c 100644 --- a/src/i18n/common.ts +++ b/src/i18n/common.ts @@ -64,7 +64,7 @@ export default { en: 'Please enter a new password again', }, passwordStrengthTip: { - zh: '密码必须由数字、英文字母、特殊字符组成,且长度在 8 到 20 之间', + zh: '密码必须由数字、英文字母、特殊字符组成,且长度在 8 到 20 之间。不能连续输入 3 位及以上一样的字符;不能输入键盘连接 3 位及以上的字符;不能包含 admin、mysql、oracle、system、windows、linux、java、python、unix、test', en: 'Passwords should be between 8 and 20 in length and combination of letters, numbers, or symbols', }, newPassNotMatch: { diff --git a/src/types/shims-vue.d.ts b/src/types/shims-vue.d.ts index e7c52eba..1828cf90 100644 --- a/src/types/shims-vue.d.ts +++ b/src/types/shims-vue.d.ts @@ -2,6 +2,7 @@ type $TSFixed = any declare module '@emqx/emqx-ui' declare module 'dateformat' +declare module 'crypto-js' declare module '*.vue' { import type { DefineComponent } from 'vue' const component: DefineComponent<{}, {}, any> diff --git a/src/utils/utils.ts b/src/utils/utils.ts index 646dbef6..af3a459b 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -3,6 +3,7 @@ import { ERROR_CODE_ARR, SELF_HANDLE_ERROR_CODES } from './constants' import { utils as XLSXUtils, writeFile } from 'xlsx' import { EmqxMessage } from '@emqx/emqx-ui' import { omit, cloneDeep, orderBy } from 'lodash' +import CryptoJS from 'crypto-js' /** * when the value is int, can use this func to create option list @@ -255,3 +256,14 @@ export const randomString = (stringLen: number): string => { return str } + +export const encryptStr = (str: string): string => { + const utf8Str = CryptoJS.enc.Utf8.parse(str) + const kStr = '0000neuronex0000' + const encrypted = CryptoJS.AES.encrypt(utf8Str, kStr, { + iv: kStr, + mode: CryptoJS.mode.CBC, + padding: CryptoJS.pad.Pkcs7, + }) + return encrypted.ciphertext.toString() +} diff --git a/src/views/Login.vue b/src/views/Login.vue index b2ed54f6..dba4095e 100644 --- a/src/views/Login.vue +++ b/src/views/Login.vue @@ -22,7 +22,7 @@