Cannot Find A Way To Decrypt A Jwe Token In Python (but Created In Asp.net) Using Jwcrypto
I am having difficulties decrypting my JWE token in python once it has been encrypted using ASP.Net. Here is my C# code (fake passwords): var signingKey = new SymmetricSecurityKey(
Solution 1:
It looks like python-jose
DO NOT support JWE. In their online documentation or in the source code I cannot find any line of code related to the JWE parsing or encryption/decryption.
Hopefully in the library list from jwt.io, I've found jwcrypto that should support such encrypted token (see this example dealing with A256KW) and in the srouce code we can see A128KW is listed.
You can give it a try.
from jwcrypto import jwk, jwe
encrypted_token = request.cookies.get(cookie_name)
key = jwk.JWK.from_json('{"kty":"oct","k":"TWJQZVNoVm1ZcTN0Nnc5eg"}')
jwe_token = jwe.JWE()
jwe_token.deserialize(encrypted_token)
jwe_token.decrypt(key)
decrypted_payload = jwe_token.payload
Post a Comment for "Cannot Find A Way To Decrypt A Jwe Token In Python (but Created In Asp.net) Using Jwcrypto"