Encode bytes using the URL- and filesystem-safe Base64 alphabet. Argument s is a bytes-like object to encode. The result is returned as a bytes object. The alphabet uses '-' instead of '+' and '_' instead of '/'.
(s)
| 107 | _urlsafe_decode_translation = bytes.maketrans(b'-_', b'+/') |
| 108 | |
| 109 | def urlsafe_b64encode(s): |
| 110 | """Encode bytes using the URL- and filesystem-safe Base64 alphabet. |
| 111 | |
| 112 | Argument s is a bytes-like object to encode. The result is returned as a |
| 113 | bytes object. The alphabet uses '-' instead of '+' and '_' instead of |
| 114 | '/'. |
| 115 | """ |
| 116 | return b64encode(s).translate(_urlsafe_encode_translation) |
| 117 | |
| 118 | def urlsafe_b64decode(s): |
| 119 | """Decode bytes using the URL- and filesystem-safe Base64 alphabet. |