MD5加密
来源:互联网 发布:python genetic 编辑:程序博客网 时间:2024/04/30 21:22
public String pwdToMd5(String string) {
byte[] hash;
try {
hash = MessageDigest.getInstance("MD5").digest(string.getBytes("UTF-8"));
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException("Huh, MD5 should be supported?", e);
} catch (UnsupportedEncodingException e) {
throw new RuntimeException("Huh, UTF-8 should be supported?", e);
}
StringBuilder hex = new StringBuilder(hash.length * 2);
for (byte b : hash) {
int i = (b & 0xFF);
if (i < 0x10) hex.append('0');
hex.append(Integer.toHexString(i));
}
return hex.toString();
}
byte[] hash;
try {
hash = MessageDigest.getInstance("MD5").digest(string.getBytes("UTF-8"));
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException("Huh, MD5 should be supported?", e);
} catch (UnsupportedEncodingException e) {
throw new RuntimeException("Huh, UTF-8 should be supported?", e);
}
StringBuilder hex = new StringBuilder(hash.length * 2);
for (byte b : hash) {
int i = (b & 0xFF);
if (i < 0x10) hex.append('0');
hex.append(Integer.toHexString(i));
}
return hex.toString();
}
0 0
- MD5加密
- MD5加密
- md5加密
- MD5加密
- md5加密
- MD5加密
- MD5加密
- md5 加密
- MD5加密
- md5加密
- MD5加密
- MD5加密
- MD5加密
- MD5加密
- MD5加密
- MD5加密
- MD5加密
- MD5加密
- 常用的shell命令
- java实现并发搜索数组元素
- HDU 5900 QSC and Master(区间dp)
- 双飞翼和圣杯布局
- SPS、PPS、IDR
- MD5加密
- 简单的imageloader
- SQL语言总结
- pojo的排序问题疑问
- 学习计划-16.09.21
- Convert Sorted Array to Binary Search Tree——Difficulty:Medium
- [整理]-iOS- 原生二维码的扫描实现
- HDU 5898 基础数位DP
- 数据库入门之增删改查