java转php加密和好密
程序员文章站
2022-03-22 23:01:28
...
java转php加密和解密
将UserJsonUtil类中的
encryptJsonUser()加密,写成php的加密;
decryptJsonUser()解密,写成php的解密。
将UserJsonUtil类中的
encryptJsonUser()加密,写成php的加密;
decryptJsonUser()解密,写成php的解密。
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();
Iteratorit=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();相关文章
相关视频
上一篇: 怎么用python画小黄人