New file |
| | |
| | | package com.dy.common.util; |
| | | |
| | | import java.security.MessageDigest; |
| | | |
| | | public class MD5 { |
| | | /** |
| | | * MD5加密 |
| | | * @param str 待加密字符串 |
| | | * @return 16进制加密字符串 |
| | | * @throws Exception 异常 |
| | | */ |
| | | public static String encrypt(String str) throws Exception{ |
| | | MessageDigest md5 = MessageDigest.getInstance("MD5") ; |
| | | byte[] digest = md5.digest(str.getBytes("utf-8")) ; |
| | | return ByteUtil.bytes2Hex(digest, false) ; |
| | | } |
| | | /* |
| | | public static void main(String[] args) throws Exception{ |
| | | String str = "123456" ; |
| | | System.out.println(encrypt(str)); |
| | | str = "admin!@#,;." ; |
| | | System.out.println(encrypt(str)); |
| | | str = "admin!@#,;.admin!@#,;.admin!@#,;." ; |
| | | System.out.println(encrypt(str)); |
| | | str = "1" ; |
| | | System.out.println(encrypt(str)); |
| | | } |
| | | */ |
| | | } |