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.
|
|
|
package com.archive.common.utils
|
|
|
|
|
|
|
|
;
|
|
|
|
|
|
|
|
import java.security.MessageDigest;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class Md5Utils
|
|
|
|
{
|
|
|
|
private static final Logger log = LoggerFactory.getLogger(com.archive.common.utils.Md5Utils.class);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static byte[] md5(String s) {
|
|
|
|
try {
|
|
|
|
MessageDigest algorithm = MessageDigest.getInstance("MD5");
|
|
|
|
algorithm.reset();
|
|
|
|
algorithm.update(s.getBytes("UTF-8"));
|
|
|
|
byte[] messageDigest = algorithm.digest();
|
|
|
|
return messageDigest;
|
|
|
|
}
|
|
|
|
catch (Exception e) {
|
|
|
|
|
|
|
|
log.error("MD5 Error...", e);
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private static final String toHex(byte[] hash) {
|
|
|
|
if (hash == null)
|
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
StringBuffer buf = new StringBuffer(hash.length * 2);
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < hash.length; i++) {
|
|
|
|
|
|
|
|
if ((hash[i] & 0xFF) < 16)
|
|
|
|
{
|
|
|
|
buf.append("0");
|
|
|
|
}
|
|
|
|
buf.append(Long.toString((hash[i] & 0xFF), 16));
|
|
|
|
}
|
|
|
|
return buf.toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static String hash(String s) {
|
|
|
|
try {
|
|
|
|
return new String(toHex(md5(s)).getBytes("UTF-8"), "UTF-8");
|
|
|
|
}
|
|
|
|
catch (Exception e) {
|
|
|
|
|
|
|
|
log.error("not supported charset...{}", e);
|
|
|
|
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
|
|
|
|
*/
|