add dependencies crypto-js
This commit is contained in:
parent
e97549c5e4
commit
34335676d4
|
|
@ -11,6 +11,7 @@
|
||||||
"@tinymce/tinymce-vue": "4.0.3",
|
"@tinymce/tinymce-vue": "4.0.3",
|
||||||
"axios": "0.21.1",
|
"axios": "0.21.1",
|
||||||
"core-js": "3.15.2",
|
"core-js": "3.15.2",
|
||||||
|
"crypto-js": "4.0.0",
|
||||||
"echarts": "5.1.2",
|
"echarts": "5.1.2",
|
||||||
"element-plus": "1.0.2-beta.54",
|
"element-plus": "1.0.2-beta.54",
|
||||||
"nprogress": "0.2.0",
|
"nprogress": "0.2.0",
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@
|
||||||
* @LastEditTime: 2021年6月28日19:13:13
|
* @LastEditTime: 2021年6月28日19:13:13
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import CryptoJS from 'crypto-js';
|
||||||
|
|
||||||
const tool = {}
|
const tool = {}
|
||||||
|
|
||||||
/* localStorage */
|
/* localStorage */
|
||||||
|
|
@ -95,4 +97,32 @@ tool.groupSeparator = function (num) {
|
||||||
}).replace(/\.$/, '');
|
}).replace(/\.$/, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 常用加解密 */
|
||||||
|
tool.crypto = {
|
||||||
|
//MD5加密
|
||||||
|
MD5(data){
|
||||||
|
return CryptoJS.MD5(data).toString()
|
||||||
|
},
|
||||||
|
//BASE64加解密
|
||||||
|
BASE64: {
|
||||||
|
encrypt(data){
|
||||||
|
return CryptoJS.enc.Base64.stringify(CryptoJS.enc.Utf8.parse(data))
|
||||||
|
},
|
||||||
|
decrypt(cipher){
|
||||||
|
return CryptoJS.enc.Base64.parse(cipher).toString(CryptoJS.enc.Utf8)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
//AES加解密
|
||||||
|
AES: {
|
||||||
|
encrypt(data, secretKey){
|
||||||
|
const result = CryptoJS.AES.encrypt(data, CryptoJS.enc.Utf8.parse(secretKey))
|
||||||
|
return result.toString()
|
||||||
|
},
|
||||||
|
decrypt(cipher, secretKey){
|
||||||
|
const result = CryptoJS.AES.decrypt(cipher, CryptoJS.enc.Utf8.parse(secretKey))
|
||||||
|
return CryptoJS.enc.Utf8.stringify(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export default tool
|
export default tool
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue