信息加密
作者:互联网
MD5、SHA 加密方式:
import java.security.*;
public class demo {
public static void main(String[] args) throws NoSuchAlgorithmException {
String name = "hero";
String password = "666666";
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(name.getBytes());
md.update(password.getBytes());
byte[] b = md.digest();
String hs="",stmp ="";
for (int i = 0;i < b.length;i++) {//二行制转字符串
stmp=(Integer.toHexString(b[i] & 0XFF));
if (stmp.length()==1) hs=hs+"0"+stmp;
else hs=hs+stmp;
}
System.out.println(hs.toUpperCase());
}
}
标签:md,加密,String,hs,stmp,update,信息,public 来源: https://blog.csdn.net/weixin_46725388/article/details/111298198