android MD5加密算法

时间:2014-11-11 14:24:53   收藏:0   阅读:266
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());

}
}

原文:http://blog.csdn.net/u014600432/article/details/41010549

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!