首页 > 代码库 > android MD5加密算法

android MD5加密算法

public class MD5test {


/**
* @param args
* @throws NoSuchAlgorithmException
*/
public static void main(String[] args) throws NoSuchAlgorithmException {
String pwd = "123456";
MessageDigest digest = MessageDigest.getInstance("MD5");
byte[] result = digest.digest(pwd.getBytes());
StringBuilder sb = new StringBuilder();
for(byte b : result){
int number = b&0xff; 
String hex = Integer.toHexString(number);
if(hex.length()==1){
sb.append("0");
}
sb.append(hex);
}
System.out.println(sb.toString());

}
}

android MD5加密算法