时间:2021-07-01 10:21:17 帮助过:30人阅读
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();
md 5 加密 用于向数据库中存储密码
标签:als decode oaf sys base port tst private ESS