Metadata-Version: 2.4
Name: shlhom
Version: 3.0.1
Summary: Protection library for Python tools with server validation and AES-GCM
Home-page: https://t.me/Fp_h9
Author: shlhom
Author-email: adojod1231@gmail.com
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Natural Language :: Arabic
Classifier: Intended Audience :: Developers
Classifier: Topic :: Security
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests>=2.25.0
Requires-Dist: pycryptodome>=3.10.0
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: license-file
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# shlhom

**Protection library for Python tools - with server-side time verification and AES-GCM encrypted cache.**

**مكتبة Python لحماية الأدوات - بتحقق زمني من السيرفر وتشفير AES-GCM للكاش.**

[![PyPI version](https://img.shields.io/pypi/v/shlhom)](https://pypi.org/project/shlhom/)
[![Python](https://img.shields.io/pypi/pyversions/shlhom)](https://pypi.org/project/shlhom/)
[![License](https://img.shields.io/pypi/l/shlhom)](https://pypi.org/project/shlhom/)

---

## Why shlhom?

You want to protect your Python tool with an expiry date - but users always find ways to bypass local checks:

- Changing the system clock
- Editing the source code
- Monkey-patching functions
- Copying the tool to another machine

shlhom solves this by sending a verification request to a remote server that you control.

---

## Features

| Feature | Description |
|---------|-------------|
| Server Verification | Every check sends a request to your server |
| Time Tamper Detection | Detects if the system clock is off by more than 5 minutes |
| AES-GCM Cache | Local encrypted cache (12h) bound to device |
| Anti-Tamper | Detects if shlhom.py is modified |
| Fallback Mode | Works offline using encrypted cache |
| Zero Config | No set_config, no API keys, no user input |

---

## Installation

    pip install shlhom

---

## Quick Start

Just one line at the top of your tool:

    import shlhom
    shlhom.check("2027-06-09")

    # your code here
    print("Tool is running")

That is it. No configuration, no keys.

---

## How It Works

1. When you call check(), shlhom runs local integrity checks
2. Sends a POST /check_device request to the server
3. Server compares your local time with real time:
   - Drift over 5 minutes: reject (tampering detected)
   - Date after expiry: reject (expired)
   - Otherwise: OK
4. If server is unreachable, shlhom falls back to encrypted cache (12 hours)

---

## API Reference

### check(expiry_date, exit_on_fail=True, show_info=True)

Main verification function.

    shlhom.check("2027-06-09")

Parameters:
- expiry_date (str): Date in YYYY-MM-DD format
- exit_on_fail (bool): Call sys.exit(1) on failure (default True)
- show_info (bool): Print status messages (default True)

### lock(expiry_date, **kwargs)

Alias for check().

    shlhom.lock("2027-06-09")

### get_device_id()

Returns a 32-character device fingerprint.

    device = shlhom.get_device_id()
    print(device)  # 5b4625d8d3bfbf4ea50ef92df9bd09be

### get_real_time()

Returns the real timestamp from a public time source.

    ts = shlhom.get_real_time()
    print(ts)  # 1790182086.0

### verify_server(expiry_date)

Directly contacts the server (bypasses local checks).

    result = shlhom.verify_server("2027-06-09")
    print(result)

---

## Use Cases

### 1. Tool with Expiry Date

    import shlhom
    shlhom.check("2027-06-09")
    # your tool

### 2. Silent Check

    import shlhom
    shlhom.check("2027-06-09", show_info=False)

### 3. Graceful Failure

    import shlhom
    if shlhom.check("2027-06-09", exit_on_fail=False):
        print("Access granted")
    else:
        print("Access denied")

---

## Security

| Attack | Protection |
|--------|-----------|
| Changing system clock | Server detects drift over 5 min |
| Editing shlhom.py | Anti-Tamper detects modification |
| Copying cache to another device | Cache is bound to device fingerprint |
| Monkey-patching functions | Integrity check on every call |
| Modifying cache | AES-GCM authentication fails |
| Brute-forcing cache | AES-256 - infeasible |

---

## Requirements

- Python 3.7 or higher
- requests 2.25.0 or higher
- pycryptodome 3.10.0 or higher

---

## License

MIT (c) shlhom

---

## Support

- Telegram: @Fp_h9
- Email: adojod1231@gmail.com

---

Made with care for developers who want to protect their work.
