⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 md5.java

📁 联系方式 lovely2000@sina.com
💻 JAVA
字号:

/*
 * MD5.java
 *
 * Created on 2008年4月9日, 上午8:11
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package happychat;

import java.security.MessageDigest;

/**
 *
 * @author Administrator
 */
public class MD5 {
     public final static String toMD5(String s) {
      char hexDigits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
        'a', 'b', 'c', 'd', 'e', 'f' };
      try {
       byte[] strTemp = s.getBytes();
       MessageDigest mdTemp = MessageDigest.getInstance("MD5");
       mdTemp.update(strTemp);
       byte[] md = mdTemp.digest();
       int j = md.length;
       char str[] = new char[j * 2];
       int k = 0;
       for (int i = 0; i < j; i++) {
        byte byte0 = md[i];
        str[k++] = hexDigits[byte0 >>> 4 & 0xf];
        str[k++] = hexDigits[byte0 & 0xf];
       }
       return new String(str);
      } catch (Exception e) {
       return null;
      }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -