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

推荐订阅源

S
Secure Thoughts
Security Latest
Security Latest
Simon Willison's Weblog
Simon Willison's Weblog
O
OpenAI News
GbyAI
GbyAI
L
LINUX DO - 最新话题
A
Arctic Wolf
T
Tor Project blog
G
GRAHAM CLULEY
I
InfoQ
博客园_首页
IT之家
IT之家
The Register - Security
The Register - Security
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Proofpoint News Feed
The GitHub Blog
The GitHub Blog
Blog — PlanetScale
Blog — PlanetScale
N
Netflix TechBlog - Medium
K
Kaspersky official blog
博客园 - 三生石上(FineUI控件)
S
SegmentFault 最新的问题
U
Unit 42
PCI Perspectives
PCI Perspectives
量子位
P
Palo Alto Networks Blog
S
Securelist
T
Troy Hunt's Blog
博客园 - 【当耐特】
Recorded Future
Recorded Future
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
S
Security Affairs
Engineering at Meta
Engineering at Meta
T
The Blog of Author Tim Ferriss
博客园 - 聂微东
罗磊的独立博客
N
News and Events Feed by Topic
人人都是产品经理
人人都是产品经理
B
Blog RSS Feed
NISL@THU
NISL@THU
C
Cisco Blogs
T
Threatpost
有赞技术团队
有赞技术团队
Forbes - Security
Forbes - Security
Hugging Face - Blog
Hugging Face - Blog
Last Week in AI
Last Week in AI
T
The Exploit Database - CXSecurity.com
Cloudbric
Cloudbric
Cyberwarzone
Cyberwarzone
Google DeepMind News
Google DeepMind News
C
Cyber Attacks, Cyber Crime and Cyber Security

博客园 - 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}