codext 1.16.4__tar.gz → 1.16.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {codext-1.16.4 → codext-1.16.5}/PKG-INFO +1 -1
- codext-1.16.5/src/codext/VERSION.txt +1 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/base/_base.py +6 -4
- {codext-1.16.4 → codext-1.16.5}/src/codext/checksums/crc.py +2 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext.egg-info/PKG-INFO +1 -1
- {codext-1.16.4 → codext-1.16.5}/tests/test_base.py +24 -1
- {codext-1.16.4 → codext-1.16.5}/tests/test_manual.py +19 -0
- codext-1.16.4/src/codext/VERSION.txt +0 -1
- {codext-1.16.4 → codext-1.16.5}/.coveragerc +0 -0
- {codext-1.16.4 → codext-1.16.5}/.github/ISSUE_TEMPLATE/add-encoding.yml +0 -0
- {codext-1.16.4 → codext-1.16.5}/.github/copilot-instructions.md +0 -0
- {codext-1.16.4 → codext-1.16.5}/.github/prompts/add_codec.prompt.md +0 -0
- {codext-1.16.4 → codext-1.16.5}/.github/pull_request_template.md +0 -0
- {codext-1.16.4 → codext-1.16.5}/.github/workflows/python-package.yml +0 -0
- {codext-1.16.4 → codext-1.16.5}/.gitignore +0 -0
- {codext-1.16.4 → codext-1.16.5}/.readthedocs.yml +0 -0
- {codext-1.16.4 → codext-1.16.5}/LICENSE +0 -0
- {codext-1.16.4 → codext-1.16.5}/README.md +0 -0
- {codext-1.16.4 → codext-1.16.5}/docs/coverage.svg +0 -0
- {codext-1.16.4 → codext-1.16.5}/docs/hakin9-codext.pdf +0 -0
- {codext-1.16.4 → codext-1.16.5}/docs/mkdocs.yml +0 -0
- {codext-1.16.4 → codext-1.16.5}/docs/pages/cli.md +0 -0
- {codext-1.16.4 → codext-1.16.5}/docs/pages/css/extra.css +0 -0
- {codext-1.16.4 → codext-1.16.5}/docs/pages/demos/using-bases.gif +0 -0
- {codext-1.16.4 → codext-1.16.5}/docs/pages/demos/using-codext.gif +0 -0
- {codext-1.16.4 → codext-1.16.5}/docs/pages/demos/using-debase.gif +0 -0
- {codext-1.16.4 → codext-1.16.5}/docs/pages/enc/base.md +0 -0
- {codext-1.16.4 → codext-1.16.5}/docs/pages/enc/binary.md +0 -0
- {codext-1.16.4 → codext-1.16.5}/docs/pages/enc/common.md +0 -0
- {codext-1.16.4 → codext-1.16.5}/docs/pages/enc/compressions.md +0 -0
- {codext-1.16.4 → codext-1.16.5}/docs/pages/enc/crypto.md +0 -0
- {codext-1.16.4 → codext-1.16.5}/docs/pages/enc/hashing.md +0 -0
- {codext-1.16.4 → codext-1.16.5}/docs/pages/enc/languages.md +0 -0
- {codext-1.16.4 → codext-1.16.5}/docs/pages/enc/others.md +0 -0
- {codext-1.16.4 → codext-1.16.5}/docs/pages/enc/stegano.md +0 -0
- {codext-1.16.4 → codext-1.16.5}/docs/pages/enc/web.md +0 -0
- {codext-1.16.4 → codext-1.16.5}/docs/pages/features.md +0 -0
- {codext-1.16.4 → codext-1.16.5}/docs/pages/guessing.md +0 -0
- {codext-1.16.4 → codext-1.16.5}/docs/pages/howto.md +0 -0
- {codext-1.16.4 → codext-1.16.5}/docs/pages/img/banner.png +0 -0
- {codext-1.16.4 → codext-1.16.5}/docs/pages/img/icon.png +0 -0
- {codext-1.16.4 → codext-1.16.5}/docs/pages/img/logo.png +0 -0
- {codext-1.16.4 → codext-1.16.5}/docs/pages/index.md +0 -0
- {codext-1.16.4 → codext-1.16.5}/docs/pages/manipulations.md +0 -0
- {codext-1.16.4 → codext-1.16.5}/docs/requirements.txt +0 -0
- {codext-1.16.4 → codext-1.16.5}/pyproject.toml +0 -0
- {codext-1.16.4 → codext-1.16.5}/pytest.ini +0 -0
- {codext-1.16.4 → codext-1.16.5}/requirements.txt +0 -0
- {codext-1.16.4 → codext-1.16.5}/setup.cfg +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/__common__.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/__info__.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/__init__.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/base/__init__.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/base/_base2n.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/base/base100.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/base/base122.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/base/base45.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/base/base85.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/base/base91.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/base/baseN.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/binary/__init__.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/binary/baudot.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/binary/bcd.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/binary/excess3.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/binary/gray.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/binary/manchester.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/binary/rotate.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/checksums/__init__.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/checksums/adler.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/checksums/luhn.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/common/__init__.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/common/a1z26.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/common/cases.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/common/dummy.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/common/octal.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/common/ordinal.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/compressions/__init__.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/compressions/gzipp.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/compressions/lz77.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/compressions/lz78.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/compressions/pkzip.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/crypto/__init__.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/crypto/affine.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/crypto/atbash.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/crypto/bacon.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/crypto/barbie.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/crypto/citrix.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/crypto/phillips.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/crypto/playfair.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/crypto/polybius.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/crypto/railfence.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/crypto/rot.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/crypto/scytale.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/crypto/shift.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/crypto/vic.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/crypto/vigenere.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/crypto/xor.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/hashing/__init__.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/hashing/blake.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/hashing/crypt.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/hashing/md.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/hashing/mmh3.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/hashing/sha.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/hashing/shake.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/languages/__init__.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/languages/braille.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/languages/galactic.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/languages/ipsum.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/languages/leetspeak.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/languages/morse.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/languages/navajo.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/languages/radio.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/languages/southpark.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/languages/tap.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/languages/tomtom.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/macros.json +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/others/__init__.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/others/dna.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/others/kbshift.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/others/letters.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/others/markdown.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/others/uuencode.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/stegano/__init__.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/stegano/hexagram.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/stegano/klopf.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/stegano/resistor.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/stegano/rick.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/stegano/sms.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/stegano/whitespace.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/web/__init__.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/web/html.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext/web/url.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext.egg-info/SOURCES.txt +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext.egg-info/dependency_links.txt +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext.egg-info/entry_points.txt +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext.egg-info/requires.txt +0 -0
- {codext-1.16.4 → codext-1.16.5}/src/codext.egg-info/top_level.txt +0 -0
- {codext-1.16.4 → codext-1.16.5}/tests/__init__.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/tests/test_common.py +0 -0
- {codext-1.16.4 → codext-1.16.5}/tests/test_generated.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
1.16.5
|
|
@@ -125,8 +125,10 @@ def base_encode(input, charset, errors="strict", exc=BaseEncodeError):
|
|
|
125
125
|
if i > SIZE_LIMIT:
|
|
126
126
|
raise InputSizeLimitError("Input exceeded size limit")
|
|
127
127
|
return i * charset[0]
|
|
128
|
-
|
|
129
|
-
|
|
128
|
+
# keep this fast-path only for a non-standard 10-character charset ; the digits
|
|
129
|
+
# charset uses the generic loop below (leading zeros, bignums, no str/int round-trip)
|
|
130
|
+
if n == 10 and charset != digits:
|
|
131
|
+
return "".join(charset[int(x)] for x in str(i))
|
|
130
132
|
while i > 0:
|
|
131
133
|
i, c = divmod(i, n)
|
|
132
134
|
r = charset[c] + r
|
|
@@ -148,8 +150,8 @@ def base_decode(input, charset, errors="strict", exc=BaseDecodeError):
|
|
|
148
150
|
i, n, dec = 0, len(charset), lambda n: base_encode(n, [chr(x) for x in range(256)], errors, exc)
|
|
149
151
|
if n == 1:
|
|
150
152
|
return i2s(len(input))
|
|
151
|
-
if n == 10:
|
|
152
|
-
return
|
|
153
|
+
if n == 10 and charset != digits:
|
|
154
|
+
return "".join(str(charset.index(c)) for c in input)
|
|
153
155
|
for k, c in enumerate(input):
|
|
154
156
|
try:
|
|
155
157
|
i = i * n + charset.index(c)
|
|
@@ -13,6 +13,7 @@ from ..__common__ import add
|
|
|
13
13
|
|
|
14
14
|
CRC = {
|
|
15
15
|
'': {
|
|
16
|
+
'': (0x1021, 0xc6c6, True, True, 0, 0xbf05),
|
|
16
17
|
'a': (0x1021, 0xc6c6, True, True, 0, 0xbf05),
|
|
17
18
|
},
|
|
18
19
|
8: {
|
|
@@ -78,6 +79,7 @@ CRC = {
|
|
|
78
79
|
'mpt1327': (0x6815, 0, False, False, 1, 0x2566),
|
|
79
80
|
},
|
|
80
81
|
16: {
|
|
82
|
+
'': (0x8005, 0, True, True, 0, 0xbb3d),
|
|
81
83
|
'acorn': (0x1021, 0, False, False, 0, 0x31c3),
|
|
82
84
|
'arc': (0x8005, 0, True, True, 0, 0xbb3d),
|
|
83
85
|
'atom': (0x002d, 0, True, True, 0, 0x4287),
|
|
@@ -112,7 +112,30 @@ class TestCodecsBase(TestCase):
|
|
|
112
112
|
self.assertEqual(codecs.decode(B8, "base8-01234567"), STR)
|
|
113
113
|
self.assertRaises(LookupError, codecs.encode, "test", "base8-0123456")
|
|
114
114
|
self.assertRaises(LookupError, codecs.encode, "test", "base8-012345678")
|
|
115
|
-
|
|
115
|
+
|
|
116
|
+
def test_codec_base10(self):
|
|
117
|
+
B10 = "2361031878030638688519054699098996"
|
|
118
|
+
self.assertEqual(codecs.encode(STR, "base10"), B10)
|
|
119
|
+
self.assertEqual(codecs.encode(b(STR), "base10"), b(B10))
|
|
120
|
+
self.assertEqual(codecs.decode(B10, "base10"), STR)
|
|
121
|
+
self.assertEqual(codecs.decode(b(B10), "base10"), b(STR))
|
|
122
|
+
for alias in ["int", "integer", "dec", "decimal"]:
|
|
123
|
+
self.assertEqual(codecs.encode(STR, alias), B10)
|
|
124
|
+
self.assertEqual(codecs.decode(B10, alias), STR)
|
|
125
|
+
# leading null bytes must be preserved as leading '0' characters
|
|
126
|
+
self.assertEqual(codecs.encode("\x00abc", "base10"), "06382179")
|
|
127
|
+
self.assertEqual(codecs.encode("\x00", "base10"), "0")
|
|
128
|
+
self.assertEqual(codecs.encode("\x00\x00abc", "base10"), "006382179")
|
|
129
|
+
self.assertEqual(codecs.decode("06382179", "base10"), "\x00abc")
|
|
130
|
+
self.assertEqual(codecs.decode("00", "base10"), "\x00\x00")
|
|
131
|
+
self.assertEqual(codecs.encode(b("\x00abc"), "base10"), b("06382179"))
|
|
132
|
+
self.assertEqual(codecs.decode(b("06382179"), "base10"), b("\x00abc"))
|
|
133
|
+
# a value whose big integer ends in a 0xe nibble must survive decoding
|
|
134
|
+
self.assertEqual(codecs.decode(codecs.encode(b"d\xc6\xfe", "base10"), "base10"), b"d\xc6\xfe")
|
|
135
|
+
# large inputs must not hit the int<->str conversion digit limit
|
|
136
|
+
for data in [b"\x00\xff\xfe", b"\x00\x00", b"\x2a" * 2048]:
|
|
137
|
+
self.assertEqual(codecs.decode(codecs.encode(data, "base10"), "base10"), data)
|
|
138
|
+
|
|
116
139
|
def test_codec_base16(self):
|
|
117
140
|
B16 = "7468697320697320612074657374"
|
|
118
141
|
self.assertEqual(codecs.encode(STR, "base16"), B16)
|
|
@@ -106,6 +106,25 @@ class ManualTestCase(TestCase):
|
|
|
106
106
|
for s, r in [("", ""), ("0", "0"), ("1", "8"), ("7992739871", "3")]:
|
|
107
107
|
self.assertEqual(codecs.encode(s, "luhn"), r)
|
|
108
108
|
self.assertEqual(codecs.encode("-", "luhn", errors="ignore"), "")
|
|
109
|
+
|
|
110
|
+
def test_codec_crc_bare_defaults(self):
|
|
111
|
+
# a crc<width> used without a variant suffix must resolve to that family's default ;
|
|
112
|
+
# width 16 and the crc-a family had no default and crashed with KeyError instead
|
|
113
|
+
from codext.checksums.crc import CRC
|
|
114
|
+
for n in CRC.keys():
|
|
115
|
+
name = "crc%d" % n if isinstance(n, int) else "crc"
|
|
116
|
+
expected = "%0{}x".format(round((n or 16)/4+.5)) % CRC[n][""][5]
|
|
117
|
+
self.assertEqual(codecs.encode("123456789", name), expected)
|
|
118
|
+
self.assertEqual(codecs.encode(b"123456789", name), b(expected))
|
|
119
|
+
# bare crc-16 is CRC-16/ARC (poly 0x8005), the same as its arc/ibm/lha aliases
|
|
120
|
+
for name in ["crc16", "crc-16", "crc_16", "crc16-arc", "crc16-ibm", "crc16-lha"]:
|
|
121
|
+
self.assertEqual(codecs.encode("123456789", name), "bb3d")
|
|
122
|
+
# bare crc is CRC-A, the same as the crca alias
|
|
123
|
+
self.assertEqual(codecs.encode("123456789", "crc"), "bf05")
|
|
124
|
+
self.assertEqual(codecs.encode("123456789", "crca"), "bf05")
|
|
125
|
+
# adding a default must not make an unknown variant resolve
|
|
126
|
+
self.assertRaises(LookupError, codecs.encode, "123456789", "crc16-bad")
|
|
127
|
+
self.assertRaises(LookupError, codecs.encode, "123456789", "crc-bad")
|
|
109
128
|
|
|
110
129
|
def test_codec_dummy_str_manips(self):
|
|
111
130
|
STR = "this is a test"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
1.16.4
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|