xaor 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.
xaor/__init__.py ADDED
@@ -0,0 +1,3 @@
1
+ from .xaor import hash_password, verify_password
2
+
3
+ __all__ = ["hash_password", "verify_password"]
xaor/xaor.dll ADDED
Binary file
xaor/xaor.py ADDED
@@ -0,0 +1,82 @@
1
+ import ctypes
2
+ import os
3
+ import sys
4
+
5
+ # Locate the dynamic library packaged inside the module directory
6
+ lib_dir = os.path.dirname(os.path.abspath(__file__))
7
+
8
+ if sys.platform == "win32":
9
+ lib_name = "xaor.dll"
10
+ elif sys.platform == "darwin":
11
+ lib_name = "libxaor.dylib"
12
+ else:
13
+ lib_name = "libxaor.so"
14
+
15
+ lib_path = os.path.join(lib_dir, lib_name)
16
+
17
+ # If the DLL isn't packaged in the package directory (e.g. during local dev),
18
+ # fallback to target/release or target/debug
19
+ if not os.path.exists(lib_path):
20
+ root_dir = os.path.abspath(os.path.join(lib_dir, "../../"))
21
+ release_path = os.path.join(root_dir, "target", "release", lib_name)
22
+ debug_path = os.path.join(root_dir, "target", "debug", lib_name)
23
+ if os.path.exists(release_path):
24
+ lib_path = release_path
25
+ elif os.path.exists(debug_path):
26
+ lib_path = debug_path
27
+ else:
28
+ raise FileNotFoundError(
29
+ f"Could not locate the compiled xaor dynamic library ({lib_name}). "
30
+ "Ensure you run 'cargo build --release' to compile it."
31
+ )
32
+
33
+ try:
34
+ lib = ctypes.CDLL(lib_path)
35
+ except Exception as e:
36
+ raise ImportError(f"Failed to load shared library '{lib_path}': {e}")
37
+
38
+ # Configure FFI types
39
+ lib.xaor_hash.argtypes = [ctypes.c_char_p]
40
+ lib.xaor_hash.restype = ctypes.c_void_p # Raw pointer to free manually
41
+
42
+ lib.xaor_verify.argtypes = [ctypes.c_char_p, ctypes.c_char_p]
43
+ lib.xaor_verify.restype = ctypes.c_int32
44
+
45
+ lib.xaor_free_string.argtypes = [ctypes.c_void_p]
46
+ lib.xaor_free_string.restype = None
47
+
48
+ lib.xaor_last_error.argtypes = []
49
+ lib.xaor_last_error.restype = ctypes.c_void_p
50
+
51
+ def hash_password(password: str) -> str:
52
+ """Hash a password using Xaor's memory-hard pipeline."""
53
+ if not isinstance(password, str):
54
+ raise TypeError("Password must be a string")
55
+
56
+ ptr = lib.xaor_hash(password.encode('utf-8'))
57
+ if not ptr:
58
+ err_ptr = lib.xaor_last_error()
59
+ err = "Unknown cryptographic error"
60
+ if err_ptr:
61
+ err = ctypes.cast(err_ptr, ctypes.c_char_p).value.decode('utf-8')
62
+ lib.xaor_free_string(err_ptr)
63
+ raise ValueError(f"Hashing failed: {err}")
64
+
65
+ hash_str = ctypes.cast(ptr, ctypes.c_char_p).value.decode('utf-8')
66
+ lib.xaor_free_string(ptr)
67
+ return hash_str
68
+
69
+ def verify_password(password: str, hash_str: str) -> bool:
70
+ """Verify a password against a stored Xaor hash string."""
71
+ if not isinstance(password, str) or not isinstance(hash_str, str):
72
+ raise TypeError("Password and hash must be strings")
73
+
74
+ res = lib.xaor_verify(password.encode('utf-8'), hash_str.encode('utf-8'))
75
+ if res == -1:
76
+ err_ptr = lib.xaor_last_error()
77
+ err = "Unknown verification error"
78
+ if err_ptr:
79
+ err = ctypes.cast(err_ptr, ctypes.c_char_p).value.decode('utf-8')
80
+ lib.xaor_free_string(err_ptr)
81
+ raise ValueError(f"Verification failed: {err}")
82
+ return res == 1
@@ -0,0 +1,34 @@
1
+ Metadata-Version: 2.4
2
+ Name: xaor
3
+ Version: 0.2.0
4
+ Summary: Adaptive regenerative cryptographic engine — memory-hard, chaos-keyed, GPU/ASIC-resistant
5
+ Author: Surya
6
+ Classifier: Programming Language :: Python :: 3
7
+ Classifier: License :: OSI Approved :: MIT License
8
+ Classifier: Operating System :: OS Independent
9
+ Requires-Python: >=3.7
10
+ Description-Content-Type: text/markdown
11
+
12
+ # Xaor Python Package
13
+
14
+ Python bindings for the **Xaor Cryptographic Engine** — an adaptive, memory-hard, chaos-keyed password hashing algorithm.
15
+
16
+ ## Installation
17
+
18
+ ```bash
19
+ pip install xaor
20
+ ```
21
+
22
+ ## Quick Start
23
+
24
+ ```python
25
+ from xaor import hash_password, verify_password
26
+
27
+ # 1. Hash a password
28
+ hashed = hash_password("my-secure-password")
29
+ print("Hash:", hashed)
30
+
31
+ # 2. Verify a password
32
+ is_valid = verify_password("my-secure-password", hashed)
33
+ print("Is valid:", is_valid) # True
34
+ ```
@@ -0,0 +1,7 @@
1
+ xaor/__init__.py,sha256=-fWESoHBKVDmsJMUcg3fOXkUjzSs0l4npW7upN0II7w,97
2
+ xaor/xaor.dll,sha256=lbOT5sYZqyDN7rAqgHhtkHCaxYMJLByG9K2qYuuHNHs,366592
3
+ xaor/xaor.py,sha256=Abn1LdhjAE-gDqGYVifmtuZm7dWjFV8MpqfxJSmKrSE,2925
4
+ xaor-0.2.0.dist-info/METADATA,sha256=rPqRfrmjicI3s4IKhbM80DjX8g8HG4c0APpYaDezc7I,888
5
+ xaor-0.2.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
6
+ xaor-0.2.0.dist-info/top_level.txt,sha256=YN1EWPJdIAxUSul-r7rvIz5ehIpF2nuVSRzrT3f2xg0,5
7
+ xaor-0.2.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ xaor