public class Demo {
/**
* @param args
* @throws NoSuchAlgorithmException
*/
public static void main(String[] args) throws NoSuchAlgorithmException {
MessageDigest digest = MessageDigest.getInstance("md5");
String password = "123456";
byte [] bytes = digest.digest(password.getBytes());
StringBuffer buffer = new StringBuffer();
for(byte b: bytes){
int number = b & 0xff;//加鹽
String hex = Integer.toHexString(number);
if(hex.length()==1){
buffer.append("0");
}
buffer.append(hex);
}
//md5加密後的值
System.out.println(buffer);
}
}
android MD5加密
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.