Decode a signature into r, s
496078
def decode_signature(sigb64):
    
    sig_bin = base64.b64decode(sigb64)
    if len(sig_bin) != 64:
        raise ValueError("Invalid base64 signature")

    sig_hex = sig_bin.encode('hex')
    sig_r = int(sig_hex[:64], 16)
    sig_s = int(sig_hex[64:], 16)
    return sig_r, sig_s
1362493
def signature_unsafe(m: bytes, sk: bytes, pk: bytes) -> bytes:
    
    h = H(sk)
    a = decodecoord(h)
    r = Hint(h[b // 8 : b // 4] + m)
    R = scalarmult_B(r)
    S = (r + Hint(encodepoint(R) + pk + m) * a) % l
    return encodepoint(R) + encodeint(S)
469527
def decode(self, s):
        
        if isinstance(s, str) and '&' in s:
            for x in self.decodings:
                s = s.replace(x[0], x[1])
        return s
346841
def decode(self, s, _w=WHITESPACE.match):
        
        obj, end = self.raw_decode(s, idx=_w(s, 0).end())
        end = _w(s, end).end()
        if end != len(s):
            raise JSONDecodeError("Extra data", s, end, len(s))
        return obj
860788
def sign(key, qs):
    """"""
    sig = derive_signature(key, qs)
    return "%s&%s" % (qs, urlencode([("sig", sig)]))
683786
def sign(s, passphrase, sig_format=SER_COMPACT, curve='secp160r1'):
    
    if isinstance(s, six.text_type):
        raise ValueError("Encode `s` to a bytestring yourself to" +
                         " prevent problems with different default encodings")
    curve = Curve.by_name(curve)
    privkey = curve.passphrase_to_privkey(passphrase)
    return privkey.sign(hashlib.sha512(s).digest(), sig_format)
827901
def _decode_token_json(token):
    
    header, payload, raw_signatures, signing_inputs = _unpack_token_json(token)
    token = {
        'header': header,
        'payload': payload,
        'signature': [base64url_encode(rs) for rs in raw_signatures]
    }
    return token
523880
def unpack_rsp(cls, rsp_pb):
        """"""
        if rsp_pb.retType != RET_OK:
            return RET_ERROR, rsp_pb.retMsg, None

        order_id = str(rsp_pb.s2c.orderID)

        return RET_OK, "", order_id
1274586
def unescape(s):
    
    """
    if re.search(r'(?<!\\)\\(\\\\)*[uU]', s) or isinstance(s, unicode):
        return unescapeUnicode(s)
    else:
        return unescapeAscii(s)
1326215
def decode(s):
    

    s = s.lower()
    r = ""
    t = ""
    for c in s:
        if c >= 'a' and c <= 'z':
            t += c
        elif c == ':':
            try:
                if t[-1] == 'u':
                    t = t[:-1] + u"\u00fc"
            except:
                pass
        else:
            if c >= '0' and c <= '5':
                tone = int(c) % 5
                if tone != 0:
                    m = re.search(u"[aoeiuv\u00fc]+", t)
                    if m is None:
                        t += c
                    elif len(m.group(0)) == 1:
                        t = t[:m.start(0)] + PinyinToneMark[tone][PinyinToneMark[0].index(m.group(0))] + t[m.end(0):]
                    else:
                        if 'a' in t:
                            t = t.replace("a", PinyinToneMark[tone][0])
                        elif 'o' in t:
                            t = t.replace("o", PinyinToneMark[tone][1])
                        elif 'e' in t:
                            t = t.replace("e", PinyinToneMark[tone][2])
                        elif t.endswith("ui"):
                            t = t.replace("i", PinyinToneMark[tone][3])
                        elif t.endswith("iu"):
                            t = t.replace("u", PinyinToneMark[tone][4])
                        else:
                            t += "!"
            r += t
            t = ""
    r += t
    return r
1123786
def text_(s, encoding='latin-1', errors='strict'):
    '''
    
    '''
    return s.decode(encoding, errors) if isinstance(s, binary_type) else s
202754
def decode_rcvd_msg(pref, message, seqnum, pretty=False):
    
    newline = "\n" if pretty else " "
    indent = "    " if pretty else ""
    start = newline + indent

    out = []
    out.append("%s%s{%sSEQNUM: %d," % (pref, newline, start, seqnum))
    out.append("%sCLIENTREF: %s," % (start, message[Const.M_CLIENTREF]))
    out.append("%sTYPE: %s," % (start, M_TYPES[message[Const.M_TYPE]]))
    if message[Const.M_TYPE] in M_SUB_TYPES:
        out.append("%sPAYLOAD: {CODE: %s, MESSAGE: %s}" %
                   (start, M_SUB_TYPES[message[Const.M_TYPE]][message[Const.M_PAYLOAD][Const.P_CODE]],
                    message[Const.M_PAYLOAD][Const.P_MESSAGE]))
    else:
        payload = None
        if message[Const.M_PAYLOAD] is not None:
            payload = {}
            for item in message[Const.M_PAYLOAD]:
                if item == Const.P_RESOURCE:
                    payload['RESOURCE'] = R_TYPES[message[Const.M_PAYLOAD][Const.P_RESOURCE]]
                else:
                    payload[item] = message[Const.M_PAYLOAD][item]
        out.append("%sPAYLOAD: %s" % (start, payload))
    out.append("%s}" % newline)

    return ''.join(out)
1265375
def decode(s):
    
    if isinstance(s, bytes):
        return s.decode(sys.getdefaultencoding())
    else:
        return s
163313
def decode(s):
    
    if isinstance(s, binary_type):
        s = s.decode('latin-1')
    if not isinstance(s, text_type):
        return s

    r = []
    _in = []
    for c in s:
        if c == '&' and not _in:
            _in.append('&')
        elif c == '-' and _in:
            if len(_in) == 1:
                r.append('&')
            else:
                r.append(modified_deutf7(''.join(_in[1:])))
            _in = []
        elif _in:
            _in.append(c)
        else:
            r.append(c)
    if _in:
        r.append(modified_deutf7(''.join(_in[1:])))

    return ''.join(r)
515484
def get_signature_from_signature_string(self, signature):
        """"""
        match = self.SIGNATURE_RE.search(signature)
        if not match:
            return None
        return match.group(1)
1277282
def repr_part(self):
        """"""
        optargs = [('weighting', self.const, 1.0),
                   ('exponent', self.exponent, 2.0)]
        return signature_string([], optargs, mod=':.4')
668748
def _decode_token_compact(token):
    
    header, payload, raw_signature, signing_input = _unpack_token_compact(token)
    token = { 
        "header": header,
        "payload": payload,
        "signature": base64url_encode(raw_signature)
    }
    return token