package com.qmth.jkserver.common;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang3.StringUtils;

import com.qmth.jkserver.model.Attachment;

/**
 * tianjun@qmth.com.cn
 */
public class MD5 {

    /**
     * Encodes a string
     * 
     * @param str
     *            String to encode
     * @return Encoded String
     * @throws NoSuchAlgorithmException
     */
    public static String encrypt(String str) {
    	if(StringUtils.isEmpty(str)){
    		return str;
    	}
    	return DigestUtils.md5Hex(str);
    }
    
    public static void main(String[] args) {
		String aString = encrypt("tianjun");//b4476196bc5cd3a3853eb0bc09614889
		System.out.println(aString);
	}

}
