签名参数正序排列

阅读更多


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


public String getMD5Sign(Map treeMap,String secretKey) {
        StringBuffer sb = new StringBuffer() ;
        Iterator 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();
    }

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