MD5 Tool 工具类
来源:互联网 发布:上海医疗网络总监招聘 编辑:程序博客网 时间:2024/06/07 02:58
package com.example.secret.tools;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class MD5Tool {
public static String md5(String string)
{
byte[] hash;
try {
hash = MessageDigest.getInstance("MD5").digest(string.getBytes("UTF-8"));
} catch (NoSuchAlgorithmException e) {
// TODO Auto-generated catch block
throw new RuntimeException("huh,MD5 should be supported?",e);
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
throw new RuntimeException("huh,UTF-8 should be supported?",e);
}
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();
}
}
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class MD5Tool {
public static String md5(String string)
{
byte[] hash;
try {
hash = MessageDigest.getInstance("MD5").digest(string.getBytes("UTF-8"));
} catch (NoSuchAlgorithmException e) {
// TODO Auto-generated catch block
throw new RuntimeException("huh,MD5 should be supported?",e);
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
throw new RuntimeException("huh,UTF-8 should be supported?",e);
}
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();
}
}
0 0
- MD5 Tool 工具类
- 工具类 tool.God
- 工具类-Tool
- MD5 加密工具类
- MD5工具类
- MD5工具类
- Md5加密工具类
- MD5加密工具类
- MD5工具类
- MD5工具类
- MD5加密工具类
- MD5工具类
- MD5加密工具类
- MD5 加密工具类
- java MD5工具类
- MD5 加密工具类
- MD5加密算法工具类
- md5 加密工具类
- 菜鸟的Linux学习笔记之命令whereis
- 44444444444444
- matlab关键字
- MiniGUI应用程序使用 Ctrl+c 结束进程,发现产生core文件
- 在javascript中一下值被当做false
- MD5 Tool 工具类
- vi使用总结
- 中国经济走出困局的最后选择--刘胜军
- 深入理解java虚拟机
- 555555555555555
- CWinAppEx::InitContextMenuManager
- android动画简介
- ucenter与其它应用结合时出现通信失败
- 安装VirtualBox时系统找不到指定路径的解决方法