mirror of https://gitee.com/godoos/godoos.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
429 B
20 lines
429 B
import CryptoJS from 'crypto-js'
|
|
|
|
const CRYPTO_KEY = 'pptist'
|
|
|
|
/**
|
|
* 加密
|
|
* @param msg 待加密字符串
|
|
*/
|
|
export const encrypt = (msg: string) => {
|
|
return CryptoJS.AES.encrypt(msg, CRYPTO_KEY).toString()
|
|
}
|
|
|
|
/**
|
|
* 解密
|
|
* @param ciphertext 待解密字符串
|
|
*/
|
|
export const decrypt = (ciphertext: string) => {
|
|
const bytes = CryptoJS.AES.decrypt(ciphertext, CRYPTO_KEY)
|
|
return bytes.toString(CryptoJS.enc.Utf8)
|
|
}
|