OXIESEC PANEL
- Current Dir:
/
/
usr
/
local
/
lib
/
python3.6
/
dist-packages
/
itsdangerous
Server IP: 10.0.0.4
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
09/19/2021 04:38:27 PM
rwxrwxr-x
📄
__init__.py
993 bytes
09/19/2021 04:38:25 PM
rw-r--r--
📁
__pycache__
-
09/19/2021 04:38:27 PM
rwxr-xr-x
📄
_json.py
918 bytes
09/19/2021 04:38:25 PM
rw-r--r--
📄
encoding.py
1.37 KB
09/19/2021 04:38:25 PM
rw-r--r--
📄
exc.py
3.13 KB
09/19/2021 04:38:25 PM
rw-r--r--
📄
jws.py
7.95 KB
09/19/2021 04:38:25 PM
rw-r--r--
📄
py.typed
0 bytes
09/19/2021 04:38:25 PM
rw-r--r--
📄
serializer.py
10.88 KB
09/19/2021 04:38:25 PM
rw-r--r--
📄
signer.py
9.15 KB
09/19/2021 04:38:25 PM
rw-r--r--
📄
timed.py
7.67 KB
09/19/2021 04:38:25 PM
rw-r--r--
📄
url_safe.py
2.33 KB
09/19/2021 04:38:25 PM
rw-r--r--
Editing: encoding.py
Close
import base64 import string import struct import typing as _t from .exc import BadData _t_str_bytes = _t.Union[str, bytes] def want_bytes( s: _t_str_bytes, encoding: str = "utf-8", errors: str = "strict" ) -> bytes: if isinstance(s, str): s = s.encode(encoding, errors) return s def base64_encode(string: _t_str_bytes) -> bytes: """Base64 encode a string of bytes or text. The resulting bytes are safe to use in URLs. """ string = want_bytes(string) return base64.urlsafe_b64encode(string).rstrip(b"=") def base64_decode(string: _t_str_bytes) -> bytes: """Base64 decode a URL-safe string of bytes or text. The result is bytes. """ string = want_bytes(string, encoding="ascii", errors="ignore") string += b"=" * (-len(string) % 4) try: return base64.urlsafe_b64decode(string) except (TypeError, ValueError): raise BadData("Invalid base64-encoded data") # The alphabet used by base64.urlsafe_* _base64_alphabet = f"{string.ascii_letters}{string.digits}-_=".encode("ascii") _int64_struct = struct.Struct(">Q") _int_to_bytes = _int64_struct.pack _bytes_to_int = _t.cast("_t.Callable[[bytes], _t.Tuple[int]]", _int64_struct.unpack) def int_to_bytes(num: int) -> bytes: return _int_to_bytes(num).lstrip(b"\x00") def bytes_to_int(bytestr: bytes) -> int: return _bytes_to_int(bytestr.rjust(8, b"\x00"))[0]