Skip to content

Commit 7dc86b2

Browse files
committed
Fixed expansion factor for base encodings
1 parent d93d615 commit 7dc86b2

7 files changed

Lines changed: 11 additions & 11 deletions

File tree

codext/base/ascii85.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ def ascii85_encode(input, errors='strict'):
2424
def ascii85_decode(input, errors='strict'):
2525
return base64.a85decode(b(input)), len(input)
2626

27-
add("ascii85", ascii85_encode, ascii85_decode, r"^ascii[-_]?85$", entropy=6.36)
27+
add("ascii85", ascii85_encode, ascii85_decode, r"^ascii[-_]?85$", entropy=6.36, expansion_factor=1.25)
2828

codext/base/base100.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,6 @@ def base100_decode(input, errors="strict"):
5151
return bytes(r), len(input)
5252

5353

54-
add("base100", base100_encode, base100_decode, r"^(?:base[-_]?100|emoji)$")
54+
add("base100", base100_encode, base100_decode, r"^(?:base[-_]?100|emoji)$", expansion_factor=1.)
5555
main = main(100, "<https://github.com/AdamNiederer/base100>")
5656

codext/base/base122.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,6 @@ def _get_7bits(currB, bob, B, decoded):
101101
return "".join(map(chr, r)), len(input)
102102

103103

104-
add("base122", base122_encode, base122_decode, r"^base[-_]?122$")
104+
add("base122", base122_encode, base122_decode, r"^base[-_]?122$", expansion_factor=1.085)
105105
main = main(122, "<http://blog.kevinalbs.com/base122>")
106106

codext/base/base45.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,6 @@ def decode(text, errors="strict"):
8383
return decode
8484

8585

86-
add("base45", base45_encode, base45_decode, r"^base[-_]?45(|[-_]inv(?:erted)?)$")
86+
add("base45", base45_encode, base45_decode, r"^base[-_]?45(|[-_]inv(?:erted)?)$", expansion_factor=1.5)
8787
main = main(45, "<https://datatracker.ietf.org/doc/html/draft-faltstrom-base45-04.txt>")
8888

codext/base/base85.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,6 @@ def base85_decode(input, errors='strict'):
4545
return base64.b85decode(b(input)), len(input)
4646

4747

48-
add("base85", base85_encode, base85_decode, r"^base[-_]?85$", entropy=7.05)
48+
add("base85", base85_encode, base85_decode, r"^base[-_]?85$", entropy=7.05, expansion_factor=1.25)
4949
main = main(85, "RFC 1924")
5050

codext/base/base91.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,6 @@ def decode(text, errors="strict"):
114114

115115

116116
add("base91", base91_encode, base91_decode, r"^base[-_]?91((?:|[-_]alt(?:ernate)?)(?:|[-_]inv(?:erted)?)?)$",
117-
entropy=6.5)
117+
entropy=6.5, expansion_factor=1.231)
118118
main = main(91, "<http://base91.sourceforge.net/>")
119119

codext/base/baseN.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@
1313

1414

1515
B2 = {r'': "01", r'[-_]inv(erted)?': "10"}
16-
base2n(B2, r"^(?:base[-_]?2|bin)(|[-_]inv(?:erted)?|[-_](?!.*(.).*\2)[a-zA-Z0-9]{2})$")
16+
base2n(B2, r"^(?:base[-_]?2|bin)(|[-_]inv(?:erted)?|[-_](?!.*(.).*\2)[a-zA-Z0-9]{2})$", expansion_factor=8.)
1717
main2 = main(2)
1818

1919

2020
B3 = {r'': "123", r'[-_]inv(erted)?': "321"}
21-
base(B3, r"^base[-_]?3(|[-_]inv(?:erted)?|[-_](?!.*(.).*\2)[a-zA-Z0-9]{3})$")
21+
base(B3, r"^base[-_]?3(|[-_]inv(?:erted)?|[-_](?!.*(.).*\2)[a-zA-Z0-9]{3})$", expansion_factor=5.)
2222
main3 = main(3)
2323

2424

2525
B4 = {r'': "1234", r'[-_]inv(erted)?': "4321"}
26-
base2n(B4, r"^base[-_]?4(|[-_]inv(?:erted)?|[-_](?!.*(.).*\2)[a-zA-Z0-9]{4})$")
26+
base2n(B4, r"^base[-_]?4(|[-_]inv(?:erted)?|[-_](?!.*(.).*\2)[a-zA-Z0-9]{4})$", expansion_factor=4.)
2727
main4 = main(4)
2828

2929

@@ -33,12 +33,12 @@
3333

3434

3535
B16 = {'': digits + "ABCDEF", 'inv': "ABCDEF" + digits}
36-
base2n(B16, r"^(?:base[-_]?16|hex)(|[-_]inv(?:erted)?)$")
36+
base2n(B16, r"^(?:base[-_]?16|hex)(|[-_]inv(?:erted)?)$", expansion_factor=2.)
3737
main16 = main(16, "RFC 4648")
3838

3939

4040
B26 = {'': upper, 'inv': lower}
41-
base(B26, r"^(?:base[-_]?26|hex)(|[-_]inv(?:erted)?)$")
41+
base(B26, r"^base[-_]?26(|[-_]inv(?:erted)?)$")
4242
main26 = main(26)
4343

4444

0 commit comments

Comments
 (0)