From d8a956bb31927848dfb359aaa9496cd654d03855 Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期五, 30 九月 2022 17:48:09 +0800
Subject: [PATCH] 1

---
 src/main/resources/templates/login.html           |   16 +++--
 src/main/java/com/lf/server/helper/Md5Helper.java |  110 ++++++++++++++++++++++++++++++++++++
 2 files changed, 119 insertions(+), 7 deletions(-)

diff --git a/src/main/java/com/lf/server/helper/Md5Helper.java b/src/main/java/com/lf/server/helper/Md5Helper.java
new file mode 100644
index 0000000..7bdfee7
--- /dev/null
+++ b/src/main/java/com/lf/server/helper/Md5Helper.java
@@ -0,0 +1,110 @@
+package com.lf.server.helper;
+
+import org.apache.commons.codec.binary.Hex;
+
+import java.security.MessageDigest;
+import java.util.Random;
+
+/**
+ * MD5甯姪绫�
+ * @author WWW
+ */
+public class Md5Helper {
+    private final static int M16 = 16;
+
+    private final static int M48 = 48;
+
+    private final static int M3 = 3;
+
+    /**
+     * 鐢熸垚鍚湁闅忔満鐩愮殑瀵嗙爜
+     *
+     * @param password
+     * @return
+     */
+    public static String generate(String password) {
+        Random r = new Random();
+        StringBuilder sb = new StringBuilder(16);
+        sb.append(r.nextInt(99999999)).append(r.nextInt(99999999));
+
+        int len = sb.length();
+        if (len < M16) {
+            for (int i = 0; i < M16 - len; i++) {
+                sb.append("0");
+            }
+        }
+
+        String salt = sb.toString();
+        password = md5Hex(password + salt);
+        char[] cs = new char[48];
+        for (int i = 0; i < M48; i += M3) {
+            cs[i] = password.charAt(i / 3 * 2);
+            char c = salt.charAt(i / 3);
+            cs[i + 1] = c;
+            cs[i + 2] = password.charAt(i / 3 * 2 + 1);
+        }
+
+        return new String(cs);
+    }
+
+    /**
+     * 鏍¢獙瀵嗙爜鏄惁姝g‘
+     *
+     * @param password
+     * @param md5
+     * @return
+     */
+    public static boolean verify(String password, String md5) {
+        char[] cs1 = new char[32];
+        char[] cs2 = new char[16];
+        for (int i = 0; i < M48; i += M3) {
+            cs1[i / 3 * 2] = md5.charAt(i);
+            cs1[i / 3 * 2 + 1] = md5.charAt(i + 2);
+            cs2[i / 3] = md5.charAt(i + 1);
+        }
+        String salt = new String(cs2);
+
+        return md5Hex(password + salt).equals(new String(cs1));
+    }
+
+    /**
+     * 鑾峰彇鍗佸叚杩涘埗瀛楃涓插舰寮忕殑MD5鎽樿
+     *
+     * @param src
+     * @return
+     */
+    public static String md5Hex(String src) {
+        try {
+            MessageDigest md5 = MessageDigest.getInstance("MD5");
+            byte[] bs = md5.digest(src.getBytes());
+
+            return new String(new Hex().encode(bs));
+        } catch (Exception e) {
+            return null;
+        }
+    }
+
+    /**
+     * 鍙嶈浆
+     *
+     * @param pass
+     * @return
+     */
+    public static String reverse(String pass) {
+        StringBuilder sb = new StringBuilder(pass);
+
+        return sb.reverse().toString();
+
+    }
+
+    /**
+     * 楠岃瘉瀵嗙爜
+     *
+     * @param originalPassword
+     * @param dbPassword
+     * @return
+     */
+    public static boolean validatePassword(String originalPassword, String dbPassword) {
+        return verify(originalPassword, reverse(dbPassword));
+    }
+}
diff --git a/src/main/resources/templates/login.html b/src/main/resources/templates/login.html
index 4df6cd4..c87baf0 100644
--- a/src/main/resources/templates/login.html
+++ b/src/main/resources/templates/login.html
@@ -100,7 +100,7 @@
 
     function autoResize() {
       var div_obj = document.getElementById("div_middle");
-      // 瀹藉害鑷�傚簲
+      //瀹藉害鑷�傚簲
       var fullWidth = document.body.offsetWidth;
       var div_loginBox = document.getElementById("div_loginBox");
       var boxWidth = div_loginBox.offsetWidth;
@@ -108,8 +108,9 @@
       //if (fullWidth > 1920) { fullWidth = 1920; }
 
       var winWidht = window.innerWidth;
-      var winHeight = window.innerHeight + 50;
+      var winHeight = window.innerHeight - 100;
       var bgHeight = 1080;
+      winWidht += 150;
       if (winWidht >= 1920) {
         $("#div_middle").css("background", "url(../images/NewGJXJlogin/1920/2bg.jpg) no-repeat").css("background-position", "center bottom").css("height", "800px");
         $("#div_middle").css("height", "980px");
@@ -128,11 +129,12 @@
         $(".loginvalifield").css("margin-top", "20px").css("width", "350px").css("height", "45px");
         $("#inputCode").css("margin-left", "46px");
         $(".logintable").css("margin-top", "113px").css("width", "350px").css("height", "470px");
+        //$(".logintable").css("margin-top", "210px").css("width", "350px").css("height", "470px");
         $("#carLink div").css("background", "url(../images/NewGJXJlogin/1600/add.png) no-repeat").css("background-position", "3% 40%");
         $("#carLink a").css("margin-left", "50px").css("font-size", "16px");
         $(".loginbtn").css("margin-top", "25px");
         leftoffset = 404;
-        bgHeight = 800;
+        bgHeight = 800; //900
         div_loginBox.style.left = ((fullWidth - 360) / 2 + leftoffset) + "px";
       } else if (winWidht >= 1440) {
         $("#div_middle").css("background", "url(../images/NewGJXJlogin/1440/2bg.jpg) no-repeat").css("background-position", "center bottom").css("height", "810px");
@@ -164,13 +166,15 @@
         $(".loginvalicode input").css("width", "165px").css("margin-left", "46px").css("font-size", "14px");
         $(".loginvalifield").css("margin-top", "20px").css("width", "300px").css("height", "40px");
         $(".logintable").css("margin-top", "83px").css("width", "300px").css("height", "390px");
+        //$(".logintable").css("margin-top", "135px").css("width", "300px").css("height", "390px");
         $("#carLink div").css("background", "url(../images/NewGJXJlogin/1366/add.png) no-repeat").css("background-position", "3.5% 50%").css("margin-top", "25px").css("height", "30px").css("line-height", "30px");
         $("#carLink a").css("margin-left", "50px").css("font-size", "14px");
         $(".loginbtn").css("margin-top", "10px").css("height", "56px");
         leftoffset = 338;
-        bgHeight = 668;
+        bgHeight = 668; //731
         div_loginBox.style.left = ((fullWidth - 300) / 2 + leftoffset) + "px";
       } else {
+        //fullWidth = 1280;
         $("#div_middle").css("background", "url(../images/NewGJXJlogin/1280/2bg.jpg) no-repeat").css("background-position", "center bottom").css("height", "620px");
         $("#loginBox_Title").css("height", "50px").css("line-height", "50px");
         $("#loginBox_Title span").css("font-size", "32px");
@@ -191,14 +195,12 @@
         $("body").css("overflow", "hidden");
       }
       div_obj.style.width = fullWidth + "px";
-
       if (winHeight > bgHeight) {
         div_obj.style.height = winHeight + "px";
         var marginTop = parseFloat($(".logintable").css("margin-top").replace("px")) + (winHeight - bgHeight);
         $(".logintable").css("margin-top", marginTop + "px");
       }
-
-      // 楂樺害鑷�傚簲
+      //楂樺害鑷�傚簲
       var fullHeight = document.body.offsetHeight;
       var myHeight = div_obj.offsetHeight;
       if (fullHeight > myHeight) {

--
Gitblit v1.9.3