JWT encrypting payload in python? (JWE)

前端 未结 2 2108
情歌与酒
情歌与酒 2020-12-20 16:34

According to RFC 7516 it should be possible to encrypt the payload/claim, called JWE.

Are there any python libraries out there that support that?

I\'ve check

2条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-20 17:18

    https://jwcrypto.readthedocs.io/en/latest/jwk.html#examples

    from jwcrypto import jwk
    _k = jwk.JWK.generate(kty='RSA', size=2048)
    _text = _k.export()
    
    import json
    # loading the key back
    _import_key_dict = json.loads(_text)
    key = jwk.JWK(**json.loads(_import_key_dict))
    

提交回复
热议问题