md5
程序员文章站
2024-03-14 13:42:22
...
package test;
import java.security.MessageDigest;
public class Md5 {
public static String getMD5Str(String str)
{
MessageDigest me=null;
try
{
me=MessageDigest.getInstance("MD5");
me.update(str.getBytes());
}
catch(Exception e)
{
e.printStackTrace();
}
return bytetoString(me.digest());
}
public static String bytetoString(byte[] digest)
{
String str = "";
String tempStr = "";
for (int i = 1; i < digest.length; i++) {
tempStr = (Integer.toHexString(digest[i] & 0xff));
if (tempStr.length() == 1) {
str = str + "0" + tempStr;
}
else {
str = str + tempStr;
}
}
return str.toLowerCase();
}
public static void main(String args[])
{
System.out.println(Md5.getMD5Str("fengye"));
long t=Long.valueOf(Long.parseLong("13623456231")).longValue()+0x0L;
long s=0x16L;
System.out.println(s+","+t);
}
}
上一篇: java 使用 DES加密解密
下一篇: DES