You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since webtoken already has aws-lc-rs in its standalone module, it exposes several auxiliary utilities.
76
+
77
+
This, for example, allows running tests, such as the PyJWT ported test suites, without importing cryptography.
78
+
79
+
```python
80
+
import webtoken as wt
81
+
82
+
83
+
wt.base64url_encode('bob') # utf8 strings or bytes
84
+
# b'Ym9i'
85
+
86
+
wt.base64url_decode(b'Ym9i').decode()
87
+
# 'bob'
88
+
89
+
wt.random_bytes(7) # cryptographically secure random bytes
90
+
# b'j>A\x0cj\xac\x7f'
91
+
92
+
priv, pub = wt.generate_key_pair('rs256')
93
+
# pub = b'-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhki.......a2ODLeYTResxi\nnQIDAQAB\n-----END PUBLIC KEY-----\n'
94
+
72
95
```
73
96
74
97
## Compatibility
75
98
76
-
Effort is made to make toke as compatible as possible with [PyJWT](https://github.com/jpadilla/pyjwt). To that effect, changes are made to make the relevant tests from the extensive PyJWT [test suite](https://github.com/jpadilla/pyjwt/tree/master/tests) pass.
99
+
Effort is made to make toke as compatible as possible with [PyJWT](https://github.com/jpadilla/pyjwt). For compatibility details, See the readme under [tests](https://github.com/h5rdly/webtoken/tree/main/tests).
77
100
78
101
## Crypto
79
102
80
-
Toke is backed by [jsonwebtoken](https://github.com/Keats/jsonwebtoken) and[aws-lc-rs](https://github.com/aws/aws-lc-rs).
103
+
The crypto backend used by webtoken is[aws-lc-rs](https://github.com/aws/aws-lc-rs).
81
104
82
105
83
106
### Supported algorithms
84
107
85
-
Via jsonwebtoken -
108
+
PyJWT compat -
86
109
- HS256
87
110
- HS384
88
111
- HS512
89
112
- RS256
90
113
- RS384
91
-
- RS512
92
-
93
-
Via aws-lc-rs -
114
+
- RS512-
94
115
- ES512
116
+
117
+
Also -
95
118
- ES256K
96
119
- ML-DSA-65
97
120
98
-
## Fun Facts
99
-
100
-
- Using the Rust Crypto backend with jsonwebtoken made the binary around ~1Mb on linux. However, RSA decoding was slower than using PyJWT. Thus, we switched to aws-lc-rs.
0 commit comments