

def create_signed_value(secret, name, value, version=None, clock=None):
    if (version is None):
        version = DEFAULT_SIGNED_VALUE_VERSION
    if (clock is None):
        clock = time.time
    timestamp = utf8(str(int(clock())))
    value = base64.b64encode(utf8(value))
    if (version == 1):
        signature = _create_signature_v1(secret, name, value, timestamp)
        value = b'|'.join([value, timestamp, signature])
        return value
    elif (version == 2):

        def format_field(s):
            return (utf8(('%d:' % len(s))) + utf8(s))
        to_sign = b'|'.join([b'2|1:0', format_field(timestamp), format_field(name), format_field(value), b''])
        signature = _create_signature_v2(secret, to_sign)
        return (to_sign + signature)
    else:
        raise ValueError(('Unsupported version %d' % version))

dataset/ETHPy150Open RobotWebTools/rosbridge_suite/rosbridge_server/src/tornado/web.py create_signed_value/original