Title: Support alternative alphabets in BaseXX encodings · Issue #145980 · python/cpython · GitHub
Open Graph Title: Support alternative alphabets in BaseXX encodings · Issue #145980 · python/cpython
X Title: Support alternative alphabets in BaseXX encodings · Issue #145980 · python/cpython
Description: Feature or enhancement RFC 4648 describes two alphabets for Base64 (standard and urlsafe) and two alphabets for base32 (standard and hexadecimal). Python also implements three variants of Base85 (Ascii85 is more complex than this, but it...
Open Graph Description: Feature or enhancement RFC 4648 describes two alphabets for Base64 (standard and urlsafe) and two alphabets for base32 (standard and hexadecimal). Python also implements three variants of Base85 (A...
X Description: Feature or enhancement RFC 4648 describes two alphabets for Base64 (standard and urlsafe) and two alphabets for base32 (standard and hexadecimal). Python also implements three variants of Base85 (A...
Opengraph URL: https://github.com/python/cpython/issues/145980
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Support alternative alphabets in BaseXX encodings","articleBody":"# Feature or enhancement\n\nRFC 4648 describes two alphabets for Base64 (standard and urlsafe) and two alphabets for base32 (standard and hexadecimal). Python also implements three variants of Base85 (Ascii85 is more complex than this, but it can be based on Base85). A number of other formats are based on BaseXX encoding with alternative alphabets.\n\nSo, I suggest to adde the alphabet parameter in several `binascii` functions. They can be used in the implementation of the `base64` module or directly by users implementing alternative formats.\n\nWe can remove just added functions `b2a_z85()` and `a2b_z85()` -- they are equivalent of `b2a_base85()` and `a2b_base85()` with an alternative alphabet. Also, Base64 with alternative alphabets will be more efficient for large data. Accidentally, this also fixes #145968.\n\nFor encoding functions we can simply pass a bytes object containing all alphabet characters. Decoding functions need a reverse table of length which maps a byte to its index or special invalid values. We can provide a function which creates such table from the alphabet.\n\nAlternatively, we can create it automatically from the passed alphabet argument and cache the result. This is less flexible but more user friendly interface. It adds some overhead for small input data, because you need to calculate a hash of the 64- or 85-bytes object, but for large data this is insignificant.\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-145981\n* gh-146230\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/serhiy-storchaka","@type":"Person","name":"serhiy-storchaka"},"datePublished":"2026-03-15T14:34:18.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/145980/cpython/issues/145980"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:b081f936-eb15-6b33-8d27-f0bda09532c3 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A616:102A8A:4ED478E:6DF05AD:6A50F695 |
| html-safe-nonce | 96b4bc3ef144892c97ec8ac789baf54df8a6277347d38069d80b03139f017861 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNjE2OjEwMkE4QTo0RUQ0NzhFOjZERjA1QUQ6NkE1MEY2OTUiLCJ2aXNpdG9yX2lkIjoiNTkyMjI0NzU1MjAyMzk4Mzc2NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 3fa611614e74306c9119edecf1297105c70802431a97222847443b7111df75ea |
| hovercard-subject-tag | issue:4078496930 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/145980/issue_layout |
| twitter:image | https://opengraph.githubassets.com/814cafece58acd10dc47bceceed269bbae9865a3ce96533b9f25589fed975c1a/python/cpython/issues/145980 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/814cafece58acd10dc47bceceed269bbae9865a3ce96533b9f25589fed975c1a/python/cpython/issues/145980 |
| og:image:alt | Feature or enhancement RFC 4648 describes two alphabets for Base64 (standard and urlsafe) and two alphabets for base32 (standard and hexadecimal). Python also implements three variants of Base85 (A... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | serhiy-storchaka |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5266e58c17a510c403505cc811606465e90a881d2007ee7df1c4800d5c659838 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8d836581d020676cc0ef4a83cd2fe17e4af02c3d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width