he2802 2 years ago
parent
commit
25f74c7414

+ 4 - 5
zhongzheng-admin/src/main/java/com/zhongzheng/controller/common/CommonController.java

@@ -750,17 +750,16 @@ public class CommonController extends BaseController {
     @Log(title = "测试获取山东题库", businessType = BusinessType.INSERT)
     @GetMapping("/common/free/getShanDongExam")
     public AjaxResult getShanDongExam(GoodsQueryBo bo) throws UnsupportedEncodingException {
-        System.out.println((new Long(262)).intValue());
-        System.out.println(Math.floor((45*50)/(46*60))+1);
+        System.out.println(bo.getBuyNote());
         System.out.println(dataSign(bo.getBuyNote(), "ca7c349b-52f2-4751-81ea-c86036e2b4e9"));
         return AjaxResult.success();
     }
-    public String dataSign(String SourceMsg, String PKey) {
+    public String dataSign(String SourceMsg, String PKey) throws UnsupportedEncodingException {
         String TempPKey;
-        TempPKey = ToolsUtils.EncoderByMd5(PKey);
+        TempPKey = ToolsUtils.MD5PubHasher(PKey.getBytes("gb2312"));
         TempPKey = SourceMsg + TempPKey;
         System.out.println(TempPKey);
-        TempPKey = ToolsUtils.EncoderByMd5(TempPKey);
+        TempPKey = ToolsUtils.MD5PubHasher(TempPKey.getBytes("gb2312"));
         return TempPKey;
     }
 

+ 33 - 20
zhongzheng-common/src/main/java/com/zhongzheng/common/utils/ToolsUtils.java

@@ -369,22 +369,31 @@ public class ToolsUtils {
     }
 
     public static String EncoderByMd5New(String str) {
-        StringBuffer sb = new StringBuffer(32);
-        try
+        StringBuilder pwd = new StringBuilder("");
+        try {
+        MessageDigest md = MessageDigest.getInstance("MD5");// 生成一个MD5加密计算摘要
+        byte[] digest1 = md.digest(str.getBytes("gb2312"));
+//        byte[] digest1 = passord.getBytes("UTF-16LE");
+        for (int i = 0; i < digest1.length; i++)
         {
-            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));
+            //将得到的字符串使用十六进制类型格式。格式后的字符是小写的字母,如果使用大写(X)则格式后的字符是大写字符
+//            pwd = pwd + digest1[i].toString("x");
+            int v = digest1[i] & 0xFf;
+            String hv = Integer.toHexString(v);
+            if (hv.length() < 2) {
+                pwd.append(0);
             }
-        } catch (Exception e)
-        {
-            return null;
+            pwd.append(hv);
+        }
+        } catch (NoSuchAlgorithmException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        } catch (UnsupportedEncodingException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
         }
-        return sb.toString().toLowerCase();
+//        MD5 md5 = new MD5CryptoServiceProvider();
+        return pwd.toString();
     }
 
     public static String EncoderByMd5(String str) {
@@ -553,14 +562,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 {

+ 0 - 2
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/vo/UserVo.java

@@ -299,8 +299,6 @@ public class UserVo {
 
 	public void setNull(){
 		this.setOpenId(null);
-		this.setIdCardImg1(null);
-		this.setIdCardImg2(null);
 		this.setCertifiedTime(null);
 		this.setGzhOpenId(null);
 	/*	if(this.getTelphone()!=null){