/**
   * 使用MD5算法进行加密
   * @param  待加密的明文密码
   * @return 返回加密后的字符串。32位。
   */
  public String getEncodedPassword(String Password) {
    String unionPassword = "";
    if(Password != null)
      unionPassword = new String(Password);
    unionPassword = unitId + account + unionPassword;
    MD5 md = new MD5();
    md.Update(unionPassword);
    return md.asHex();
  }

解决方案 »

  1.   

    你可以去看看jdk1.4的api,如java.security.*。
    调用MD5的办法用MessageDigest alga=MessageDigest.getInstance("MD5"); 
      

  2.   

    给你一个我的类:package com.abc.inc;
    import java.util.*;
    import java.io.*;
    import java.security.MessageDigest;public class PWD {  public String encryptPWD(String sPassword) {
            byte cResult[] = new byte[16];
            String sResult = "";
            try {
                MessageDigest md = MessageDigest.getInstance("MD5");
                md.update( ("chenlilin.nhdrtpj" + sPassword).getBytes());
                cResult = md.digest();            for (int i = 0; i < cResult.length; i++) {
                    if (cResult[i] < 0)
                        cResult[i] += 128;
                    String sTemp = Integer.toHexString(cResult[i]).toUpperCase();
                    if (cResult[i] < 16)
                        sTemp = "0" + sTemp;
                    sResult += sTemp;
                }
            }
            catch (Exception e) {
                sResult = "";
            }
            return sResult;
        } 
    }
      

  3.   

    http://210.73.88.156:8080/study/md5/index.jsp该页上偶给出乐关于MD5加密的例子演示及其源代码。