You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Derive Base16 decode tables from custom encode tables so a configured codec can decode its own output. Reject encode tables that do not contain exactly 16 unique byte values.
Reviewed-by: OpenAI Codex
Reviewed-by: Anthropic Claude Code
Copy file name to clipboardExpand all lines: src/changes/changes.xml
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -45,6 +45,7 @@ The <action> type attribute can be add,update,fix,remove.
45
45
<body>
46
46
<releaseversion="1.22.1"date="YYYY-MM-DD"description="This is a feature and maintenance release. Java 8 or later is required.">
47
47
<!-- FIX -->
48
+
<actiontype="fix"issue="CODEC-341"dev="ggregory"due-to="Ruiqi Dong, Gary Gregory">Base16.Builder.setEncodeTable(byte...) can create a codec that cannot decode its own output.</action>
48
49
<actiontype="add"issue="CODEC-337"dev="pkarwasz"due-to="Ruiqi Dong, Gary Gregory">Digest ALL reuses System.in, so only the first algorithm sees the real input (#431).</action>
Copy file name to clipboardExpand all lines: src/main/java/org/apache/commons/codec/binary/Base16.java
+43-8Lines changed: 43 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -33,7 +33,7 @@
33
33
* </p>
34
34
* <p>
35
35
* The only additional feature above those specified in RFC 4648 is support for working with a lower-case alphabet in addition to the default upper-case
36
-
* alphabet.
36
+
* alphabet, and configuring a custom 16-byte alphabet with {@link Builder#setEncodeTable(byte...)}.
37
37
* </p>
38
38
*
39
39
* @see Base16InputStream
@@ -78,10 +78,18 @@ public Base16 get() {
78
78
returnnewBase16(this);
79
79
}
80
80
81
+
/**
82
+
* Sets the Base16 encode table and derives the matching decode table.
83
+
*
84
+
* @param encodeTable 16 unique bytes, null resets to the default upper-case table.
85
+
* @return {@code this} instance.
86
+
* @throws IllegalArgumentException if {@code encodeTable} does not contain 16 unique bytes.
0 commit comments