• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

java转php加密和好密

php 搞代码 3年前 (2022-01-24) 27次浏览 已收录 0个评论

java转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

%本文来源gaodai#ma#com搞*代#码9网#搞gaodaima代码 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 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();


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:java转php加密和好密

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址