classification
Title: Add Base32 support for RFC4648 "Extended Hex" alphabet (patch attached)
Type: enhancement Stage: patch review
Components: Library (Lib) Versions: Python 3.8
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: cheryl.sabella, ezio.melotti, martin.panter, matthaeus.wander, pitrou, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2013-01-18 18:21 by matthaeus.wander, last changed 2019-03-27 14:22 by cheryl.sabella.

Files
File name Uploaded Description Edit
base32hex.tar.gz matthaeus.wander, 2013-01-18 18:21 Patches for Python 2.7 and 3
py3_base32hex.patch matthaeus.wander, 2013-01-18 18:51 Patch for Python 3 review
py3_base32hex.patch matthaeus.wander, 2015-07-22 16:50 Patch for 3.5 or 3.6 review
py36_base32hex.patch matthaeus.wander, 2015-07-23 14:15 *fixed* Patch for 3.6
py36_base32hex.patch serhiy.storchaka, 2015-07-23 14:50 Regenerated for review review
Messages (9)
msg180206 - (view) Author: Matthäus Wander (matthaeus.wander) Date: 2013-01-18 18:21
RFC4648 specifies two different alphabets for Base32: 1) the common one already used in RFC3548 and implemented in Python, and 2) an "Extended Hex" alphabet which is used by e.g. DNSSEC NSEC3 but not yet implemented in Python.

The attached patches add the "Extended Hex" alphabet to Python 2.7 and 3 via an optional parameter 'base32hex=False'. Default behavior is not changed.

patch Lib/base64.py < py27_base64.patch
patch Lib/test/test_base64.py < py27_test_base64.patch
msg180207 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2013-01-18 18:26
Since this is a new feature it can go on 3.4 only.
It would also be better to include both the changes for base64.py and test_base64.py in a single patch and attach that, rather than uploading an archive that contains both.

FTR the links to the relevant RFCs are:
http://tools.ietf.org/html/rfc3548
http://tools.ietf.org/html/rfc4648
msg180210 - (view) Author: Matthäus Wander (matthaeus.wander) Date: 2013-01-18 18:51
Added single patch as requested.
msg243591 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-05-19 13:57
The patch can't be longer applied cleanly. It should be synchronized with sources. It is the last chance for this feature to get to 3.5 if somebody will update the patch and add the documentation.

The feature itself LGTM. The only my doubt is about the name of boolean parameter. "base32hex" is recommended as encoding name. Parameter can be named as "exthex" or "extended_hex". Or may be add separate functions b32hexencode/b32hexdecode. I'm not sure.
msg247134 - (view) Author: Matthäus Wander (matthaeus.wander) Date: 2015-07-22 16:50
I've created a new patch that works against the current 3.5 sources. Should be fine for 3.6, I guess.

Separate functions b32hexencode and b32hexdecode are used now. There is no optional parameter "base32hex" anymore.
msg247158 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2015-07-23 01:21
Matthäus, I think you uploaded the old patch again by accident. Also, see Berker’s old comments about documentation, and my new suggestions, on the Rietveld code review, if you haven’t already.
msg247205 - (view) Author: Matthäus Wander (matthaeus.wander) Date: 2015-07-23 14:15
*facepalm* Yes, I uploaded the old patch twice. Sorry for that.

- Added doc update.
- Added test case that includes all 32 characters codes.

I'm reusing the existing Base32 table generation logic without changes. It has been changed (in 3.4 or so) since the first patch. If the logic is still to be changed as suggested by Martin in Rietveld review, I'd suggest to open a separate issue because it affects the existing Base32 implementation, too.
msg247216 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-07-23 15:26
Added comments on Rietveld.
msg338962 - (view) Author: Cheryl Sabella (cheryl.sabella) * (Python committer) Date: 2019-03-27 14:22
Is there interest in having this patch converted to a pull request?
History
Date User Action Args
2019-03-27 14:22:28cheryl.sabellasetnosy: + cheryl.sabella

messages: + msg338962
versions: + Python 3.8, - Python 3.6
2015-07-23 15:26:24serhiy.storchakasetstage: needs patch -> patch review
2015-07-23 15:26:16serhiy.storchakasetmessages: + msg247216
2015-07-23 14:50:03serhiy.storchakasetfiles: + py36_base32hex.patch
2015-07-23 14:15:35matthaeus.wandersetfiles: + py36_base32hex.patch

messages: + msg247205
2015-07-23 08:41:18serhiy.storchakasetstage: patch review -> needs patch
2015-07-23 01:21:05martin.pantersetnosy: + martin.panter
messages: + msg247158
2015-07-22 16:50:52matthaeus.wandersetfiles: + py3_base32hex.patch

messages: + msg247134
versions: + Python 3.6, - Python 3.5
2015-05-19 13:57:38serhiy.storchakasetnosy: + pitrou
messages: + msg243591
2015-05-19 13:38:13serhiy.storchakasetstage: patch review
versions: + Python 3.5, - Python 3.4
2013-05-18 18:57:14serhiy.storchakasetnosy: + serhiy.storchaka
2013-01-18 18:51:10matthaeus.wandersetfiles: + py3_base32hex.patch
keywords: + patch
messages: + msg180210
2013-01-18 18:26:11ezio.melottisetnosy: + ezio.melotti

messages: + msg180207
versions: + Python 3.4, - Python 2.7, Python 3.5
2013-01-18 18:21:19matthaeus.wandercreate