pathl 2.2.0__tar.gz → 2.2.2__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.
Files changed (27) hide show
  1. {pathl-2.2.0 → pathl-2.2.2}/PKG-INFO +1 -1
  2. {pathl-2.2.0 → pathl-2.2.2}/pathl/cli.py +17 -0
  3. pathl-2.2.2/pathl/hash/__init__.py +11 -0
  4. pathl-2.2.2/pathl/hash/sha256.c +220 -0
  5. {pathl-2.2.0 → pathl-2.2.2}/pathl/hello/world.py +5 -0
  6. {pathl-2.2.0 → pathl-2.2.2}/pathl.egg-info/PKG-INFO +1 -1
  7. {pathl-2.2.0 → pathl-2.2.2}/pathl.egg-info/SOURCES.txt +2 -0
  8. {pathl-2.2.0 → pathl-2.2.2}/pyproject.toml +1 -1
  9. {pathl-2.2.0 → pathl-2.2.2}/setup.py +5 -1
  10. {pathl-2.2.0 → pathl-2.2.2}/README.md +0 -0
  11. {pathl-2.2.0 → pathl-2.2.2}/pathl/__init__.py +0 -0
  12. {pathl-2.2.0 → pathl-2.2.2}/pathl/crypto/__init__.py +0 -0
  13. {pathl-2.2.0 → pathl-2.2.2}/pathl/crypto/aes.py +0 -0
  14. {pathl-2.2.0 → pathl-2.2.2}/pathl/crypto/rsa.py +0 -0
  15. {pathl-2.2.0 → pathl-2.2.2}/pathl/crypto/utils.py +0 -0
  16. {pathl-2.2.0 → pathl-2.2.2}/pathl/dns/dns.py +0 -0
  17. {pathl-2.2.0 → pathl-2.2.2}/pathl/hello/__init__.py +0 -0
  18. {pathl-2.2.0 → pathl-2.2.2}/pathl/hello/welcome.py +0 -0
  19. {pathl-2.2.0 → pathl-2.2.2}/pathl/math/__init__.py +0 -0
  20. {pathl-2.2.0 → pathl-2.2.2}/pathl/math/math.c +0 -0
  21. {pathl-2.2.0 → pathl-2.2.2}/pathl/scaner/fastscan.c +0 -0
  22. {pathl-2.2.0 → pathl-2.2.2}/pathl/scaner/scaner.py +0 -0
  23. {pathl-2.2.0 → pathl-2.2.2}/pathl.egg-info/dependency_links.txt +0 -0
  24. {pathl-2.2.0 → pathl-2.2.2}/pathl.egg-info/entry_points.txt +0 -0
  25. {pathl-2.2.0 → pathl-2.2.2}/pathl.egg-info/requires.txt +0 -0
  26. {pathl-2.2.0 → pathl-2.2.2}/pathl.egg-info/top_level.txt +0 -0
  27. {pathl-2.2.0 → pathl-2.2.2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pathl
3
- Version: 2.2.0
3
+ Version: 2.2.2
4
4
  Summary: General-purpose cybersecurity toolkit
5
5
  Author: Alicja
6
6
  License-Expression: MIT
@@ -51,6 +51,18 @@ def cmd_fastscan(args):
51
51
  print(f"[*] Saved to {args.output}")
52
52
 
53
53
 
54
+ def cmd_sha256(args):
55
+ import sys
56
+ try:
57
+ from pathl.hash import sha256
58
+ except ImportError:
59
+ print("Error: sha256 C extension is not compiled. Run 'make build-c' first.")
60
+ sys.exit(1)
61
+
62
+ result = sha256.hash(args.text)
63
+ print(result)
64
+
65
+
54
66
  def main():
55
67
  parser = argparse.ArgumentParser(
56
68
  prog="pathl",
@@ -96,6 +108,11 @@ def main():
96
108
  parser_fastscan.add_argument("--output")
97
109
  parser_fastscan.set_defaults(func=cmd_fastscan)
98
110
 
111
+ # SHA256
112
+ parser_sha256 = subparsers.add_parser("sha256", help="Haszuj tekst algorytmem SHA-256")
113
+ parser_sha256.add_argument("text", help="Tekst do zahaszowania")
114
+ parser_sha256.set_defaults(func=cmd_sha256)
115
+
99
116
 
100
117
  args = parser.parse_args()
101
118
 
@@ -0,0 +1,11 @@
1
+ """
2
+ pathl.hash — moduły haszujące napisane w C
3
+
4
+ Użycie:
5
+ from pathl.hash import sha256
6
+ print(sha256.hash("hello"))
7
+ # => 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824
8
+
9
+ print(sha256.hash_bytes(b"hello"))
10
+ # => 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824
11
+ """
@@ -0,0 +1,220 @@
1
+ /*
2
+ * pathl.hash.sha256 — SHA-256 w czystym C (bez OpenSSL)
3
+ * Użycie z Pythona:
4
+ * from pathl.hash import sha256
5
+ * print(sha256.hash("hello"))
6
+ */
7
+
8
+ #define PY_SSIZE_T_CLEAN
9
+ #include <Python.h>
10
+ #include <stdint.h>
11
+ #include <string.h>
12
+
13
+ /* ── SHA-256 stałe ───────────────────────────────────────────────────── */
14
+ static const uint32_t K[64] = {
15
+ 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
16
+ 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
17
+ 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
18
+ 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
19
+ 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
20
+ 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
21
+ 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
22
+ 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
23
+ 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
24
+ 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
25
+ 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
26
+ 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
27
+ 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
28
+ 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
29
+ 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
30
+ 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
31
+ };
32
+
33
+ /* ── makra ────────────────────────────────────────────────────────────── */
34
+ #define ROTR(x, n) (((x) >> (n)) | ((x) << (32 - (n))))
35
+ #define CH(x, y, z) (((x) & (y)) ^ (~(x) & (z)))
36
+ #define MAJ(x, y, z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z)))
37
+ #define EP0(x) (ROTR(x,2) ^ ROTR(x,13) ^ ROTR(x,22))
38
+ #define EP1(x) (ROTR(x,6) ^ ROTR(x,11) ^ ROTR(x,25))
39
+ #define SIG0(x) (ROTR(x,7) ^ ROTR(x,18) ^ ((x) >> 3))
40
+ #define SIG1(x) (ROTR(x,17) ^ ROTR(x,19) ^ ((x) >> 10))
41
+
42
+ typedef struct {
43
+ uint8_t data[64];
44
+ uint32_t datalen;
45
+ uint64_t bitlen;
46
+ uint32_t state[8];
47
+ } SHA256_CTX;
48
+
49
+ static void sha256_transform(SHA256_CTX *ctx, const uint8_t *data)
50
+ {
51
+ uint32_t a, b, c, d, e, f, g, h, i, j, t1, t2, m[64];
52
+
53
+ for (i = 0, j = 0; i < 16; i++, j += 4)
54
+ m[i] = ((uint32_t)data[j] << 24) |
55
+ ((uint32_t)data[j + 1] << 16) |
56
+ ((uint32_t)data[j + 2] << 8) |
57
+ ((uint32_t)data[j + 3]);
58
+ for (; i < 64; i++)
59
+ m[i] = SIG1(m[i - 2]) + m[i - 7] + SIG0(m[i - 15]) + m[i - 16];
60
+
61
+ a = ctx->state[0]; b = ctx->state[1];
62
+ c = ctx->state[2]; d = ctx->state[3];
63
+ e = ctx->state[4]; f = ctx->state[5];
64
+ g = ctx->state[6]; h = ctx->state[7];
65
+
66
+ for (i = 0; i < 64; i++) {
67
+ t1 = h + EP1(e) + CH(e, f, g) + K[i] + m[i];
68
+ t2 = EP0(a) + MAJ(a, b, c);
69
+ h = g; g = f; f = e; e = d + t1;
70
+ d = c; c = b; b = a; a = t1 + t2;
71
+ }
72
+
73
+ ctx->state[0] += a; ctx->state[1] += b;
74
+ ctx->state[2] += c; ctx->state[3] += d;
75
+ ctx->state[4] += e; ctx->state[5] += f;
76
+ ctx->state[6] += g; ctx->state[7] += h;
77
+ }
78
+
79
+ static void sha256_init(SHA256_CTX *ctx)
80
+ {
81
+ ctx->datalen = 0;
82
+ ctx->bitlen = 0;
83
+ ctx->state[0] = 0x6a09e667;
84
+ ctx->state[1] = 0xbb67ae85;
85
+ ctx->state[2] = 0x3c6ef372;
86
+ ctx->state[3] = 0xa54ff53a;
87
+ ctx->state[4] = 0x510e527f;
88
+ ctx->state[5] = 0x9b05688c;
89
+ ctx->state[6] = 0x1f83d9ab;
90
+ ctx->state[7] = 0x5be0cd19;
91
+ }
92
+
93
+ static void sha256_update(SHA256_CTX *ctx, const uint8_t *data, size_t len)
94
+ {
95
+ for (size_t i = 0; i < len; i++) {
96
+ ctx->data[ctx->datalen++] = data[i];
97
+ if (ctx->datalen == 64) {
98
+ sha256_transform(ctx, ctx->data);
99
+ ctx->bitlen += 512;
100
+ ctx->datalen = 0;
101
+ }
102
+ }
103
+ }
104
+
105
+ static void sha256_final(SHA256_CTX *ctx, uint8_t *hash)
106
+ {
107
+ uint32_t i = ctx->datalen;
108
+
109
+ if (ctx->datalen < 56) {
110
+ ctx->data[i++] = 0x80;
111
+ while (i < 56) ctx->data[i++] = 0x00;
112
+ } else {
113
+ ctx->data[i++] = 0x80;
114
+ while (i < 64) ctx->data[i++] = 0x00;
115
+ sha256_transform(ctx, ctx->data);
116
+ memset(ctx->data, 0, 56);
117
+ }
118
+
119
+ ctx->bitlen += (uint64_t)ctx->datalen * 8;
120
+ ctx->data[63] = (uint8_t)(ctx->bitlen);
121
+ ctx->data[62] = (uint8_t)(ctx->bitlen >> 8);
122
+ ctx->data[61] = (uint8_t)(ctx->bitlen >> 16);
123
+ ctx->data[60] = (uint8_t)(ctx->bitlen >> 24);
124
+ ctx->data[59] = (uint8_t)(ctx->bitlen >> 32);
125
+ ctx->data[58] = (uint8_t)(ctx->bitlen >> 40);
126
+ ctx->data[57] = (uint8_t)(ctx->bitlen >> 48);
127
+ ctx->data[56] = (uint8_t)(ctx->bitlen >> 56);
128
+ sha256_transform(ctx, ctx->data);
129
+
130
+ for (i = 0; i < 4; i++) {
131
+ hash[i] = (ctx->state[0] >> (24 - i * 8)) & 0xff;
132
+ hash[i + 4] = (ctx->state[1] >> (24 - i * 8)) & 0xff;
133
+ hash[i + 8] = (ctx->state[2] >> (24 - i * 8)) & 0xff;
134
+ hash[i + 12] = (ctx->state[3] >> (24 - i * 8)) & 0xff;
135
+ hash[i + 16] = (ctx->state[4] >> (24 - i * 8)) & 0xff;
136
+ hash[i + 20] = (ctx->state[5] >> (24 - i * 8)) & 0xff;
137
+ hash[i + 24] = (ctx->state[6] >> (24 - i * 8)) & 0xff;
138
+ hash[i + 28] = (ctx->state[7] >> (24 - i * 8)) & 0xff;
139
+ }
140
+ }
141
+
142
+ /* ── Python API ───────────────────────────────────────────────────────── */
143
+
144
+ /*
145
+ * sha256.hash(text: str) -> str
146
+ * Zwraca hex-digest SHA-256 dla podanego tekstu (UTF-8).
147
+ */
148
+ static PyObject *py_sha256_hash(PyObject *self, PyObject *args)
149
+ {
150
+ const char *input;
151
+ Py_ssize_t input_len;
152
+
153
+ if (!PyArg_ParseTuple(args, "s#", &input, &input_len))
154
+ return NULL;
155
+
156
+ SHA256_CTX ctx;
157
+ uint8_t digest[32];
158
+ char hexbuf[65];
159
+
160
+ Py_BEGIN_ALLOW_THREADS
161
+ sha256_init(&ctx);
162
+ sha256_update(&ctx, (const uint8_t *)input, (size_t)input_len);
163
+ sha256_final(&ctx, digest);
164
+ for (int i = 0; i < 32; i++)
165
+ snprintf(hexbuf + i * 2, 3, "%02x", digest[i]);
166
+ hexbuf[64] = '\0';
167
+ Py_END_ALLOW_THREADS
168
+
169
+ return PyUnicode_FromString(hexbuf);
170
+ }
171
+
172
+ /*
173
+ * sha256.hash_bytes(data: bytes) -> str
174
+ * Zwraca hex-digest SHA-256 dla surowych bajtów.
175
+ */
176
+ static PyObject *py_sha256_hash_bytes(PyObject *self, PyObject *args)
177
+ {
178
+ const uint8_t *input;
179
+ Py_ssize_t input_len;
180
+
181
+ if (!PyArg_ParseTuple(args, "y#", &input, &input_len))
182
+ return NULL;
183
+
184
+ SHA256_CTX ctx;
185
+ uint8_t digest[32];
186
+ char hexbuf[65];
187
+
188
+ Py_BEGIN_ALLOW_THREADS
189
+ sha256_init(&ctx);
190
+ sha256_update(&ctx, input, (size_t)input_len);
191
+ sha256_final(&ctx, digest);
192
+ for (int i = 0; i < 32; i++)
193
+ snprintf(hexbuf + i * 2, 3, "%02x", digest[i]);
194
+ hexbuf[64] = '\0';
195
+ Py_END_ALLOW_THREADS
196
+
197
+ return PyUnicode_FromString(hexbuf);
198
+ }
199
+
200
+ /* ── Tabela metod ─────────────────────────────────────────────────────── */
201
+ static PyMethodDef Sha256Methods[] = {
202
+ {"hash", py_sha256_hash, METH_VARARGS,
203
+ "hash(text: str) -> str\n\nZwraca hex SHA-256 dla tekstu UTF-8."},
204
+ {"hash_bytes", py_sha256_hash_bytes, METH_VARARGS,
205
+ "hash_bytes(data: bytes) -> str\n\nZwraca hex SHA-256 dla surowych bajtów."},
206
+ {NULL, NULL, 0, NULL}
207
+ };
208
+
209
+ static struct PyModuleDef sha256module = {
210
+ PyModuleDef_HEAD_INIT,
211
+ "sha256",
212
+ "Moduł SHA-256 napisany w czystym C (bez OpenSSL).",
213
+ -1,
214
+ Sha256Methods
215
+ };
216
+
217
+ PyMODINIT_FUNC PyInit_sha256(void)
218
+ {
219
+ return PyModule_Create(&sha256module);
220
+ }
@@ -3,3 +3,8 @@ class World:
3
3
  self.msg = "Hello Its My Packeg"
4
4
  def main(self):
5
5
  print(self.msg)
6
+ def versin(self):
7
+
8
+ print("2.9.9")
9
+ def another(self):
10
+ print("twoja matka")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pathl
3
- Version: 2.2.0
3
+ Version: 2.2.2
4
4
  Summary: General-purpose cybersecurity toolkit
5
5
  Author: Alicja
6
6
  License-Expression: MIT
@@ -14,6 +14,8 @@ pathl/crypto/aes.py
14
14
  pathl/crypto/rsa.py
15
15
  pathl/crypto/utils.py
16
16
  pathl/dns/dns.py
17
+ pathl/hash/__init__.py
18
+ pathl/hash/sha256.c
17
19
  pathl/hello/__init__.py
18
20
  pathl/hello/welcome.py
19
21
  pathl/hello/world.py
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "pathl"
7
- version = "2.2.0"
7
+ version = "2.2.2"
8
8
  description = "General-purpose cybersecurity toolkit"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.8"
@@ -9,6 +9,10 @@ setup(
9
9
  Extension(
10
10
  name="pathl.math.math",
11
11
  sources=["pathl/math/math.c"]
12
- )
12
+ ),
13
+ Extension(
14
+ name="pathl.hash.sha256",
15
+ sources=["pathl/hash/sha256.c"]
16
+ ),
13
17
  ]
14
18
  )
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