0

我使用 RSA 密钥在 Java 中生成了 JWE。我想在 python 中解码它。我在官方文档中尝试了 PyJwt。但我收到了这个错误

Traceback (most recent call last):
  File "/home/bhimasen/Documents/ENV/SysEnv37/lib/python3.7/site-packages/jwt/api_jws.py", line 209, in _load
    payload = base64url_decode(payload_segment)
  File "/home/bhimasen/Documents/ENV/SysEnv37/lib/python3.7/site-packages/jwt/utils.py", line 33, in base64url_decode
    return base64.urlsafe_b64decode(input)
  File "/home/bhimasen/Documents/ENV/SysEnv37/lib/python3.7/base64.py", line 133, in urlsafe_b64decode
    return b64decode(s)
  File "/home/bhimasen/Documents/ENV/SysEnv37/lib/python3.7/base64.py", line 87, in b64decode
    return binascii.a2b_base64(s)
binascii.Error: Incorrect padding

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "token_decrypt.py", line 37, in <module>
    decoded = jwt.decode(str_ex, private_key, algorithms=["RS256"])
  File "/home/bhimasen/Documents/ENV/SysEnv37/lib/python3.7/site-packages/jwt/api_jwt.py", line 119, in decode
    decoded = self.decode_complete(jwt, key, algorithms, options, **kwargs)
  File "/home/bhimasen/Documents/ENV/SysEnv37/lib/python3.7/site-packages/jwt/api_jwt.py", line 95, in decode_complete
    **kwargs,
  File "/home/bhimasen/Documents/ENV/SysEnv37/lib/python3.7/site-packages/jwt/api_jws.py", line 149, in decode_complete
    payload, signing_input, header, signature = self._load(jwt)
  File "/home/bhimasen/Documents/ENV/SysEnv37/lib/python3.7/site-packages/jwt/api_jws.py", line 211, in _load
    raise DecodeError("Invalid payload padding") from err
jwt.exceptions.DecodeError: Invalid payload padding

这是我拥有的令牌,

eyJjdHkiOiJKV1QiLCJlbmMiOiJBMjU2R0NNIiwiYWxnIjoiUlNBLU9BRVAtMjU2In0.oprppSvcEKs7gRLRitABobeciYtEOUTQwLli1j8JvCCU_BlbnBurjqqbjLNJR3IZcVDWW1zLfnwJ3vKRSxmuUCOfirmn9_u0UY2dUOMoRO9ubsmQzP2F-Prn7thBocUaeY44vSHBpz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O8TE2fK7TlO_wQyHMsC3yaF9rWwiuBR471yDLEFK-SFPUhgP2rBFkF8qQ01vSI6XFfioAhkF7zHNRu9Ff.5ECWE_6VUAZQ4IIMOjhveA

用于加密的算法是

{"cty":"JWT","enc":"A256GCM","alg":"RSA-OAEP-256"}

任何人都可以帮助解决这个问题吗?还是有什么方法可以使这种解码成为可能?

4

0 回答 0