采用数据加密的形式:md5+des
package com.test.moltest;import net.sf.json.JSONObject;import com.huonet.util.DESTools;
import com.huonet.util.UserJsonUtil;public class MobileRecharg {
public static void main(String[] argv) throws Exception {
//调用充值接口
String application_value = "recharge";
String account = "payease";
String mobile = "13581570818";
String orderid = "201305133127";
String amount = "100";
JSONObject jobj = new JSONObject();
jobj.accumulate("application_value", application_value);
jobj.accumulate("account", account);
jobj.accumulate("mobile", mobile);
jobj.accumulate("amount", amount);
jobj.accumulate("orderid", orderid);
String s = java.net.URLEncoder.encode(UserJsonUtil.encryptJsonUser(jobj));
String res= "http://www1.beijing.com.cn/user/api/mobile_test.jsp?s="+s;
System.out.println( "res=="+res);
//调用结束
//处理返回结果
//res = "CLp5Zjwtq9waj0Q6QNj6TArNHqMOwuJV/FRlHdmk4UFxExX0bEeH+pbi9guWDjTju/XchsQrIfJleZvQGw8Efb4JxzOosnXTstG00gxVzROVinl6o30HUA==";
System.out.println(UserJsonUtil.decryptJsonUser1(res.trim()));
s = DESTools.decrypt("testtest", s);//解密1
jobj = JSONObject.fromObject(s);
System.out.println(jobj);
}}这个接口要PHP如何调用?
package com.test.moltest;import net.sf.json.JSONObject;import com.huonet.util.DESTools;
import com.huonet.util.UserJsonUtil;public class MobileRecharg {
public static void main(String[] argv) throws Exception {
//调用充值接口
String application_value = "recharge";
String account = "payease";
String mobile = "13581570818";
String orderid = "201305133127";
String amount = "100";
JSONObject jobj = new JSONObject();
jobj.accumulate("application_value", application_value);
jobj.accumulate("account", account);
jobj.accumulate("mobile", mobile);
jobj.accumulate("amount", amount);
jobj.accumulate("orderid", orderid);
String s = java.net.URLEncoder.encode(UserJsonUtil.encryptJsonUser(jobj));
String res= "http://www1.beijing.com.cn/user/api/mobile_test.jsp?s="+s;
System.out.println( "res=="+res);
//调用结束
//处理返回结果
//res = "CLp5Zjwtq9waj0Q6QNj6TArNHqMOwuJV/FRlHdmk4UFxExX0bEeH+pbi9guWDjTju/XchsQrIfJleZvQGw8Efb4JxzOosnXTstG00gxVzROVinl6o30HUA==";
System.out.println(UserJsonUtil.decryptJsonUser1(res.trim()));
s = DESTools.decrypt("testtest", s);//解密1
jobj = JSONObject.fromObject(s);
System.out.println(jobj);
}}这个接口要PHP如何调用?
如果以后也有人研究这块的,可以看下面的一段代码。'{"application_value":"recharge","account":"payease","mobile":"13581570818","amount":"100","orderid":"201305133127","md5":"ebd99a76ad1747dc97136769d1a085a0"}';其中md5的键就是通过哈希md5加密的数据
加密的数据是rechargepayease13581570818100201305133127
将上面的代码进行DES加密就可以了。
然后通过请求url地址,就会得到一串加密的数据,通过解密的方式就可以解决了。解密就简单了。
把一串的数据,通过DES解密,然后再通过JSON进行解码就可以得出一个对象了,也就是真正的数据。