開發中經常遇到MD5加密,最近作小程序也用到了,簡單總結了一下;javascript
這要有兩個加密文件,一個不支持中文,一個支持,因此你選擇支持的來用就好了;java
也隨便說說小程序的get和post網絡請求。git
來看看效果圖:github
網絡請求代碼:json
requestData: function (appid, token, itype, callback, offset, count){ wx.request({ url: "xxxxxx", method: "POST",//GET data: { m: 'api', appid: appid, token: token, c: itype, a: 'batchget', offset: offset, count: count }, header: { 'Content-Type': 'application/x-www-form-urlencoded', //POST //'content-type': 'application/json' //GET }, success: function (res) { console.log(res.data.data) callback(res.data.data) } }) },
固然有點前提,微信小程序網絡請求須要去微信平臺服務器域名配置,小程序
固然也能夠有第二種方式,勾選不驗證域名,固然微信小程序只支持https的接口,須要使用http的須要轉微信小程序
以下圖api
md5加密:服務器
很簡單,和日常其餘語言的使用方式差很少微信
1:引入
var md5 = require('../../utils/md5.js') var zhmd5 = require('../../utils/zhmd5.js')
2:使用
md51: md5.hexMD5("切切歆語"), md52: zhmd5.md5("切切歆語")
案例中還用到了 小程序 template 標籤的使用