cyclic-cypher-compressor 0.2.0__py3-none-any.whl

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.
@@ -0,0 +1,34 @@
1
+ """Cyclic Cypher Compressor package."""
2
+
3
+ from .core import (
4
+ CONST_CYCLE,
5
+ MOV_CYCLE,
6
+ KEYBOARD,
7
+ CONST_ORDER,
8
+ MOV_ORDER,
9
+ build_keyboard_cyphers,
10
+ repeat_stream,
11
+ side_by_side_matchup,
12
+ compress_block,
13
+ unfold_from_alignments,
14
+ root_digit,
15
+ fold_tiers,
16
+ )
17
+
18
+ __version__ = "0.2.0"
19
+
20
+ __all__ = [
21
+ "__version__",
22
+ "CONST_CYCLE",
23
+ "MOV_CYCLE",
24
+ "KEYBOARD",
25
+ "CONST_ORDER",
26
+ "MOV_ORDER",
27
+ "build_keyboard_cyphers",
28
+ "repeat_stream",
29
+ "side_by_side_matchup",
30
+ "compress_block",
31
+ "unfold_from_alignments",
32
+ "root_digit",
33
+ "fold_tiers",
34
+ ]
@@ -0,0 +1,29 @@
1
+ """Command-line interface for cyclic-cypher-compressor."""
2
+
3
+ import argparse
4
+ import json
5
+ from .core import compress_block
6
+
7
+
8
+ def main() -> None:
9
+ parser = argparse.ArgumentParser(
10
+ description="Run cyclic cypher side-by-side alignment compression."
11
+ )
12
+ parser.add_argument("text", help="Input string to fold and align")
13
+ parser.add_argument("--cypher", default="c1", help="Cypher ID (c1..c6)")
14
+ parser.add_argument("--mult", type=int, default=1, help="Multiplier (1..6)")
15
+ parser.add_argument("--shift", type=int, default=0, help="Moving 7-digit offset (0..6)")
16
+ args = parser.parse_args()
17
+
18
+ result = compress_block(
19
+ args.text,
20
+ cypher_id=args.cypher,
21
+ multiplier=args.mult,
22
+ move_shift=args.shift,
23
+ )
24
+ print(result["header"])
25
+ print(json.dumps({"tiers": len(result["tiers"]), "aligned": result["aligned_count"], "residuals": result["residual_count"]}, indent=2))
26
+
27
+
28
+ if __name__ == "__main__":
29
+ main()
@@ -0,0 +1,197 @@
1
+ """Core cyclic cypher, alignment matchup, and tier-folding implementation."""
2
+
3
+ from typing import Dict, List, Tuple
4
+
5
+ CONST_CYCLE = "142857"
6
+ MOV_CYCLE = "0142857"
7
+
8
+ KEYBOARD = (
9
+ " abcdefghijklmnopqrstuvwxyz"
10
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
11
+ "0123456789.,!?;:'\"-()[]{}@#$%^&*+=_/<>\\|~`"
12
+ )
13
+
14
+ CONST_ORDER = ["1", "4", "2", "8", "5", "7"]
15
+ MOV_ORDER = ["0", "1", "4", "2", "8", "5", "7"]
16
+
17
+
18
+ def build_keyboard_cyphers(count: int = 6) -> Dict[str, Dict[str, str]]:
19
+ """Generate deterministic cypher maps c1..cN over the universal keyboard."""
20
+ cyphers: Dict[str, Dict[str, str]] = {}
21
+ for idx in range(1, count + 1):
22
+ shift = (idx - 1) % len(CONST_CYCLE)
23
+ rot = CONST_CYCLE[shift:] + CONST_CYCLE[:shift]
24
+ cyphers[f"c{idx}"] = {ch: rot[i % len(rot)] for i, ch in enumerate(KEYBOARD)}
25
+ return cyphers
26
+
27
+
28
+ def repeat_stream(pattern: str, length: int) -> str:
29
+ """Repeat a cyclic digit pattern cleanly to match target length."""
30
+ if length <= 0:
31
+ return ""
32
+ return (pattern * ((length // len(pattern)) + 1))[:length]
33
+
34
+
35
+ def root_digit(d1: int, d2: int, d3: int) -> int:
36
+ """Stepwise single-digit root consolidation for overlapping triple sums."""
37
+ s1 = d1 + d2
38
+ while s1 >= 10:
39
+ s1 = sum(int(x) for x in str(s1))
40
+ s2 = s1 + d3
41
+ while s2 >= 10:
42
+ s2 = sum(int(x) for x in str(s2))
43
+ return s2
44
+
45
+
46
+ def fold_tiers(digit_string: str, floor: int = 6) -> List[Dict[str, object]]:
47
+ """
48
+ Fold a numeric cypher string across overlapping triple-sum tiers,
49
+ stripping 3, 6, 9 at each tier and recording last-3 edge markers
50
+ until reaching the nearest tier >= floor digits.
51
+ """
52
+ curr = [int(c) for c in digit_string]
53
+ tiers: List[Dict[str, object]] = []
54
+ tier_idx = 0
55
+
56
+ while True:
57
+ raw_str = "".join(map(str, curr))
58
+ removed_369 = [(i, d) for i, d in enumerate(curr) if d in (3, 6, 9)]
59
+ seq_starts = [
60
+ i
61
+ for i in range(len(curr) - 1)
62
+ if curr[i] not in (3, 6, 9)
63
+ and curr[i] == curr[i + 1]
64
+ and (i == 0 or curr[i - 1] != curr[i])
65
+ ]
66
+ shrunk = [d for d in curr if d not in (3, 6, 9)]
67
+ shrunk_str = "".join(map(str, shrunk))
68
+
69
+ tiers.append(
70
+ {
71
+ "tier": tier_idx,
72
+ "raw": raw_str,
73
+ "raw_last3": raw_str[-3:],
74
+ "removed_369": removed_369,
75
+ "seq_starts": seq_starts,
76
+ "shrunk": shrunk_str,
77
+ "shrunk_last3": shrunk_str[-3:],
78
+ }
79
+ )
80
+
81
+ if len(shrunk) <= floor + 1:
82
+ break
83
+
84
+ nxt = [
85
+ root_digit(shrunk[i], shrunk[i + 1], shrunk[i + 2])
86
+ for i in range(len(shrunk) - 2)
87
+ ]
88
+ if len(nxt) < floor:
89
+ break
90
+ curr = nxt
91
+ tier_idx += 1
92
+
93
+ return tiers
94
+
95
+
96
+ def side_by_side_matchup(
97
+ text: str,
98
+ cypher_id: str = "c1",
99
+ multiplier: int = 1,
100
+ move_shift: int = 0,
101
+ ) -> Dict[str, object]:
102
+ """
103
+ Encode text through a universal keyboard cypher and compare constant (6-digit)
104
+ and moving (7-digit) streams side by side to produce compact sum signatures.
105
+ """
106
+ cyphers = build_keyboard_cyphers(6)
107
+ if cypher_id not in cyphers:
108
+ raise ValueError(
109
+ f"Unknown cypher_id '{cypher_id}'. Expected one of {list(cyphers.keys())}"
110
+ )
111
+
112
+ cmap = cyphers[cypher_id]
113
+ encoded = "".join(cmap.get(ch, cmap[" "]) for ch in text)
114
+ n = len(encoded)
115
+
116
+ c_shift = (multiplier - 1) % len(CONST_CYCLE)
117
+ const_base = CONST_CYCLE[c_shift:] + CONST_CYCLE[:c_shift]
118
+ const_stream = repeat_stream(const_base, n)
119
+
120
+ m_shift = move_shift % len(MOV_CYCLE)
121
+ mov_base = MOV_CYCLE[m_shift:] + MOV_CYCLE[:m_shift]
122
+ mov_stream = repeat_stream(mov_base, n)
123
+
124
+ const_alignments: List[Tuple[int, str, str]] = [
125
+ (i, text[i], encoded[i])
126
+ for i in range(n)
127
+ if encoded[i] == const_stream[i]
128
+ ]
129
+ mov_alignments: List[Tuple[int, str, str]] = [
130
+ (i, text[i], encoded[i])
131
+ for i in range(n)
132
+ if encoded[i] == mov_stream[i]
133
+ ]
134
+
135
+ const_sums = [sum(1 for _, _, d in const_alignments if d == k) for k in CONST_ORDER]
136
+ mov_sums = [sum(1 for _, _, d in mov_alignments if d == k) for k in MOV_ORDER]
137
+
138
+ const_tag = f"{cypher_id}cx{multiplier}." + ".".join(map(str, const_sums))
139
+ mov_tag = f"{cypher_id}mx{multiplier}." + ".".join(map(str, mov_sums))
140
+
141
+ return {
142
+ "length": n,
143
+ "encoded_digits": encoded,
144
+ "const_stream": const_stream,
145
+ "mov_stream": mov_stream,
146
+ "const_alignments": const_alignments,
147
+ "mov_alignments": mov_alignments,
148
+ "const_signature": const_tag,
149
+ "mov_signature": mov_tag,
150
+ }
151
+
152
+
153
+ def compress_block(
154
+ text: str,
155
+ cypher_id: str = "c1",
156
+ multiplier: int = 1,
157
+ move_shift: int = 0,
158
+ ) -> Dict[str, object]:
159
+ """
160
+ Return the compact side-by-side signature header, tier fold summary,
161
+ and residual characters for exact round-trip recovery.
162
+ """
163
+ m = side_by_side_matchup(
164
+ text, cypher_id=cypher_id, multiplier=multiplier, move_shift=move_shift
165
+ )
166
+ aligned_positions = {pos for pos, _, _ in m["const_alignments"]} | {
167
+ pos for pos, _, _ in m["mov_alignments"]
168
+ }
169
+ residuals = [(i, text[i]) for i in range(len(text)) if i not in aligned_positions]
170
+ tiers = fold_tiers(str(m["encoded_digits"]), floor=6)
171
+
172
+ return {
173
+ "header": f"{m['const_signature']} | {m['mov_signature']} | len={m['length']}",
174
+ "const_signature": m["const_signature"],
175
+ "mov_signature": m["mov_signature"],
176
+ "tiers": tiers,
177
+ "aligned_count": len(aligned_positions),
178
+ "residual_count": len(residuals),
179
+ "residuals": residuals,
180
+ }
181
+
182
+
183
+ def unfold_from_alignments(
184
+ length: int,
185
+ const_alignments: List[Tuple[int, str, str]],
186
+ mov_alignments: List[Tuple[int, str, str]],
187
+ residuals: List[Tuple[int, str]],
188
+ ) -> str:
189
+ """Reassemble original text from aligned hits and residual positions."""
190
+ slots: List[str] = [""] * length
191
+ for pos, ch, _ in const_alignments:
192
+ slots[pos] = ch
193
+ for pos, ch, _ in mov_alignments:
194
+ slots[pos] = ch
195
+ for pos, ch in residuals:
196
+ slots[pos] = ch
197
+ return "".join(slots)
@@ -0,0 +1,58 @@
1
+ Metadata-Version: 2.4
2
+ Name: cyclic-cypher-compressor
3
+ Version: 0.2.0
4
+ Summary: Universal keyboard cyclic cypher and side-by-side constant/moving alignment sum compressor.
5
+ Author: 50shades0fGraei
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/50shades0fGraei/cyclic-cypher-compressor
8
+ Project-URL: Repository, https://github.com/50shades0fgraei/666-cyclic-compressor
9
+ Keywords: compression,cypher,cyclic,142857,alignment
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Operating System :: OS Independent
15
+ Requires-Python: >=3.8
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+ Dynamic: license-file
19
+
20
+ # Cyclic Cypher Compressor (`cyclic-cypher-compressor`)
21
+
22
+ A Python package implementing the universal keyboard cyclic cypher (`142857` constant cycle & `0142857` moving cycle) with overlapping triple-sum tier reduction, `3/6/9` shrinking, `last-3` boundary markers, and side-by-side alignment-sum signatures.
23
+
24
+ ## Installation
25
+
26
+ ```bash
27
+ pip install cyclic-cypher-compressor
28
+ ```
29
+
30
+ ## Quick Start
31
+
32
+ ```python
33
+ from cyclic_cypher_compressor import (
34
+ side_by_side_matchup,
35
+ compress_block,
36
+ unfold_from_alignments,
37
+ fold_tiers,
38
+ )
39
+
40
+ text = "there we were in the dark before the dawn"
41
+ match = side_by_side_matchup(text, cypher_id="c1", multiplier=1, move_shift=0)
42
+ print(match["const_signature"], "|", match["mov_signature"])
43
+
44
+ pkg = compress_block(text, cypher_id="c1", multiplier=1, move_shift=0)
45
+ restored = unfold_from_alignments(
46
+ length=match["length"],
47
+ const_alignments=match["const_alignments"],
48
+ mov_alignments=match["mov_alignments"],
49
+ residuals=pkg["residuals"],
50
+ )
51
+ assert restored == text
52
+ ```
53
+
54
+ ## CLI Usage
55
+
56
+ ```bash
57
+ cyclic-compress "there we were in the dark before the dawn" --cypher c1 --mult 1 --shift 0
58
+ ```
@@ -0,0 +1,9 @@
1
+ cyclic_cypher_compressor/__init__.py,sha256=Xi0a8AabteGk3BhAP0TeWGHQ4yW46oslM0C-1zaP7eY,606
2
+ cyclic_cypher_compressor/cli.py,sha256=yRLy95kWXHiV-TNPM36mPiuQ2OXYUMKSxdwiNSXNACY,971
3
+ cyclic_cypher_compressor/core.py,sha256=NXnDJukEccoi3Ws7q-YKPAfcUyd92OjTMWDPLMFlr4s,6278
4
+ cyclic_cypher_compressor-0.2.0.dist-info/licenses/LICENSE,sha256=a-tsAm0Dg6vuo2UIlHw9tTe7eOZcalR_2W33Fpj_9uI,1072
5
+ cyclic_cypher_compressor-0.2.0.dist-info/METADATA,sha256=K0I-v-3PsrfgBy0AnTByvGjzhE4sgKvR4TG_AA8Ehbs,1955
6
+ cyclic_cypher_compressor-0.2.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
7
+ cyclic_cypher_compressor-0.2.0.dist-info/entry_points.txt,sha256=mXNPXWUP_ojyG0uds6XttbuJLzS-Cizegs7TZTaK28s,70
8
+ cyclic_cypher_compressor-0.2.0.dist-info/top_level.txt,sha256=mWMIoATt20Zjf1WKcOd6O2aj7YHh4O_CNSOqbMELBoU,25
9
+ cyclic_cypher_compressor-0.2.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ cyclic-compress = cyclic_cypher_compressor.cli:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 50shades0fGraei
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ cyclic_cypher_compressor