您的位置:首页 > 健康 > 养生 > 宝安中心医院入职体检_一个门户网站源码_网络营销自学网站_拓客软件

宝安中心医院入职体检_一个门户网站源码_网络营销自学网站_拓客软件

2025/3/31 11:36:58 来源:https://blog.csdn.net/qq_28641023/article/details/146563632  浏览:    关键词:宝安中心医院入职体检_一个门户网站源码_网络营销自学网站_拓客软件
宝安中心医院入职体检_一个门户网站源码_网络营销自学网站_拓客软件

uni-app 官网没有 加密 API
我们 可以 安装 crypto-js

npm install crypto-js

他会保存到项目中 node_modules

在这里插入图片描述

import CryptoJS from '../node_modules/crypto-js' //引用AES源码js
const keyCode = '012345678' //密钥
const ivCode = '012345678' //偏移量const key = CryptoJS.enc.Utf8.parse(keyCode);
const iv = CryptoJS.enc.Utf8.parse(ivCode);
const utils = {encodeAES(text) {const encrypted = CryptoJS.AES.encrypt(text, key, {iv: iv,mode: CryptoJS.mode.CBC,padding: CryptoJS.pad.Pkcs7});let enText = encrypted.toString()if (enText == '') {enText = text}console.log('enText: ', enText);return enText;},decodeAES(enText) {const decrypt = CryptoJS.AES.decrypt(enText, key, {iv: iv,mode: CryptoJS.mode.CBC,padding: CryptoJS.pad.Pkcs7})const decryptedStr = decrypt.toString(CryptoJS.enc.Utf8)let text = decryptedStr.toString()if (text == '') {text = enText}console.log('text: ', text);return text},
}export default utils

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com