uni-app 小程序 rsa 加密 使用的是 jsencrypt
main.js文件
//引入js文件
import security_http_config from './common/security.js'
//封装的接口
Vue.prototype.proims = (data, url, contentType) => {
//重要的地方
**let currentKey = security_http_config.createKey();**
const token_u = uni.getStorageSync('token');
data.token = token_u;
return new Promise((resolve, u) => {
uni.request({
url: httpurl + url,
//重要的地方
**data: security_http_config.transform('post', data, currentKey),**
method: 'post',
header: {
token: uni.getStorageSync('token'),
//重要的地方
'Content-Type': contentType || "application/json",
ff8d82a3d6654309b17c97289c9c78fc: 'headerEncoding:base64;contentEncoding:base64',
ff974421535f45508a8931b6432ffbf5: security_http_config.rsa(currentKey, uni
.getStorageSync('key'))
},
dataType: 'json',