SHA + HEX 메시지 요약 암호 화

import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 *       
 * 

* SHA+Hex * * @author * */ public abstract class ShaHex { /** */ private static final String ENCODING = "UTF8"; /** */ private static final String PROVIDER = "SHA-1"; private static final Logger LOG = LoggerFactory.getLogger(ShaHex.class); private ShaHex() { // do nothing } /** * * @param message * @return , , 。 */ public static final String messageDigest(String message) { String digest = null; try { final byte[] plainText = message.getBytes(ENCODING); MessageDigest messageDigest = MessageDigest.getInstance(PROVIDER); messageDigest.update(plainText); digest = new String(HexUtils.encode(messageDigest.digest())); } catch (UnsupportedEncodingException e) { LOG.error(" !", e); digest = message; } catch (NoSuchAlgorithmException e) { LOG.error(" !", e); digest = message; } return digest; } }

좋은 웹페이지 즐겨찾기