郑永安
2023-06-19 f65443d8abeaedc9d102324565e8368e7c9d90c8
src/main/java/com/gk/firework/Domain/Utils/DigestUtils.java
对比新文件
@@ -0,0 +1,29 @@
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);
    }
}