import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import java.security.MessageDigest; public class EncryptionUtil { private static final Logger Log = LogManager.getLogger(); private enum DigestType { MD5("MD5"), SHA1("SHA1"), SHA256("SHA-256"), SHA512("SHA-512"); private String digestDesc; private DigestType(String digestDesc){ this.digestDesc = digestDesc; } public String getDigestDesc() { return digestDesc; } } private final static String digest(String sourceStr, DigestType type) { char hexDigits[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; try { byte[] btInput = sourceStr.getBytes(); // 获得MD5摘要
【JAVA-加密工具类】MD5、SHA1、SHA-256、SHA-512加密
最新推荐文章于 2024-07-23 17:46:22 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)