日期:2014-05-17 浏览次数:20437 次
package com.test.moltest;
import java.util.Collection;
import java.util.Iterator;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.capinfo.crypt.Md5;
/**
* Created by IntelliJ IDEA.
* User: bob_0703
* Date: 2008-10-18
* Time: 17:30:53
* To change this template use File | Settings | File Templates.
*/
public class UserJsonUtil {
private static final Log log = LogFactory.getLog("UserJsonUtil.class");
public static boolean decryptJsonUser(String s) {
boolean rs = false;
try {
s = DESTools.decrypt("testtest", s);//解密1
JSONObject jobj = JSONObject.fromObject(s);//转换成为json
JSONArray names=jobj.names();
String md5Str = (String) jobj.get("md5");//获取加密后的MD5
names.remove(names.size()-1);
StringBuffer buf=new StringBuffer();
Iterator<String> it=names.iterator();
while(it.hasNext()){
String name=it.next();
buf.append(jobj.get(name));
}
jobj.remove("md5");
Md5 md5 = new Md5("");
md5.hmac_Md5(buf.toString(), "test");
byte b[] = md5.getDigest();