JDK 1.8 版本以上(含)

class Md5Pass{
    private  static String ss="ISMvKXpXpadDiUoOSoAfww==";

    public static void main(String[] args) throws UnsupportedEncodingException, NoSuchAlgorithmException {
        System.out.println(login("admin"));
    }


    public static boolean login(String pass) throws UnsupportedEncodingException, NoSuchAlgorithmException {
       if(md52(pass).equals(ss)){
           System.out.println(md52("123"));
           return true;

       }
       else{
           return  false;
       }

    }


    public static String md52(String pass) {
        MessageDigest md= null;
        try {
            md = MessageDigest.getInstance("md5");
            //通过Md5  计算摘要
            byte[] b= new byte[0];
            b = md.digest(pass.getBytes("UTF-8"));
            String str=  Base64.getEncoder().encodeToString(b);
            return str;
        } catch (NoSuchAlgorithmException | UnsupportedEncodingException e) {
            e.printStackTrace();
        }
      return null;
    }
}

JDK 1.8 以下

         没有访问权限  要添加
          Base64Encoder bas=new Base64Encoder();
            bas.encode(b);
           Base64Encoder deco=new Base64Encoder();
          bytes =deco.decodeBuffer();

相关文章:

  • 2022-01-16
  • 2021-07-22
  • 2021-08-16
  • 2021-12-23
  • 2021-12-19
  • 2021-12-26
  • 2022-01-27
  • 2021-12-06
猜你喜欢
  • 2021-12-28
  • 2021-05-04
  • 2022-12-23
  • 2022-02-22
  • 2022-01-22
  • 2022-01-20
  • 2021-11-14
相关资源
相似解决方案