Welcome to Python CWT¶
Python CWT is a CBOR Web Token (CWT) and CBOR Object Signing and Encryption (COSE) implementation compliant with:
and related various specifications. See Referenced Specifications.
It is designed to make users who already know about JWS/JWE/JWT be able to use it in ease. Little knowledge of CBOR/COSE/CWT is required to use it.
You can install Python CWT with pip:
$ pip install cwt
And then, you can use it as follows:
>>> import cwt
>>> from cwt import COSEKey
>>> key = COSEKey.from_symmetric_key(alg="HS256")
>>> token = cwt.encode({"iss": "coaps://as.example", "sub": "dajiaji", "cti": "123"}, key)
>>> token.hex()
'd18443a10105a05835a60172636f6170733a2f2f61732e6578616d706c65026764616a69616a690743313233041a60c6a60b051a60c697fb061a60c697fb582019d4a89e141e3a8805ba1c90d81a8a2dd8261464dce379d8af8044d1cc062258'
>>> cwt.decode(token, key)
{1: 'coaps://as.example', 2: 'dajiaji', 7: b'123', 4: 1620088759, 5: 1620085159, 6: 1620085159}
Index¶
- Installation
- CWT Usage Examples
- COSE Usage Examples
- API Reference
- Supported CWT Claims
- Supported COSE Algorithms
- Referenced Specifications
- Changes
- Unreleased
- Version 1.5.2
- Version 1.5.1
- Version 1.5.0
- Version 1.4.2
- Version 1.4.1
- Version 1.4.0
- Version 1.3.2
- Version 1.3.1
- Version 1.3.0
- Version 1.2.0
- Version 1.1.0
- Version 1.0.0
- Version 0.10.0
- Version 0.9.0
- Version 0.8.1
- Version 0.8.0
- Version 0.7.1
- Version 0.7.0
- Version 0.6.1
- Version 0.6.0
- Version 0.5.0
- Version 0.4.0
- Version 0.3.0
- Version 0.2.3
- Version 0.2.2
- Version 0.2.1
- Version 0.2.0
- Version 0.1.1
- Version 0.1.0