签名参数正序排列



Map<String ,String> treeMap = new TreeMap<String, String>();
        treeMap.put("deviceid" ,deviceid) ;
        treeMap.put("pcdeviceid" ,pcdeviceid) ;
        treeMap.put("userid" ,userid) ;
        String md5Sign = getMD5Sign(treeMap,secretKey);


public String getMD5Sign(Map<String, String> treeMap,String secretKey) {
        StringBuffer sb = new StringBuffer() ;
        Iterator<String> ite = treeMap.keySet().iterator() ;
        while(ite.hasNext()){
            String key = ite.next() ;
            String value = treeMap.get(key) ;
            if(StringUtils.isNotBlank(value)){
                sb.append(key).append(value) ;
            }
        }
        if(StringUtils.isNotBlank(secretKey)) {
            sb.append(secretKey);
        }
        return MD5Util.md5Hex(sb.toString(), "utf-8").toUpperCase();
    }

你可能感兴趣的:(签名)