对比新文件 |
| | |
| | | package com.gk.firework.Domain.Utils; |
| | | |
| | | import org.apache.commons.codec.Charsets; |
| | | |
| | | /** |
| | | * 加密相关工具类直接使用Spring util封装,减少jar依赖 |
| | | * @author L.cm |
| | | */ |
| | | public class DigestUtils extends org.springframework.util.DigestUtils { |
| | | |
| | | /** |
| | | * Calculates the MD5 digest and returns the value as a 32 character hex string. |
| | | * |
| | | * @param data Data to digest |
| | | * @return MD5 digest as a hex string |
| | | */ |
| | | public static String md5Hex(final String data) { |
| | | return DigestUtils.md5DigestAsHex(data.getBytes(Charsets.UTF_8)); |
| | | } |
| | | |
| | | /** |
| | | * Return a hexadecimal string representation of the MD5 digest of the given bytes. |
| | | * @param bytes the bytes to calculate the digest over |
| | | * @return a hexadecimal digest string |
| | | */ |
| | | public static String md5Hex(final byte[] bytes) { |
| | | return DigestUtils.md5DigestAsHex(bytes); |
| | | } |
| | | } |