Metadata-Version: 2.4
Name: daniel_sources
Version: 1.2.0
Summary: Reusable Python utilities for hashing, encryption, Stripe Checkout, documents, and quiz projects
Author: Daniel
Keywords: utilities,hashing,stripe,quizzes,pdf,environment
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: cryptography>=42.0
Requires-Dist: Werkzeug>=3.0
Requires-Dist: PyJWT>=2.9
Requires-Dist: requests>=2.31
Requires-Dist: stripe>=12.0
Requires-Dist: pypdf>=5.0
Requires-Dist: python-docx>=1.1
Requires-Dist: python-dotenv>=1.0

# daniel_sources — pip-installable Python utility library

**Python 3.10 or newer** · **Version 1.2.0** · import as `import daniel_sources as ds`

This is a reusable standalone module adapted from your KleeQuiz production + developer source code. It includes hashing/password helpers, JWTs, encryption, random codes, email, Stripe Checkout/webhook utilities, PDFs and DOCX, quizzes, SQLite API-key/credits helpers, and the Developer API client.

## Install from the ZIP (works now, even before PyPI publishing)

1. Extract the ZIP. Open a terminal in the extracted folder containing `pyproject.toml`.
2. Install it in your active Python environment:

```powershell
python -m pip install .
```

**Windows virtual environment (no activation required):**

```powershell
py -m venv .venv
.\.venv\Scripts\python.exe -m pip install .
.\.venv\Scripts\python.exe -c "import daniel_sources as ds; print(ds.hash('SHA256', 'hello'))"
```

This automatically installs all eight declared third-party dependencies, *into the selected Python environment*: `cryptography`, `Werkzeug`, `PyJWT`, `requests`, `stripe`, `pypdf`, `python-docx`, and `python-dotenv`. Dependencies may require an internet connection if pip hasn't cached them. You do **not** need to install a separate requirements file.

**If you have the wheel instead** (from the included `dist` folder):

```powershell
python -m pip install .\dist\daniel_sources-1.2.0-py3-none-any.whl
```

## Code examples

```python
import daniel_sources as ds

print(ds.hash("SHA256", "hello"))
code = ds.generate_code()
key = ds.generate_encryption_key()
print(ds.decrypt(ds.encrypt("hello", key), key))
```

## Virtual environments and `.env` files

Make a `.env` file beside your project (not inside the installed library):

```dotenv
STRIPE_SECRET_KEY=sk_test_your_own_key_here
STRIPE_WEBHOOK_SECRET=whsec_your_own_signing_secret_here
```

`import daniel_sources` automatically loads the `.env` file in your **current working directory**, without overwriting existing environment variables. It does not look inside other projects or search parent folders. This is separate from the Python virtual environment `.venv` folder.

```python
import os
import daniel_sources as ds  # loads .env in your project folder, if present

print("Stripe configured?", bool(os.getenv("STRIPE_SECRET_KEY")))
print(ds.hash("SHA256", "hello"))
```

If you keep configuration in a nonstandard file or need to reload it after import, use `ds.load_env("config/dev.env")`. Use `ds.load_env(".env", override=True)` only when you intentionally want the file to replace process variables.

To turn import-time loading **off**, set `DANIEL_SOURCES_AUTO_DOTENV=0` *before importing* the library (e.g. in your Windows terminal: `$env:DANIEL_SOURCES_AUTO_DOTENV="0"`). No network access or payment occurs on import. **Never commit real secrets to GitHub.**

## Use `pip install daniel_sources` from anywhere

The exact command `pip install daniel_sources` works **only after** the package name has been claimed and this distribution has been uploaded to the public Python Package Index (PyPI), or an equivalent configured private index. This ZIP is **not yet published**. The included wheel and source distribution are ready to publish.

To publish on PyPI yourself:

1. Create a PyPI account at https://pypi.org/ and configure authentication (use a protected PyPI token or trusted publishing).
2. Review the module, license/ownership and documentation: publishing makes the **source public**.
3. From this folder, install packaging tools and build (the prebuilt archives in `dist/` can be used instead):

   ```powershell
   python -m pip install --upgrade build twine
   python -m build
   python -m twine check dist/*
   python -m twine upload dist/*
   ```

4. Once your package is live on PyPI, in any new project / virtualenv:

   ```powershell
   python -m pip install daniel_sources
   ```

After every source update, increment the version in `pyproject.toml` and `__version__` before publishing again, then users can upgrade with `python -m pip install --upgrade daniel_sources`.

If the name is already reserved when you publish, choose a distinct PyPI distribution name (e.g., `daniel-sources-kleequiz`); the *import* can still be `import daniel_sources as ds`.

## Install/edit your local package while developing

```powershell
python -m pip install -e .
python test_daniel_sources.py
```

Editable installs let you change `daniel_sources.py` and immediately use its changes in the same virtualenv. Publishing is not needed to develop locally.

## Security and limits

- Hashing with SHA256 is **not** password storage; use `ds.password_hash` and `ds.password_verify` for passwords.
- Stripe helpers require real Stripe credentials and a server-side integration; webhook signatures must be verified before crediting purchases.
- These helpers do not automatically handle web routes, model weights, Google OAuth, or live production deployment.
- This distribution contains no real API tokens, private `.env` files, production database or user records.
- Publishing the package publicly is your decision: inspect all code for any information you don't want publicly available and decide on your license before upload.

Also see `FUNCTION_INDEX.md`, `SOURCES.md`, and `docs/ORIGINAL_LIBRARY_GUIDE.md`.
