管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2022-09-30 d8a956bb31927848dfb359aaa9496cd654d03855
1
已添加1个文件
已修改1个文件
126 ■■■■■ 文件已修改
src/main/java/com/lf/server/helper/Md5Helper.java 110 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/templates/login.html 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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);
    }
    /**
     * æ ¡éªŒå¯†ç æ˜¯å¦æ­£ç¡®
     *
     * @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));
    }
}
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) {