generated from root/miduo_server
修改md5方法
parent
be334c1c5b
commit
bd2e6a1847
|
|
@ -129,7 +129,7 @@ public class UserInfoController {
|
||||||
return resp.toString();
|
return resp.toString();
|
||||||
}
|
}
|
||||||
String signStr = api_key + appota_user_id + server_id + GamotaConstats.secretKey;
|
String signStr = api_key + appota_user_id + server_id + GamotaConstats.secretKey;
|
||||||
String sign = MD5Util.encrypByMd5(signStr);
|
String sign = MD5Util.encrypByMd5New(signStr);
|
||||||
if(!sign.equals(signature)){
|
if(!sign.equals(signature)){
|
||||||
LOGGER.info("sign=" + sign + " --- signature="+signature);
|
LOGGER.info("sign=" + sign + " --- signature="+signature);
|
||||||
resp.put("message", "signature error");
|
resp.put("message", "signature error");
|
||||||
|
|
@ -337,4 +337,13 @@ public class UserInfoController {
|
||||||
return "GodLvInfo";
|
return "GodLvInfo";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void main(String args[]){
|
||||||
|
String api_key = GamotaConstats.apikey;
|
||||||
|
String appota_user_id = "2618078";
|
||||||
|
String server_id = "10157";
|
||||||
|
String signStr = api_key + appota_user_id + server_id + GamotaConstats.secretKey;
|
||||||
|
String sign = MD5Util.encrypByMd5New(signStr);
|
||||||
|
System.out.println(sign);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,4 +30,28 @@ public class MD5Util {
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String encrypByMd5New(String context) {
|
||||||
|
try {
|
||||||
|
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||||
|
md.update(context.getBytes());//update处理
|
||||||
|
byte [] encryContext = md.digest();//调用该方法完成计算
|
||||||
|
|
||||||
|
int i;
|
||||||
|
StringBuffer buf = new StringBuffer("");
|
||||||
|
for (int offset = 0; offset < encryContext.length; offset++) {//做相应的转化(十六进制)
|
||||||
|
i = encryContext[offset];
|
||||||
|
if (i < 0) i += 256;
|
||||||
|
if (i < 16) buf.append("0");
|
||||||
|
buf.append(Integer.toHexString(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
return buf.toString().toLowerCase();
|
||||||
|
|
||||||
|
} catch (NoSuchAlgorithmException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue