class GatewaySignUtil {

	public static String  sign(String appKey,Map<String,String> param) throws Md5Exception {
		Map<String, String> map = new TreeMap<String, String>();
		map.putAll(param);
		Set<String> keySet = map.keySet();
		StringBuilder buffer = new StringBuilder();
        Iterator<String> iter = keySet.iterator();
        while (iter.hasNext()) {
            String key = iter.next();
            if ("sign".equals(key)){
            	continue;
            }
            String value = map.get(key);
            if ( value == null || value.length() < 1 ) {
            	continue;
            }
            buffer.append(key);
            buffer.append("=");
            buffer.append(value);
            buffer.append("&");
        }
        buffer.append("key=");
        buffer.append(appKey);
        return MD5.encode(buffer.toString()).toUpperCase();
	}

}