按照ASCII码从小到大排序增加MD5加密

public String sign(Map mObject,String signKey){
		 if(mObject == null ){
			return null;
		 }
		 List keyList = new ArrayList(mObject.keySet());
		 Collections.sort(keyList);
		 StringBuffer sb = new StringBuffer();
		 for( int i=0; i < keyList.size(); i++){
			 String key = keyList.get(i);
			 Object val = mObject.get(key);
			 sb.append(key + "=" + val + "&");
		 }
		 
//		 String signStr = sb.substring(0,sb.length()-1)+"&key="+signKey;
		 sb.append("key="+signKey);
		 String signStr = sb.toString();
		 System.err.println("signStr is "+signStr);
		 String md5Str = DigestUtils.md5Hex(signStr);
		 return md5Str;
	}

 

转载于:https://my.oschina.net/xinyuanKong/blog/3069101

你可能感兴趣的:(按照ASCII码从小到大排序增加MD5加密)