package xyz.acmer.util;

/**
 * Created by hypo on 16-2-17.
 */
public class EncryptHelper {
}

@@ -22,74 +22,1513 @@
 l;%0A%0A
-/**%0A * Created by hypo on 16-2-17.%0A */%0Apublic class EncryptHelper %7B
+import sun.misc.BASE64Encoder;%0Aimport xyz.acmer.entity.user.User;%0A%0Aimport java.io.UnsupportedEncodingException;%0Aimport java.security.MessageDigest;%0Aimport java.security.NoSuchAlgorithmException;%0A%0A/**%0A * %E5%8A%A0%E5%AF%86%E7%9B%B8%E5%85%B3%E5%B7%A5%E5%85%B7%E9%9B%86%0A * Created by hypo on 16-2-17.%0A */%0Apublic class EncryptHelper %7B%0A%0A    public static String md5(String srt)%7B%0A%0A        if(srt == null %7C%7C srt.length() == 0)%7B%0A            return %22%22;%0A        %7D%0A%0A        MessageDigest md5= null;%0A        try %7B%0A            md5 = MessageDigest.getInstance(%22MD5%22);%0A        %7D catch (NoSuchAlgorithmException e) %7B%0A            e.printStackTrace();%0A        %7D%0A%0A        //%E5%8A%A0%E5%AF%86%E5%90%8E%E7%9A%84%E5%AD%97%E7%AC%A6%E4%B8%B2%0A        String rnt = %22%22;%0A        BASE64Encoder base64en = new BASE64Encoder();%0A        try %7B%0A            rnt = base64en.encode(md5.digest(srt.getBytes(%22utf-8%22)));%0A        %7D catch (UnsupportedEncodingException e) %7B%0A            e.printStackTrace();%0A        %7D%0A%0A        return rnt;%0A    %7D%0A%0A    public static String getPassword(String str)%7B%0A%0A        // %E5%8A%A0%E7%9B%90%0A        String str1 = md5(str + %22unnecessary%22);%0A        String str2 = md5(str1.substring(2, str1.length() / 2) + str);%0A%0A        String password = md5(str2);%0A%0A        return password;%0A    %7D%0A%0A    public static Boolean verifyPassword(User user, String password)%7B%0A%0A        if (password == null %7C%7C password.length() == 0)%7B%0A            return false;%0A        %7D%0A%0A        if (user == null %7C%7C user.getPassword() == null)%7B%0A            return false;%0A        %7D%0A%0A        password = getPassword(password);%0A%0A        return password.equals(user.getPassword());%0A    %7D
 %0A%7D%0A

update EncryptHelper