Skip to content

Commit 9e45516

Browse files
author
Michael Davis
committed
Temporarily remove JWK code
1 parent da253ef commit 9e45516

File tree

2 files changed

+0
-264
lines changed

2 files changed

+0
-264
lines changed

jose/jwk.py

Lines changed: 0 additions & 213 deletions
This file was deleted.

jose/utils.py

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -54,54 +54,3 @@ def constant_time_compare(a, b):
5454
for x, y in zip(a, b):
5555
result |= ord(x) ^ ord(y)
5656
return result == 0
57-
58-
59-
def utf_decode(string):
60-
"""Method to UTF decode a string, if necessary.
61-
62-
Args:
63-
string (str): A string to UTF decode, if necessary.
64-
"""
65-
r_string = string
66-
if not isinstance(string, six.string_types):
67-
r_string = r_string.decode('utf8')
68-
69-
return r_string
70-
71-
72-
def int_arr_to_long(arr):
73-
return int(''.join(["%02x" % byte for byte in arr]), 16)
74-
75-
76-
def long_to_int_arr(long_int):
77-
_bytes = []
78-
while long_int:
79-
long_int, r = divmod(long_int, 256)
80-
_bytes.insert(0, r)
81-
return _bytes
82-
83-
84-
def long_to_base64(n):
85-
bys = long_to_int_arr(n)
86-
data = struct.pack('%sB' % len(bys), *bys)
87-
if not len(data):
88-
data = '\x00'
89-
s = base64.urlsafe_b64encode(data).rstrip(b'=')
90-
return s
91-
92-
93-
def base64url_to_long(data):
94-
_d = base64.urlsafe_b64decode(bytes(data) + b'==')
95-
# verify that it's base64url encoded and not just base64
96-
# that is no '+' and '/' characters and not trailing "="s.
97-
if [e for e in [b'+', b'/', b'='] if e in data]:
98-
raise ValueError("Not base64url encoded")
99-
return int_arr_to_long(struct.unpack('%sB' % len(_d), _d))
100-
101-
102-
def base64_to_long(data):
103-
# if isinstance(data, str):
104-
# data = bytes(data)
105-
# urlsafe_b64decode will happily convert b64encoded data
106-
_d = base64.urlsafe_b64decode(bytes(data) + b'==')
107-
return int_arr_to_long(struct.unpack('%sB' % len(_d), _d))

0 commit comments

Comments
 (0)