-
Notifications
You must be signed in to change notification settings - Fork 4
/
jwe_to_jwt.py
12 lines (9 loc) · 3.23 KB
/
jwe_to_jwt.py
1
2
3
4
5
6
7
8
9
10
11
12
from jwcrypto import jwk, jwe
enc = "eyJhbGciOiJSU0EtT0FFUCIsImVuYyI6IkEyNTZDQkMtSFM1MTIiLCJraWQiOiJZaHVJSlU2bzE1RVVDeXFBMExIRXFKZC14VlBKZ295VzV3WjFvNHBhZFdzIiwiY3R5IjoiSldUIn0.HPocunvuMnkUM9fFtKqjTUSVbOYVDtPGVmUJ1N4cRv_CIZtqKjFy-o2k884a-_k48ecJ0OIbrkos6MOWKzC6m7nG2yDVo_HHIqnu9ElT5GhmCK60zTmQ-MSdpgehXRZQZ4-2RXZjBW3cPjqVB-VhUKl2VvhYOHkBxEpq1VoZ3yr5vwqEKKL_rNGN2fEpubJj5DFT62-40MLNzGAfsCgcodFJPr_dX-XkZTYs80eqpM9x1LEpip07tBiM2nGImWrwuMBtJ_RsHACwi8HrUlgkgnUOeqwnhASeACnVocNDXZ5MXISWrdbiwfeJUymAHUHiDMGYsR0yzSkFQklfQeSdxg.r2Bl7zwjRTMJcxutfgG-Sw.JqtrIsnvFUYmk8AEB4ubdTgVHDFVF4CpMaY_NSlucP_IhZWNa8YkmeuPcrSpUVN4wVCnVWajun_eVIDyuH9Zj1uRR55yIUns2wgDd-EQx136VSrT4UUEm5zsEe6BTEzDFaJo_pgumaFKsbqvzxp2G-0vaFdh8GuoY2IM2QuLvwMkq9HTHkDoD9SZuNSPxP15dCwF-pQpgftdSO6QuE6GAdEf4ejtvEYvbMb-YDykZBOCCx8XoAYc0ZJ-LCJdH_nbMLubcVgarkd1NIJSZGqEC6rOj4KR-OG_NZYwM9of4SvSQhn_CMjdooL5n2-hfi1neLdg2aubFXkNsi25MG31uAZoCCjGylx-fIFL3U7CiIur_qFAJ-fSdTJEOjevVJMXpRDz5PsawvVoIzZbSZySk_kpr9xN-u7iPOEuFZb63OzxteXMSq4sODZXbyvVBse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B7g53104kw5cquSMA8gR5oiHt36bvnOHtbYgZmzn\n9iKgwml/EnaZ1NoE4/WJWbUTapodzQf65LASli897iECgYEA5PA7lJEDd3vrw5hl\nolFzvjvRriOu1SMHXx9Y52AgpOeQ6MnE1pO8qwn33lwYTSPGYinaq4jS3FKF/U5v\nOZltJAGBMa4ByEvAROJVCh958rKVRWKIqVXLOi8Gk11kHbVKw6oDXAd8Qt/y/ff8\nk/K6jW2EbWm1K6kfTvTMzoHkqrUCgYEAz2QeMH4WtrdiWUET7JgZNX0TbcaVBgd2\nGpo8JHnfnGOUsvO/euKGgqpCcxiWVXSlqffQyTgVzl4iMROP8bEaQwvueHurtziM\nDSy9Suumyktu3PbGgjqu/izRim8Xlg7sz8Hs2quJPII/fQ8BCoaWpg30osFZqCBa\nrQM7CWhxR40CgYA3CVWZap8lu0G7XMiaE/C6O9E1htiB3pDoGjYaMW7Hle+tNsw+\nNXf2uke/Se6BpOcNNDigYh0m4CPb+F4ev7aQIFh5o/ZDu4o2RR7idxyu7qWZ740h\nAEIB88ol5R6rUajujtGN7zK9NO9KhLJQstqMI1bhorbuDxM6vPj7cBiTvQKBgQDJ\nfuJ+BuOWntHlGf97rcNAXsdTrs73TqSG8Ddi0S5ayb2dqIjvoctChJ2PKeJWIMEc\nRHQMLHuzR2489F60WnfDkIIfeTi7CSu5WTCI7C/e+C88bF8uBEolFfJ4Z7soxlN6\n/1Val7L8oSeCH+PJED6qE4EN6IFtghHXav4fA+SbuQKBgQCNy7q3MoBOxDlKOpSN\nChoYUfW0JvwJbyyaVYOVq0efGVobosAblE/IuwaoIuVgh8c4T3qZtwFcSpvfR5Qy\nSOWFs2QXN/P4ZvmiVpXK/9Tcnth2BThpb9apQCT2a/CYtrRiGNAVWKiK0U9QlN/w\n9fVBO/ZgdaXE4xqYOSceH14yrQ==\n-----END PRIVATE KEY-----\n"
# Import of a PEM encoded PKCS#8 key
private_key = jwk.JWK.from_pem(pkcs8pem)
jwetoken = jwe.JWE()
jwetoken.deserialize(enc, key=private_key)
payload = jwetoken.payload
print(payload.decode('utf-8'))