使用Apache digest做md5加密的范例
2009-01-15 13:27
726 查看
活用Apache commons,使用Apache digest做md5加密的范例。
<script type="text/javascript"><!--
google_ad_client = "pub-2097865745512830";
/* 728x90, 作成済み 08/12/22 */
google_ad_slot = "5461334436";
google_ad_width = 728;
google_ad_height = 90;
// --></script>
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script>
转贴请注明出处:http://blog.csdn.net/froole
import java.security.NoSuchAlgorithmException; import org.apache.commons.codec.digest.DigestUtils; /** * @author loveapple * @since 2009-01-15 * @version $Revision$ */ public class MD5Test { //加密后的文字串 static final String CHANGEME_MD5_STR = "4cb9c8a8048fd02294477fcb1a41191a"; //被加密的文字串 static final String TARGET = "changeme"; public static void main(String[] argvs){ try { MessageDigestAdapter adapter = new MessageDigestAdapter("MD5"); String md5str = adapter.digest(TARGET); System.out.println(md5str); if(CHANGEME_MD5_STR.equals(md5str)){ System.out.println(md5str + "->" + CHANGEME_MD5_STR); System.out.println("same with mysql request. length is [" + md5str.length() + "]"); }else{ System.out.println("NOT SAME! with mysql requse"); } System.out.println("common codec result: " + DigestUtils.md5Hex(TARGET)); if(CHANGEME_MD5_STR.equals(DigestUtils.md5Hex(TARGET))){ System.out.println("code result same with mysql request too. length is [" + DigestUtils.md5Hex(TARGET) + "]"); } }catch (NoSuchAlgorithmException e) { e.printStackTrace(); } } }
<script type="text/javascript"><!--
google_ad_client = "pub-2097865745512830";
/* 728x90, 作成済み 08/12/22 */
google_ad_slot = "5461334436";
google_ad_width = 728;
google_ad_height = 90;
// --></script>
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script>
转贴请注明出处:http://blog.csdn.net/froole
相关文章推荐
- 使用Apache digest可以做md5 SHA1 BASE64加密
- Apache 使用Digest验证
- java.security.MessageDigest的使用,MD5加密!
- 使用Apache digest可以做md5 SHA1 BASE64加密
- java.security.MessageDigest的使用,MD5加密!
- 使用Java中的MessageDigest对文本进行MD5加密(Java中的MD5加密算法示例)
- 微信使用范例
- 【jar】JDK将单个的java文件打包为jar包,并引用到项目中使用【MD5加密】
- Apache commons email 使用过程中遇到的问题
- 使用WAMP5搭建Apache+MySQL+PHP环境
- 使用apache的ZipOutputStream进行zip(rar等压缩文件)的文件压缩
- 如何使用MD5加密,MD5的特点
- Apache Shiro 使用手册(二)Shiro 认证
- Apache Shiro 使用手册(五)Shiro 配置说明
- Discuz! 7.0 模块调用脚本范例程序 - 多选下拉的缺陷以及使用方法
- PHPnow在WIN7、WIN8下使用PnCp.cmd无法重启apache和mysql
- Apache Storm使用
- 使用Apache JMeter压測Thrift
- 使用apache的fileupload进行文件上传
- PHP学习笔记【3】--apache服务器使用和配置