def sign(*records):
    if PRIVATE_KEY is None:
        raise ValueError("Recurly.js private key is not set.")
    records = list(records)
    try:
        data = records.pop() if type(records[-1]) is dict else {}
    except IndexError:
        data = {}
    for record in records:
        data[record.__class__.nodename] = record.__dict__
    if 'timestamp' not in data:
        data['timestamp'] = int(time.time())
    if 'nonce' not in data:
        data['nonce'] = re.sub(six.b('\W+'), six.b(''), base64.b64encode(os.urandom(32)))
    unsigned = to_query(data)
    signed = hmac.new(six.b(PRIVATE_KEY), six.b(unsigned), hashlib.sha1).hexdigest()
    return '|'.join([signed, unsigned])
Signs objects or data dictionary with your Recurly.js private key.
dataset/ETHPy150Open recurly/recurly-client-python/recurly/js.py/sign