日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > windows >内容正文

windows

如何使用window.btoa base64对接口数组进行加密处理

發布時間:2023/12/2 windows 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 如何使用window.btoa base64对接口数组进行加密处理 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

大家好,我是孫叫獸,前端全棧工程師,uniapp技術交流群:1149933135

項目采用uniapp+uView開發;

uiapp官方文檔:https://uniapp.dcloud.io/

uview官方文檔:http://uviewui.com/components/intro.html

接口傳參的操作步驟請參考我上一篇文章——>uniapp框架之如何修改接口傳參的參數?

我這個顯示的是加密過的,這里只演示過程。

window.btoa base64加密?一般格式是:window.btoa(‘123456’);

這個不支持數組直接加密的,因此我們需要將數組轉換成字符串,如果后端處理了,我們就不用轉成字符串啦,具體可以使用console.log(this.personId.attendees);打印一下。

這個不用轉成字符串的

this.personId.attendees = window.btoa(this.personId.attendees); this.personId.charge = window.btoa(this.personId.charge);

轉成字符串的

this.personId.attendees = window.btoa(this.personId.attendees.toString()); this.personId.charge = window.btoa(this.personId.attendees.toString());

因為上面的對一個數組四個人一起加密處理的,后臺解密需要解密四次,我們可以將數組拆分成4個分開加密(有多少人分割成多少個數組再加密)。

var result = [];for(var i=1;i<=this.personId.attendees.length;i++){result.push(this.personId.attendees.slice(i,i+1)); } return result;// console.log(result); //對參與人進行加密(可以多個人)this.personId.attendees = window.btoa(result);// console.log(this.personId.attendees);//對主責人進行加密處理(只能選一個人)this.personId.charge = window.btoa(this.personId.attendees.toString());

?

總結

以上是生活随笔為你收集整理的如何使用window.btoa base64对接口数组进行加密处理的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。