You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
74 lines
2.1 KiB
74 lines
2.1 KiB
3 weeks ago
|
/* */ package com.archive.common.utils
|
||
|
|
||
|
-INF.classes.com.archive.common.utils;
|
||
|
/* */
|
||
|
/* */ import java.security.MessageDigest;
|
||
|
/* */ import org.slf4j.Logger;
|
||
|
/* */ import org.slf4j.LoggerFactory;
|
||
|
/* */
|
||
|
/* */
|
||
|
/* */
|
||
|
/* */
|
||
|
/* */
|
||
|
/* */
|
||
|
/* */ public class Md5Utils
|
||
|
/* */ {
|
||
|
/* 14 */ private static final Logger log = LoggerFactory.getLogger(com.archive.common.utils.Md5Utils.class);
|
||
|
/* */
|
||
|
/* */
|
||
|
/* */
|
||
|
/* */
|
||
|
/* */ private static byte[] md5(String s) {
|
||
|
/* */ try {
|
||
|
/* 21 */ MessageDigest algorithm = MessageDigest.getInstance("MD5");
|
||
|
/* 22 */ algorithm.reset();
|
||
|
/* 23 */ algorithm.update(s.getBytes("UTF-8"));
|
||
|
/* 24 */ byte[] messageDigest = algorithm.digest();
|
||
|
/* 25 */ return messageDigest;
|
||
|
/* */ }
|
||
|
/* 27 */ catch (Exception e) {
|
||
|
/* */
|
||
|
/* 29 */ log.error("MD5 Error...", e);
|
||
|
/* */
|
||
|
/* 31 */ return null;
|
||
|
/* */ }
|
||
|
/* */ }
|
||
|
/* */
|
||
|
/* */ private static final String toHex(byte[] hash) {
|
||
|
/* 36 */ if (hash == null)
|
||
|
/* */ {
|
||
|
/* 38 */ return null;
|
||
|
/* */ }
|
||
|
/* 40 */ StringBuffer buf = new StringBuffer(hash.length * 2);
|
||
|
/* */
|
||
|
/* */
|
||
|
/* 43 */ for (int i = 0; i < hash.length; i++) {
|
||
|
/* */
|
||
|
/* 45 */ if ((hash[i] & 0xFF) < 16)
|
||
|
/* */ {
|
||
|
/* 47 */ buf.append("0");
|
||
|
/* */ }
|
||
|
/* 49 */ buf.append(Long.toString((hash[i] & 0xFF), 16));
|
||
|
/* */ }
|
||
|
/* 51 */ return buf.toString();
|
||
|
/* */ }
|
||
|
/* */
|
||
|
/* */
|
||
|
/* */
|
||
|
/* */ public static String hash(String s) {
|
||
|
/* */ try {
|
||
|
/* 58 */ return new String(toHex(md5(s)).getBytes("UTF-8"), "UTF-8");
|
||
|
/* */ }
|
||
|
/* 60 */ catch (Exception e) {
|
||
|
/* */
|
||
|
/* 62 */ log.error("not supported charset...{}", e);
|
||
|
/* 63 */ return s;
|
||
|
/* */ }
|
||
|
/* */ }
|
||
|
/* */ }
|
||
|
|
||
|
|
||
|
/* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\commo\\utils\Md5Utils.class
|
||
|
* Java compiler version: 8 (52.0)
|
||
|
* JD-Core Version: 1.1.3
|
||
|
*/
|