alarihash 1.0.0__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.
@@ -0,0 +1,9 @@
1
+ Metadata-Version: 2.4
2
+ Name: alarihash
3
+ Version: 1.0.0
4
+ Summary: Python implementation of the AlariHash-X encoding pipeline
5
+ Home-page: https://github.com/alaricholt677/PKGS
6
+ Author: alaricholt677
7
+ Dynamic: author
8
+ Dynamic: home-page
9
+ Dynamic: summary
@@ -0,0 +1 @@
1
+ from .encoder import alari_encode
@@ -0,0 +1,83 @@
1
+ # alarihash/encoder.py
2
+
3
+ def normalize_input(s: str) -> str:
4
+ return " ".join(s.lower().split())
5
+
6
+
7
+ def text_to_binary(s: str) -> str:
8
+ return "".join(format(ord(c), "08b") for c in s)
9
+
10
+
11
+ def scramble_once(binary: str, round_index: int) -> str:
12
+ out = []
13
+ shift = (7 + round_index * 3) % len(binary) or 1
14
+
15
+ for i in range(len(binary)):
16
+ a = int(binary[i])
17
+ b = int(binary[(i + shift) % len(binary)])
18
+ c = int(binary[(i + len(binary) - shift) % len(binary)])
19
+ bit = (a ^ b ^ c) & 1
20
+ out.append(str(bit))
21
+
22
+ return "".join(out)
23
+
24
+
25
+ def multi_round_scramble(binary: str, rounds: int) -> str:
26
+ current = binary
27
+ for r in range(rounds):
28
+ current = scramble_once(current, r)
29
+ return current
30
+
31
+
32
+ def rotate_left(x: int, n: int) -> int:
33
+ return ((x << n) | (x >> (32 - n))) & 0xFFFFFFFF
34
+
35
+
36
+ def mix_chunk(chunk: str) -> int:
37
+ acc = 0
38
+ for i, ch in enumerate(chunk):
39
+ bit = 1 if ch == "1" else 0
40
+ acc ^= (bit << (i % 31))
41
+ acc = rotate_left(acc, (i % 5) + 1)
42
+ return acc & 0xFFFFFFFF
43
+
44
+
45
+ def chunk_and_mix(binary: str, block_size: int) -> list[int]:
46
+ blocks = []
47
+ for i in range(0, len(binary), block_size):
48
+ chunk = binary[i:i + block_size]
49
+ blocks.append(mix_chunk(chunk))
50
+ return blocks
51
+
52
+
53
+ def fold_blocks(blocks: list[int]) -> int:
54
+ state = 0x9E3779B9 # golden ratio constant
55
+
56
+ for i, v in enumerate(blocks):
57
+ state ^= v
58
+ state = (state + ((v << 5) - (v >> 3))) & 0xFFFFFFFF
59
+ rot = (i % 13) + 3
60
+ state = rotate_left(state, rot)
61
+ state ^= (state >> 11)
62
+
63
+ return state & 0xFFFFFFFF
64
+
65
+
66
+ def avalanche_mix(x: int) -> int:
67
+ x ^= x >> 15
68
+ x = (x * 0x85EBCA6B) & 0xFFFFFFFF
69
+ x ^= x >> 13
70
+ x = (x * 0xC2B2AE35) & 0xFFFFFFFF
71
+ x ^= x >> 16
72
+ return x & 0xFFFFFFFF
73
+
74
+
75
+ def alari_encode(text: str) -> str:
76
+ text = normalize_input(text)
77
+ binary = text_to_binary(text)
78
+ scrambled = multi_round_scramble(binary, 5)
79
+ blocks = chunk_and_mix(scrambled, 64)
80
+ state = fold_blocks(blocks)
81
+ final_int = avalanche_mix(state)
82
+ hex_value = format(final_int, "016x")
83
+ return f"alaricholt677.encoded${hex_value}"
@@ -0,0 +1,9 @@
1
+ Metadata-Version: 2.4
2
+ Name: alarihash
3
+ Version: 1.0.0
4
+ Summary: Python implementation of the AlariHash-X encoding pipeline
5
+ Home-page: https://github.com/alaricholt677/PKGS
6
+ Author: alaricholt677
7
+ Dynamic: author
8
+ Dynamic: home-page
9
+ Dynamic: summary
@@ -0,0 +1,7 @@
1
+ setup.py
2
+ alarihash/__init__.py
3
+ alarihash/encoder.py
4
+ alarihash.egg-info/PKG-INFO
5
+ alarihash.egg-info/SOURCES.txt
6
+ alarihash.egg-info/dependency_links.txt
7
+ alarihash.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ alarihash
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,10 @@
1
+ from setuptools import setup, find_packages
2
+
3
+ setup(
4
+ name="alarihash",
5
+ version="1.0.0",
6
+ packages=find_packages(),
7
+ description="Python implementation of the AlariHash-X encoding pipeline",
8
+ author="alaricholt677",
9
+ url="https://github.com/alaricholt677/PKGS",
10
+ )