Created
May 20, 2021 14:55
-
-
Save marcan2020/1850ecac8d93ccd8fa4e8eadc362526f to your computer and use it in GitHub Desktop.
shc_jws.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import base64 | |
def decode(data): | |
missing_padding = len(data) % 4 | |
if missing_padding: | |
data += b'='* (4 - missing_padding) | |
return base64.urlsafe_b64decode(data) | |
jws_parts = list(map(decode, jws.split("."))) | |
print("header:", jws_parts[0]) | |
# header: {"zip":"DEF","alg":"ES256","kid":"..."} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
With python 3.9.6 it seems you need
data += str(b'='* (4 - missing_padding))
to avoid
TypeError: can only concatenate str (not "bytes") to str