Commit d070efd9 by Li Yongyu

md5 算法优化

parent 702705cd
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<classes> <classes>
<class name="com.puhui.test.RenMai_APITest"> <class name="com.puhui.test.RenMai_APITest">
<methods> <methods>
<include name="f" invocation-numbers="0 1 2 3 4 5 6 7 8 "/> <include name="f" invocation-numbers="0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 "/>
</methods> </methods>
</class> </class>
</classes> </classes>
......
package com.offcn.api.nwn.md5; package com.offcn.api.nwn.md5;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest; import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
public class LMFMD5 { public class LMFMD5 {
//����һ����LMFMD5 //����һ����LMFMD5
public static String MD5(String sourceStr) { public static String MD5(String str) {
/*
String result = ""; String result = "";
try { try {
MessageDigest md = MessageDigest.getInstance("MD5"); MessageDigest md = MessageDigest.getInstance("MD5");
...@@ -31,7 +34,37 @@ public class LMFMD5 { ...@@ -31,7 +34,37 @@ public class LMFMD5 {
} catch (NoSuchAlgorithmException e) { } catch (NoSuchAlgorithmException e) {
System.out.println(e); System.out.println(e);
} }
return result; return result;*/
MessageDigest messageDigest = null;
try {
messageDigest = MessageDigest.getInstance("MD5");
messageDigest.reset();
messageDigest.update(str.getBytes("UTF-8"));
} catch (NoSuchAlgorithmException e) { // NOSONAR
System.out.println(e.getMessage());
} catch (UnsupportedEncodingException e) { // NOSONAR
System.out.println(e.getMessage());
}
byte[] byteArray = messageDigest.digest();
StringBuffer md5StrBuff = new StringBuffer();
for (int i = 0; i < byteArray.length; i++) {
if (Integer.toHexString(0xFF & byteArray[i]).length() == 1)
md5StrBuff.append("0").append(Integer.toHexString(0xFF & byteArray[i]));
else
md5StrBuff.append(Integer.toHexString(0xFF & byteArray[i]));
}
// return md5StrBuff.toString().toUpperCase();
return md5StrBuff.toString();
} }
} }
package com.offcn.api.nwn.md5; package com.offcn.api.nwn.md5;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.Arrays; import java.util.Arrays;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import com.offcn.process.NWN; import com.offcn.process.NWN;
public class nwngetsign { public class nwngetsign {
...@@ -30,10 +33,11 @@ public class nwngetsign { ...@@ -30,10 +33,11 @@ public class nwngetsign {
str = str + "bf2h3%^j?ljkj3706kji88697"; //教务的加密,规则固定需要加 str = str + "bf2h3%^j?ljkj3706kji88697"; //教务的加密,规则固定需要加
System.out.println("str===" + str); System.out.println("str===" + str);
//String str1 = "appid=tiku&avatar=http://thirdqq.qlogo.cn/qqapp/1106773681/5B50BBF83A00DC46B16B708F720A5D46/100&device_id=861837034477409&login_type=qq&nickname=hobo&open_id=1&platform=Android&version=1"+"&123456"; //String str1 = "appid=tiku&avatar=http://thirdqq.qlogo.cn/qqapp/1106773681/5B50BBF83A00DC46B16B708F720A5D46/100&device_id=861837034477409&login_type=qq&nickname=hobo&open_id=1&platform=Android&version=1"+"&123456";
String res = new LMFMD5().MD5(str); String res = new LMFMD5().MD5(str);
System.out.println("res===" +res); System.out.println("res===" +res);
return res; return res;
......
...@@ -29,7 +29,7 @@ import net.sf.json.JSONObject; ...@@ -29,7 +29,7 @@ import net.sf.json.JSONObject;
/** /**
* 添加母版层级 * 删除班级(教务包)
* *
* @author liyy * @author liyy
* *
......
...@@ -29,7 +29,7 @@ import net.sf.json.JSONObject; ...@@ -29,7 +29,7 @@ import net.sf.json.JSONObject;
/** /**
* 添加母版层级 * 查找母版下是否有对应的教务包
* *
* @author liyy * @author liyy
* *
......
...@@ -113,7 +113,7 @@ public class APITest_nwn extends NWN{ ...@@ -113,7 +113,7 @@ public class APITest_nwn extends NWN{
//数据回写 //数据回写
// HashMap<String, Object> ExpectResult=MapUtil.Expect(data); // HashMap<String, Object> ExpectResult=MapUtil.Expect(data);
/* SheetUtils sheet = new SheetUtils("DataAll.xls", "Output"); /* SheetUtils sheet = new SheetUtils("DataAll.xls", "Output");
sheet.writeExcel( sheet.writeExcel(
data.get("NO").toString(), data.get("NO").toString(),
data.get("TCNO").toString() + "_Step" + data.get("Step").toString(), data.get("TCNO").toString() + "_Step" + data.get("Step").toString(),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment