mirror of
https://gitee.com/dromara/go-view.git
synced 2026-04-23 00:00:12 +08:00
feat: 加密登录数据,修改折线图表UI
This commit is contained in:
+26
-27
@@ -1,30 +1,29 @@
|
||||
import * as CryptoJS from 'crypto-ts'
|
||||
|
||||
export default {
|
||||
AES_KEY: 'mt',
|
||||
cryptoEncode(data: string): string {
|
||||
if (typeof data !== 'string') return ''
|
||||
// 加密
|
||||
const key = CryptoJS.enc.Utf8.parse(this.AES_KEY)
|
||||
const str = JSON.stringify(data)
|
||||
const encryptedData = CryptoJS.AES.encrypt(str, key, {
|
||||
mode: CryptoJS.mode.ECB,
|
||||
padding: CryptoJS.pad.PKCS7,
|
||||
iv: CryptoJS.enc.Utf8.parse(this.AES_KEY)
|
||||
})
|
||||
return encryptedData.toString()
|
||||
},
|
||||
// 解密
|
||||
cryptoDecode(data: string): string {
|
||||
if (typeof data !== 'string') return ''
|
||||
const encryptedHexStr = CryptoJS.enc.Utf8.parse(data)
|
||||
const encryptedBase64Str = CryptoJS.enc.Utf8.stringify(encryptedHexStr)
|
||||
const key = CryptoJS.enc.Utf8.parse(this.AES_KEY)
|
||||
const decryptedData = CryptoJS.AES.decrypt(encryptedBase64Str, key, {
|
||||
mode: CryptoJS.mode.ECB,
|
||||
padding: CryptoJS.pad.PKCS7,
|
||||
iv: CryptoJS.enc.Utf8.parse(this.AES_KEY)
|
||||
})
|
||||
return decryptedData.toString(CryptoJS.enc.Utf8)
|
||||
}
|
||||
const AES_KEY = 'mt'
|
||||
|
||||
export const cryptoEncode = (data: string): string => {
|
||||
if (typeof data !== 'string') return ''
|
||||
// 加密
|
||||
const key = CryptoJS.enc.Utf8.parse(AES_KEY)
|
||||
const str = JSON.stringify(data)
|
||||
const encryptedData = CryptoJS.AES.encrypt(str, key, {
|
||||
mode: CryptoJS.mode.ECB,
|
||||
padding: CryptoJS.pad.PKCS7,
|
||||
iv: CryptoJS.enc.Utf8.parse(AES_KEY)
|
||||
})
|
||||
return encryptedData.toString()
|
||||
}
|
||||
// 解密
|
||||
export const cryptoDecode = (data: string): string => {
|
||||
if (typeof data !== 'string') return ''
|
||||
const encryptedHexStr = CryptoJS.enc.Utf8.parse(data)
|
||||
const encryptedBase64Str = CryptoJS.enc.Utf8.stringify(encryptedHexStr)
|
||||
const key = CryptoJS.enc.Utf8.parse(AES_KEY)
|
||||
const decryptedData = CryptoJS.AES.decrypt(encryptedBase64Str, key, {
|
||||
mode: CryptoJS.mode.ECB,
|
||||
padding: CryptoJS.pad.PKCS7,
|
||||
iv: CryptoJS.enc.Utf8.parse(AES_KEY)
|
||||
})
|
||||
return decryptedData.toString(CryptoJS.enc.Utf8)
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
export * from '@/utils/utils'
|
||||
export * from '@/utils/crypto'
|
||||
export * from '@/utils/router'
|
||||
export * from '@/utils/storage'
|
||||
export * from '@/utils/style'
|
||||
|
||||
Reference in New Issue
Block a user