Vue里进行md5加密(简单记录)
1、进行npm或者yarn下载md5
yarn add js-md5
或者
npm install --save js-md5
2、main.js里面引入md5
import md5 from 'js-md5';//使用md5进行加密
Vue.prototype.$md5 = md5;
3、对需要进行加密的methods方法里进行调用即可
getDeviceInfo(){
let md;
//获取当前时间 时间使用时间戳毫秒的格式
this.timestamp = Date.parse(new Date());
md = this.secrectkey+"|"+this.appId+this.timestamp;
this.sign = this.$md5(md)
this.$fetchGet('/iot/info',{appId:this.appId,sign:this.sign,timestamp:this.timestamp}).then(response=> {
console.log(response.data,'设备状态')
this.tableData = response.data;
}).catch(function (error) {
console.log(error);
})
},