sign.js 546 Bytes
/**
 *
 * @author: jiangfeng<jeff.jiang@yoho.cn>
 * @date: 16/7/22
 */
'use strict';

const Sign = {
    raw(args) {
        let keys = Object.keys(args);

        keys = keys.sort();

        return keys.map(k => {
            return k.toLowerCase() + '=' + args[k];
        }).join('&');
    },

    rawUncode(args) {
        let keys = Object.keys(args);

        keys = keys.sort();

        return keys.map(k => {
            return k.toLowerCase() + '=' + encodeURIComponent(args[k]);
        }).join('&');
    }
};

module.exports = Sign;