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

📄 security.java

📁 OBPM是一个开源
💻 JAVA
字号:
package cn.myapps.util;

import java.security.MessageDigest;

/**
 * The security
 */
public class Security {
    /**
     * Encrypt the string with the MD5 arithmetic
     * @param s Normal message that you want to convert.
     * @return The Encrypt string.
     * @throws Exception
     */
    public static String encodeToMD5(String s) throws Exception{
        if (s == null)
            return null;
        String digstr = "";
        MessageDigest MD = MessageDigest.getInstance("MD5");

        byte[] oldbyte = new byte[s.length()];
        for (int i = 0; i < s.length(); i++) {
            oldbyte[i] = (byte) s.charAt(i);
        }
        MD.update(oldbyte);

        byte[] newbyte = MD.digest(oldbyte);
        for (int i = 0; i < newbyte.length; i++) {
            digstr = digstr + newbyte[i];
        }

        return digstr;
    }
}

⌨️ 快捷键说明

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