2009年7月6日

 简单MD5加密算法,

import java.security.MessageDigest;

public class Md5
{
  
public static String encode(String str)
    
{
      String temp
="";
      String encodestr
="";
      
try
      
{
      MessageDigest mesg
=MessageDigest.getInstance("MD5");
      mesg.update(str.getBytes());
      
        
byte[] bystr=mesg.digest();
     
    
      
      
int i=bystr.length;
      
for(int m=0;m<i;m++)
        
{
           encodestr
=Integer.toHexString(bystr[m] & 0xff);
           temp
=temp+encodestr;

        }

      }
 
      
catch (Exception e)
      
{
         System.out.println(
"i Love you");
      }

        
return temp.toUpperCase();
    }

}

posted @ 2009-07-06 22:43 %落叶 阅读(109) | 评论 (0)编辑 收藏


仅列出标题  

posts - 1, comments - 0, trackbacks - 0, articles - 0

Copyright © %落叶