亲测可用
/***
* 简单解密下 //by jiaxi
* @param code
* @param totalsplit
*/
private String decoder(String code,int totalsplit){
//前面totalSplit/2位不要(一般来说 可以随机数)
String str=code.substring(totalsplit/2);
//将字符串最后五位放在前面
String tmp=str.substring(totalsplit,str.length());
String tmp2=str.substring(0,totalsplit);
code=tmp+tmp2;
return code;
}
小程序app.js
wx_encoder:function(str,totalsplit){
//by jiaxi
var random="";
//生成随机数
for(var i=0;i<totalsplit/2;i++){
var tmp=""+(Math.floor(Math.random()*10+1));
random=random+tmp;
}
//将后面几位放到前面
var one=str.substring(str.length-totalsplit,totalsplit.length);
var two=str.substring(0,str.length-totalsplit);
var end=random+one+two;
console.info(str+">>>>>>>>>>"+end);
return end;
},