您的位置:首页 > 移动开发 > Android开发

Android md5加密工具类

2016-05-19 21:25 543 查看
/**
*
* @描述         md5加密工具类
* @项目名称      App_News
* @包名         com.android.news.tools
* @类名         MD5Encoder
* @author      chenlin
* @date        2012年5月19日 下午9:24:23
* @version     1.0
*/
public class MD5Encoder {

public static String encode(String string) throws Exception {
byte[] hash = MessageDigest.getInstance("MD5").digest(string.getBytes("UTF-8"));
StringBuilder hex = new StringBuilder(hash.length * 2);
for (byte b : hash) {
if ((b & 0xFF) < 0x10) {
hex.append("0");
}
hex.append(Integer.toHexString(b & 0xFF));
}
return hex.toString();
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  android 加密 md5