OXIESEC PANEL
- Current Dir:
/
/
usr
/
lib
/
python3
/
dist-packages
/
josepy
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
03/17/2025 09:32:20 AM
rwxr-xr-x
📄
__init__.py
1.97 KB
04/13/2018 02:47:09 PM
rw-r--r--
📁
__pycache__
-
07/12/2020 04:36:18 PM
rwxr-xr-x
📄
b64.py
1.47 KB
04/13/2018 02:47:09 PM
rw-r--r--
📄
b64_test.py
2.27 KB
04/13/2018 02:47:09 PM
rw-r--r--
📄
errors.py
815 bytes
04/13/2018 02:47:09 PM
rw-r--r--
📄
errors_test.py
463 bytes
04/13/2018 02:47:09 PM
rw-r--r--
📄
interfaces.py
7.56 KB
04/13/2018 02:47:09 PM
rw-r--r--
📄
interfaces_test.py
3.54 KB
04/13/2018 02:47:09 PM
rw-r--r--
📄
json_util.py
15.38 KB
04/13/2018 02:47:09 PM
rw-r--r--
📄
json_util_test.py
13.94 KB
04/13/2018 02:47:09 PM
rw-r--r--
📄
jwa.py
6.01 KB
04/13/2018 02:47:09 PM
rw-r--r--
📄
jwa_test.py
4.54 KB
04/13/2018 02:47:09 PM
rw-r--r--
📄
jwk.py
9.19 KB
04/13/2018 02:47:09 PM
rw-r--r--
📄
jwk_test.py
6.92 KB
04/13/2018 02:47:09 PM
rw-r--r--
📄
jws.py
13.93 KB
04/13/2018 02:47:09 PM
rw-r--r--
📄
jws_test.py
8.32 KB
04/13/2018 02:47:09 PM
rw-r--r--
📄
test_util.py
2.85 KB
04/13/2018 02:47:09 PM
rw-r--r--
📄
util.py
7.3 KB
04/13/2018 02:47:09 PM
rw-r--r--
📄
util_test.py
6.45 KB
04/13/2018 02:47:09 PM
rw-r--r--
Editing: b64.py
Close
"""`JOSE Base64`_ is defined as: - URL-safe Base64 - padding stripped .. _`JOSE Base64`: https://tools.ietf.org/html/draft-ietf-jose-json-web-signature-37#appendix-C .. Do NOT try to call this module "base64", as it will "shadow" the standard library. """ import base64 import six def b64encode(data): """JOSE Base64 encode. :param data: Data to be encoded. :type data: bytes :returns: JOSE Base64 string. :rtype: bytes :raises TypeError: if ``data`` is of incorrect type """ if not isinstance(data, six.binary_type): raise TypeError('argument should be {0}'.format(six.binary_type)) return base64.urlsafe_b64encode(data).rstrip(b'=') def b64decode(data): """JOSE Base64 decode. :param data: Base64 string to be decoded. If it's unicode, then only ASCII characters are allowed. :type data: bytes or unicode :returns: Decoded data. :rtype: bytes :raises TypeError: if input is of incorrect type :raises ValueError: if input is unicode with non-ASCII characters """ if isinstance(data, six.string_types): try: data = data.encode('ascii') except UnicodeEncodeError: raise ValueError( 'unicode argument should contain only ASCII characters') elif not isinstance(data, six.binary_type): raise TypeError('argument should be a str or unicode') return base64.urlsafe_b64decode(data + b'=' * (4 - (len(data) % 4)))