]> Cypherpunks repositories - gostls13.git/commit
encoding: require unique alphabet for base32 and base64
authorJoe Tsai <joetsai@digital-static.net>
Thu, 22 Jun 2023 18:44:55 +0000 (11:44 -0700)
committerGopher Robot <gobot@golang.org>
Fri, 18 Aug 2023 02:08:03 +0000 (02:08 +0000)
commit243c8c0eec20d981d8e76a3aac82f97cca991571
treeef9bb7bce980eef12cb849a13c18868dead47f59
parent9070f27039560c054fef8f2fb8d775cc2cb983b3
encoding: require unique alphabet for base32 and base64

In order for decoding to faithfully reproduce the encoded input,
the symbols must be unique (i.e., provide a bijective mapping).
Thus, reject duplicate symbols in NewEncoding.

As a minor optimization, modify WithPadding to use the decodeMap
to quickly check whether the padding character is used in O(1)
instead of O(32) or O(64).

Change-Id: I5631f6ff9335c35d59d020dc0e307e3520786fbc
Reviewed-on: https://go-review.googlesource.com/c/go/+/520335
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Joseph Tsai <joetsai@digital-static.net>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
src/encoding/base32/base32.go
src/encoding/base64/base64.go