I went to this website https://jwt.io/#debugger-io Here I took the given sample info and passed it to my code.
But the encoded information that I got is not matching what is given on the website. Since I am doing something wrong here, I am not able to generate the signature in a valid format.
I need to make a program for JWT verification without using PyJWT types libraries.
Here is my code
import base64
import hmac
header = {"alg": "HS256", "typ": "JWT"}
payload = {"sub": "1234567890", "name": "John Doe", "iat": 1516239022}
header = base64.urlsafe_b64encode(bytes(str(header), 'utf-8'))
payload = base64.urlsafe_b64encode(bytes(str(payload), 'utf-8'))
print(header)
print(payload)
signature = hmac.new(bytes('hi', 'utf-8'), header + b'.' + payload, digestmod='sha256').hexdigest()
print(signature)