/usr/lib/python3/dist-packages/pymacaroons/__pycache__
NameSizeModeActions
caveat.cpython-310.pyc22580644editdlrm
exceptions.cpython-310.pyc11140644editdlrm
macaroon.cpython-310.pyc53100644editdlrm
utils.cpython-310.pyc37150644editdlrm
verifier.cpython-310.pyc33890644editdlrm
__init__.cpython-310.pyc5150644editdlrm
Edit: /usr/lib/python3/dist-packages/pymacaroons/__pycache__/utils.cpython-310.pyc (3715B)
o %Y @sddlZddlmZddlZddlZddlmZmZddZddZ d"dd Z d d Z d d Z ddZ ddZddZddZddZddZddZddZddZd d!ZdS)#N)sha256) text_type binary_typecCs6|durdSt|tr|dSt|tr|StdNutf-8z!Must be a string or bytes object.) isinstancerencoder TypeErrorstring_or_bytesr 3/usr/lib/python3/dist-packages/pymacaroons/utils.pyconvert_to_bytes s   rcCs6|durdSt|tr |St|tr|dStdr)rrrdecoder r r r r convert_to_strings   rcCsT|durd}t|}t|}||krt|d|S||kr(t|d||S|S)N ) bytearraylenbytes) byte_stringsize byte_arraylengthr r r truncate_or_padsrcCs td|S)Nsmacaroons-key-generator) hmac_digest)keyr r r generate_derived_key, rcCstj||tdS)N)msg digestmod)hmacnewrdigest)rdatar r r r0srcCst||}t|SN)rbinasciihexlify)rr$digr r r hmac_hex8s  r)cCst|}t||Sr%)rr))r identifier derived_keyr r r create_initial_signature=s r,cCs"t||}t||}t|||Sr%)rr))rdata1data2hash1hash2r r r hmac_concatBs  r1cCs t||Sr%)r)) signature predicater r r sign_first_party_caveatHrr4cCs t|||Sr%)r1)r2verification_id caveat_idr r r sign_third_party_caveatLs r7cCsHt|t|kr dSd}t||D]\}}|t|t|AO}q|dkS)aE Returns True if the two strings are equal, False otherwise. The time taken is independent of the number of characters that match. For the sake of simplicity, this function executes in constant time only when the two strings have the same length. It short-circuits when they have different lengths. Fr)rzipord)val1val2resultxyr r r equalsPs  r?cCs|dt| dS)zAdd padding to base64 encoded bytes. Padding can be removed when sending the messages. @param b bytes to be padded. @return a padded bytes. =)rbr r r add_base64_paddingbsrDcCs t|Sr%)raw_urlsafe_b64decodebase64 b64decoderDsr r r raw_b64decodemsrJcCstt|dS)ztBase64 decode with added padding and conversion to bytes. @param s string decode @return bytes decoded r)rFurlsafe_b64decoderDrrHr r r rEtsrEcCst|dS)z^Base64 encode with padding removed. @param s string decode @return bytes decoded r@)rFurlsafe_b64encoderstriprBr r r raw_urlsafe_b64encode}srNr%)rFhashlibrr!r&sixrrrrrrrr)r,r1r4r7r?rDrJrErNr r r r s(