|
@@ -368,24 +368,7 @@ public class ToolsUtils {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- public static String EncoderByMd5New(String str) {
|
|
|
- StringBuffer sb = new StringBuffer(32);
|
|
|
- try
|
|
|
- {
|
|
|
- MessageDigest md = MessageDigest.getInstance("MD5");
|
|
|
- byte[] array = md.digest(str.getBytes("gb2312"));
|
|
|
|
|
|
- for (int i = 0; i < array.length; i++)
|
|
|
- {
|
|
|
- sb.append(Integer.toHexString((array[i] & 0xFF) | 0x100)
|
|
|
- .toUpperCase().substring(1, 3));
|
|
|
- }
|
|
|
- } catch (Exception e)
|
|
|
- {
|
|
|
- return null;
|
|
|
- }
|
|
|
- return sb.toString().toLowerCase();
|
|
|
- }
|
|
|
|
|
|
public static String EncoderByMd5(String str) {
|
|
|
String result = "";
|
|
@@ -393,7 +376,7 @@ public class ToolsUtils {
|
|
|
try {
|
|
|
md5 = MessageDigest.getInstance("MD5");
|
|
|
// 这句是关键
|
|
|
- md5.update(str.getBytes("gb2312"));
|
|
|
+ md5.update(str.getBytes("gbk"));
|
|
|
} catch (NoSuchAlgorithmException e) {
|
|
|
// TODO Auto-generated catch block
|
|
|
e.printStackTrace();
|
|
@@ -553,14 +536,18 @@ public class ToolsUtils {
|
|
|
return tempPKey;
|
|
|
}
|
|
|
|
|
|
- private static String MD5PubHasher(byte[] hashText) throws NoSuchAlgorithmException {
|
|
|
- MessageDigest md5 = MessageDigest.getInstance("MD5");
|
|
|
- byte[] b = md5.digest(hashText);
|
|
|
- StringBuilder ret = new StringBuilder();
|
|
|
- for (int i = 0; i < b.length; i++) {
|
|
|
- ret.append(String.format("%02x", b[i]));
|
|
|
+ public static String MD5PubHasher(byte[] hashText) {
|
|
|
+ try {
|
|
|
+ MessageDigest md5 = MessageDigest.getInstance("MD5");
|
|
|
+ byte[] b = md5.digest(hashText);
|
|
|
+ StringBuilder ret = new StringBuilder();
|
|
|
+ for (int i = 0; i < b.length; i++) {
|
|
|
+ ret.append(String.format("%02x", b[i]));
|
|
|
+ }
|
|
|
+ return ret.toString();
|
|
|
+ }catch (NoSuchAlgorithmException e){
|
|
|
+ return null;
|
|
|
}
|
|
|
- return ret.toString();
|
|
|
}
|
|
|
|
|
|
public static String encryptDes(String source, byte[] key, byte[] iv) throws Exception {
|