Encode bytes-like object b in base85 format and return a bytes object. If pad is true, the input is padded with b'\\0' so its length is a multiple of 4 bytes before encoding.
(b, pad=False)
| 440 | _b85dec = None |
| 441 | |
| 442 | def b85encode(b, pad=False): |
| 443 | """Encode bytes-like object b in base85 format and return a bytes object. |
| 444 | |
| 445 | If pad is true, the input is padded with b'\\0' so its length is a multiple of |
| 446 | 4 bytes before encoding. |
| 447 | """ |
| 448 | global _b85chars, _b85chars2 |
| 449 | # Delay the initialization of tables to not waste memory |
| 450 | # if the function is never called |
| 451 | if _b85chars2 is None: |
| 452 | _b85chars = [bytes((i,)) for i in _b85alphabet] |
| 453 | _b85chars2 = [(a + b) for a in _b85chars for b in _b85chars] |
| 454 | return _85encode(b, _b85chars, _b85chars2, pad) |
| 455 | |
| 456 | def b85decode(b): |
| 457 | """Decode the base85-encoded bytes-like object or ASCII string b |