D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
self
/
root
/
usr
/
lib
/
python3.6
/
site-packages
/
jwt
/
Filename :
compat.py
back
Copy
""" The `compat` module provides support for backwards compatibility with older versions of python, and compatibility wrappers around optional packages. """ # flake8: noqa import hmac import struct import sys PY3 = sys.version_info[0] == 3 if PY3: text_type = str binary_type = bytes else: text_type = unicode binary_type = str string_types = (text_type, binary_type) try: constant_time_compare = hmac.compare_digest except AttributeError: # Fallback for Python < 2.7 def constant_time_compare(val1, val2): """ Returns True if the two strings are equal, False otherwise. The time taken is independent of the number of characters that match. """ if len(val1) != len(val2): return False result = 0 for x, y in zip(val1, val2): result |= ord(x) ^ ord(y) return result == 0 # Use int.to_bytes if it exists (Python 3) if getattr(int, 'to_bytes', None): def bytes_from_int(val): remaining = val byte_length = 0 while remaining != 0: remaining = remaining >> 8 byte_length += 1 return val.to_bytes(byte_length, 'big', signed=False) else: def bytes_from_int(val): buf = [] while val: val, remainder = divmod(val, 256) buf.append(remainder) buf.reverse() return struct.pack('%sB' % len(buf), *buf)
Name
Size
Last Modified
Owner
Permissions
Actions
__pycache__
Dir
July 28 2023 2:56:41
root
0755
contrib
Dir
July 28 2023 2:56:41
root
0755
__init__.py
0.771
KB
March 18 2018 1:37:23
root
0644
__main__.py
4.229
KB
March 18 2018 1:37:23
root
0644
algorithms.py
13.023
KB
March 18 2018 1:37:23
root
0644
api_jws.py
7.421
KB
March 18 2018 1:37:23
root
0644
api_jwt.py
7.207
KB
March 18 2018 1:37:23
root
0644
compat.py
1.406
KB
March 18 2018 1:37:23
root
0644
exceptions.py
0.873
KB
March 18 2018 1:37:23
root
0644
utils.py
2.567
KB
March 18 2018 1:37:23
root
0644
2017 © D7net | D704T team