惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
Microsoft Security Blog
Microsoft Security Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
V
Visual Studio Blog
宝玉的分享
宝玉的分享
IT之家
IT之家
人人都是产品经理
人人都是产品经理
T
The Blog of Author Tim Ferriss
I
InfoQ
B
Blog RSS Feed
T
Threatpost
博客园_首页
M
MIT News - Artificial intelligence
Spread Privacy
Spread Privacy
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Know Your Adversary
Know Your Adversary
U
Unit 42
Engineering at Meta
Engineering at Meta
C
Cyber Attacks, Cyber Crime and Cyber Security
月光博客
月光博客
Scott Helme
Scott Helme
T
Tor Project blog
有赞技术团队
有赞技术团队
AWS News Blog
AWS News Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Last Week in AI
Last Week in AI
S
Schneier on Security
Vercel News
Vercel News
博客园 - Franky
C
Cybersecurity and Infrastructure Security Agency CISA
L
LINUX DO - 热门话题
NISL@THU
NISL@THU
L
LangChain Blog
爱范儿
爱范儿
Google DeepMind News
Google DeepMind News
The GitHub Blog
The GitHub Blog
雷峰网
雷峰网
Latest news
Latest news
C
CXSECURITY Database RSS Feed - CXSecurity.com
Hugging Face - Blog
Hugging Face - Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
www.infosecurity-magazine.com
www.infosecurity-magazine.com
G
GRAHAM CLULEY
S
Security Affairs
A
About on SuperTechFans
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
大猫的无限游戏
大猫的无限游戏
W
WeLiveSecurity
Cisco Talos Blog
Cisco Talos Blog
罗磊的独立博客

博客园 - kongxx

Java & .Net通讯问题 无异间发现的好网站 Message: 因为当前线程不在单线程单元中,故无法实例化 ActiveX 控件 错误处理方法 使用log4net记录日志到MySQL中 C#的MD5实现 PHP实现的Telnet 【引用】 microsoft WINDOWS 系统错误代码 [收藏] PicoContainer学习手册 PicoContainer学习手册 Java动态代理实现 [导入]Digester学习笔记 [导入]使用对Ant编程来实现简单文件的打包 [导入]关闭WinXP自带的Zip功能 [导入]使Tomcat可以下载中文文件 [导入].Net中使用com组件后发生System.ArithmeticException异常的解决办法 [导入]使用简单的Web开发架构 [导入].Net配置文件常用配置说明 [导入]使控件拥有透明背景色 [引用] [导入].Net配置log4net
Java的MD5实现
kongxx · 2005-09-30 · via 博客园 - kongxx

rfcs: http://www.faqs.org/rfcs/rfc1321.html

 1import java.security.*
 2import java.security.spec.*
 3
 4public class MD5
 5    public String convert(String s)
 6        char hexChars[] = '0''1''2''3''4''5''6''7''8''9''a''b''c''d''e''f'}
 7        try 
 8            byte[] bytes = s.getBytes(); 
 9            MessageDigest md = MessageDigest.getInstance("MD5"); 
10            md.update(bytes); 
11            bytes = md.digest(); 
12            int j = bytes.length; 
13            char[] chars = new char[j * 2]; 
14            int k = 0
15            for (int i = 0; i < bytes.length; i++
16                byte b = bytes[i]; 
17                chars[k++= hexChars[b >>> 4 & 0xf]; 
18                chars[k++= hexChars[b & 0xf]; 
19            }
 
20            return new String(chars); 
21        }
 
22        catch (Exception e)
23            return null
24        }
 
25    }
 
26    
27    public static void main(String[] args){
28        System.out.println(new MD5().convert("0123456789"));        
29    }

30}