<commit_before>#!/usr/bin/env python3

# JWT Decoder
import base64

jwt = "<KEY>"

jwt = jwt.split('.')

print(jwt)
<commit_msg>initial decoding of header and payload of JWT [jwt_decoder.py]<commit_after>#!/usr/bin/env python3

# JWT Decoder
import base64
import sys
# <KEY>


def get_parts(jwt):
    return dict(zip(['header', 'payload', 'signature'], jwt.split('.')))


def decode_part(part):
    # use Base64URL decode plus optional padding.
    # === makes sure that padding will be always correct
    # extraneous padding is ignored
    return base64.urlsafe_b64decode(part + '===')


def encode_part(part):
    return base64.urlsafe_b64encode(part).decode('utf-8')


parts = get_parts(sys.argv[1])

header = decode_part(parts['header'])
print(header)

payload = decode_part(parts['payload'])
print(payload)

{'fraction_non_alphanumeric': 0.14391143911439114, 'fraction_numerical': 0.02214022140221402, 'mean_word_length': 4.814285714285714, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4067341', 'n_tokens_mistral': 292, 'n_tokens_neox': 279, 'n_words': 69}