homegrowndhe


Namehomegrowndhe JSON
Version 0.3.3 PyPI version JSON
download
home_pageNone
SummaryNone
upload_time2024-07-26 07:49:29
maintainerNone
docs_urlNone
authorDJ Stomp
requires_python<4.0,>=3.10
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # HomegrownDHE

HomegrownDHE is a Python package that provides an implementation of the Diffie-Hellman key exchange algorithm. It is designed for educational purposes and demonstrates how two participants can securely exchange cryptographic keys over an insecure channel.

[![Tests (Conda)](https://github.com/DJStompZone/HomeGrownDHE/actions/workflows/test-conda.yml/badge.svg)](https://github.com/DJStompZone/HomeGrownDHE/actions/workflows/test-conda.yml) [![CodeQL](https://github.com/DJStompZone/HomeGrownDHE/actions/workflows/codeql.yml/badge.svg)](https://github.com/DJStompZone/HomeGrownDHE/actions/workflows/codeql.yml)
## Installation

To install the package from PyPI, use the following command:

```sh
pip install homegrowndhe
```

## Usage

The package provides a main script to demonstrate the Diffie-Hellman key exchange, as well as utility functions for testing and debugging.

### Running the Main Script

To run the main script, simply execute the `__main__.py` file:

```sh
python -m homegrowndhe
```

This will perform a Diffie-Hellman key exchange between two participants and print the results to the console.

### Development Mode

To enable development mode, set the `DEV_TEST` environment variable to `True`. This will enable additional debug output and run the end-to-end tests:

```sh
export DEV_TEST=True
python -m homegrowndhe
```

### Detailed Usage

Here is a detailed breakdown of the available functions and their usage:

#### `main(test_iters=0) -> int`

The main function to demonstrate the Diffie-Hellman key exchange between two participants.

- `test_iters`: Number of test iterations to run. Defaults to `TEST_ITERATIONS`.
- Returns an integer exit code. A non-zero exit code indicates an error.

#### `test_end_to_end(iterations=1)`

Function to perform end-to-end tests of the Diffie-Hellman key exchange.

- `iterations`: Number of test iterations to run. Defaults to 1.

### Utility Functions

The package includes several utility functions for terminal output and numeric operations:

- `twidth()`: Returns the terminal width.
- `cprint(*args, padding=3, **kwargs)`: Centered print with padding.
- `blockprint(txt)`: Block print with centered text.
- `p_print(*args, **kwargs)`: Pretty print for development mode.
- `get_digits(s: str) -> str`: Extracts digits from a string.
- `is_long_num(_s: str, min_d: int = 100) -> bool`: Checks if a string contains a long numeric value.
- `get_long_numerics(s: str, min_d: int = 100) -> List[str]`: Extracts long numeric values from a string.

### Diffie-Hellman Key Exchange Classes

#### `DiffieHellmanParticipant`

A class representing a participant in the Diffie-Hellman key exchange.

- `__init__(self, parameters: DSA.DsaKey)`: Initializes a participant with given DSA parameters.
- `compute_shared_key(self, other_public_key: int) -> int`: Computes the shared key using the other participant's public key.

#### `generate_large_prime_parameters(bits: int = 2048) -> DSA.DsaKey`

Generates large prime parameters for the Diffie-Hellman key exchange.

- `bits`: The number of bits for the prime number. Defaults to 2048.

### Testing

To run the tests, use the following command:

```sh
pytest
```

This will execute the tests defined in the `test_homegrowndhe.py` file.

## License

This project is licensed under the MIT License.
```

Feel free to modify the README to suit your specific needs or add more sections if necessary.
            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "homegrowndhe",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.10",
    "maintainer_email": null,
    "keywords": null,
    "author": "DJ Stomp",
    "author_email": "noreply@85457381+djstompzone@users.noreply.github.com",
    "download_url": "https://files.pythonhosted.org/packages/e8/34/e8a072d6d0c484f42e54fd1fecdf5f1438ab026e8e3c0403d1c311297823/homegrowndhe-0.3.3.tar.gz",
    "platform": null,
    "description": "# HomegrownDHE\n\nHomegrownDHE is a Python package that provides an implementation of the Diffie-Hellman key exchange algorithm. It is designed for educational purposes and demonstrates how two participants can securely exchange cryptographic keys over an insecure channel.\n\n[![Tests (Conda)](https://github.com/DJStompZone/HomeGrownDHE/actions/workflows/test-conda.yml/badge.svg)](https://github.com/DJStompZone/HomeGrownDHE/actions/workflows/test-conda.yml) [![CodeQL](https://github.com/DJStompZone/HomeGrownDHE/actions/workflows/codeql.yml/badge.svg)](https://github.com/DJStompZone/HomeGrownDHE/actions/workflows/codeql.yml)\n## Installation\n\nTo install the package from PyPI, use the following command:\n\n```sh\npip install homegrowndhe\n```\n\n## Usage\n\nThe package provides a main script to demonstrate the Diffie-Hellman key exchange, as well as utility functions for testing and debugging.\n\n### Running the Main Script\n\nTo run the main script, simply execute the `__main__.py` file:\n\n```sh\npython -m homegrowndhe\n```\n\nThis will perform a Diffie-Hellman key exchange between two participants and print the results to the console.\n\n### Development Mode\n\nTo enable development mode, set the `DEV_TEST` environment variable to `True`. This will enable additional debug output and run the end-to-end tests:\n\n```sh\nexport DEV_TEST=True\npython -m homegrowndhe\n```\n\n### Detailed Usage\n\nHere is a detailed breakdown of the available functions and their usage:\n\n#### `main(test_iters=0) -> int`\n\nThe main function to demonstrate the Diffie-Hellman key exchange between two participants.\n\n- `test_iters`: Number of test iterations to run. Defaults to `TEST_ITERATIONS`.\n- Returns an integer exit code. A non-zero exit code indicates an error.\n\n#### `test_end_to_end(iterations=1)`\n\nFunction to perform end-to-end tests of the Diffie-Hellman key exchange.\n\n- `iterations`: Number of test iterations to run. Defaults to 1.\n\n### Utility Functions\n\nThe package includes several utility functions for terminal output and numeric operations:\n\n- `twidth()`: Returns the terminal width.\n- `cprint(*args, padding=3, **kwargs)`: Centered print with padding.\n- `blockprint(txt)`: Block print with centered text.\n- `p_print(*args, **kwargs)`: Pretty print for development mode.\n- `get_digits(s: str) -> str`: Extracts digits from a string.\n- `is_long_num(_s: str, min_d: int = 100) -> bool`: Checks if a string contains a long numeric value.\n- `get_long_numerics(s: str, min_d: int = 100) -> List[str]`: Extracts long numeric values from a string.\n\n### Diffie-Hellman Key Exchange Classes\n\n#### `DiffieHellmanParticipant`\n\nA class representing a participant in the Diffie-Hellman key exchange.\n\n- `__init__(self, parameters: DSA.DsaKey)`: Initializes a participant with given DSA parameters.\n- `compute_shared_key(self, other_public_key: int) -> int`: Computes the shared key using the other participant's public key.\n\n#### `generate_large_prime_parameters(bits: int = 2048) -> DSA.DsaKey`\n\nGenerates large prime parameters for the Diffie-Hellman key exchange.\n\n- `bits`: The number of bits for the prime number. Defaults to 2048.\n\n### Testing\n\nTo run the tests, use the following command:\n\n```sh\npytest\n```\n\nThis will execute the tests defined in the `test_homegrowndhe.py` file.\n\n## License\n\nThis project is licensed under the MIT License.\n```\n\nFeel free to modify the README to suit your specific needs or add more sections if necessary.",
    "bugtrack_url": null,
    "license": null,
    "summary": null,
    "version": "0.3.3",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "89f64210a1e6ed948e483685ecd9c3d20b667f8d8edb4473be6c6fe36bac828c",
                "md5": "e3f5f7f937b29810570caad4416d2241",
                "sha256": "f9b0c21a5b83f90a105fc82badba5e16e8043290fb72b7a299397d3cb3ff690a"
            },
            "downloads": -1,
            "filename": "homegrowndhe-0.3.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e3f5f7f937b29810570caad4416d2241",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.10",
            "size": 5718,
            "upload_time": "2024-07-26T07:49:28",
            "upload_time_iso_8601": "2024-07-26T07:49:28.434640Z",
            "url": "https://files.pythonhosted.org/packages/89/f6/4210a1e6ed948e483685ecd9c3d20b667f8d8edb4473be6c6fe36bac828c/homegrowndhe-0.3.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e834e8a072d6d0c484f42e54fd1fecdf5f1438ab026e8e3c0403d1c311297823",
                "md5": "939621aa31a235ac72eb82fbd05ec10e",
                "sha256": "c5bae9f0926d35109cf35adf086661b9ea516d855ae44ab1f4d19ff3fe242810"
            },
            "downloads": -1,
            "filename": "homegrowndhe-0.3.3.tar.gz",
            "has_sig": false,
            "md5_digest": "939621aa31a235ac72eb82fbd05ec10e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.10",
            "size": 4594,
            "upload_time": "2024-07-26T07:49:29",
            "upload_time_iso_8601": "2024-07-26T07:49:29.837466Z",
            "url": "https://files.pythonhosted.org/packages/e8/34/e8a072d6d0c484f42e54fd1fecdf5f1438ab026e8e3c0403d1c311297823/homegrowndhe-0.3.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-07-26 07:49:29",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "homegrowndhe"
}
        
Elapsed time: 0.54951s