javaMD5加密

@Test
    public void test02() {

        String str="MD5加密的内容";
        StringBuffer hexString = new StringBuffer();
        try {
            MessageDigest md = MessageDigest.getInstance("MD5");
            md.update(str.getBytes());
            byte[] hash = md.digest();
            for (int i = 0; i < hash.length; i++) {
                if ((0xff & hash[i]) < 0x10) {
                    hexString.append("0" + Integer.toHexString((0xFF & hash[i])));
                } else {
                    hexString.append(Integer.toHexString(0xFF & hash[i]));
                }
            }
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }
        System.out.println("MD5加密:------");
        System.out.println(hexString.toString());
    }
上一篇:IOS小组件(7):小组件点击交互


下一篇:BOS项目(SSH)03_04_登录功能--MD5加密、MD5加盐、EasyUI提示框和下拉菜单、登录退出功能、切换皮肤