libcrypto


Namelibcrypto JSON
Version 1.0.6 PyPI version JSON
download
home_pagehttps://github.com/pymmdrza/libcrypto
SummaryA professional library For Cryptography and Cryptocurrencies in Python.
upload_time2025-07-15 00:21:28
maintainerNone
docs_urlNone
authorMmdrza
requires_python>=3.8
licenseMIT
keywords
VCS
bugtrack_url
requirements setuptools pycryptodome wheel ecdsa typer rich
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![Python Version](https://img.shields.io/pypi/v/libcrypto?color=blue&logo=python)](https://pypi.org/project/libcrypto/)
[![License](https://img.shields.io/pypi/l/libcrypto)](LICENSE)

# LibCrypto

A professional library for Cryptography and Cryptocurrencies in Python.

This library provides a comprehensive suite of tools for developers working with cryptocurrencies, focusing on key management and address generation with a clean, high-level API.

## Key Features

- **High-Level Wallet API**: A simple `Wallet` class to manage keys and addresses.
- **Multi-Currency Support**: Correctly generate addresses for numerous secp256k1-based cryptocurrencies, including:
  - Bitcoin (BTC) - Legacy, SegWit (P2SH & Native)
  - Ethereum (ETH)
  - Tron (TRX)
  - Ripple (XRP)
  - Bitcoin Cash (BCH) - CashAddr format
  - Litecoin (LTC)
  - Dash (DASH)
  - Dogecoin (DOGE)
- **Hierarchical Deterministic (HD) Wallets**: Full BIP32 support for generating wallets from a master seed.
- **BIP39 Mnemonic Support**: Generate, validate, and derive seeds from mnemonic phrases.
- **Key & Format Conversions**: Easily convert between WIF, Hex, and Bytes for private and public keys.
- **Powerful Command-Line Interface**: Perform common wallet operations directly from your terminal.

## Installation

Install the library using pip:
```bash
pip install libcrypto
```

## Quick Start (Library Usage)

```python
from libcrypto import Wallet

key = "Your private key here (hex)"
# Initialize the Wallet with the private key
# Replace "Your private key here (hex)" with your actual private key in hexadecimal format
wallet = Wallet(key)
# Generate P2PKH, P2SH-P2WPKH, P2WPKH addresses for Bitcoin
p2pkh = wallet.get_address(coin="bitcoin", address_type="p2pkh")
p2wsh = wallet.get_address(coin="bitcoin", address_type="p2sh-p2wpkh")
p2wpkh = wallet.get_address(coin="bitcoin", address_type="p2wpkh")
# Generate ethereum Address
ethereum_address = wallet.get_address(coin="ethereum")
# Generate Dash Address
dash = wallet.get_address(coin="dash")
# Generate Dogecoin Address
dogecoin_address = wallet.get_address(coin="dogecoin")
# Generate Tron Address
tron_address = wallet.get_address(coin="tron")
# Generate Ripple Address
ripple_address = wallet.get_address(coin="ripple")
# Generate Litecoin Address
litecoin_address = wallet.get_address(coin="litecoin")
# Generate Litecoin Address with specific address types
litecoin_address_p2pkh = wallet.get_address(coin="litecoin", address_type="p2pkh")
litecoin_address_p2wsh = wallet.get_address(coin="litecoin", address_type="p2sh-p2wpkh")
litecoin_address_p2wpkh = wallet.get_address(coin="litecoin", address_type="p2wpkh")
```

The library is designed to be straightforward. Here is a basic example of generating addresses from an existing private key.

```python
from libcrypto import Wallet

# Initialize a wallet from a WIF private key
wif_key = "L4ZQks37JHUadEqaj2nGB1eaZFcsRZwZGQ7WVYuQiztzg4pqopU6"  # Example WIF key
wallet = Wallet(wif_key)

# Generate addresses for different coins
eth_address = wallet.get_address('ethereum')
btc_address = wallet.get_address('bitcoin', address_type='p2wpkh') # Native SegWit
bch_address = wallet.get_address('bitcoin_cash')

print(f"Ethereum Address: {eth_address}")
print(f"Bitcoin (SegWit) Address: {btc_address}")
print(f"Bitcoin Cash Address: {bch_address}")
```

![CLI](https://raw.githubusercontent.com/Pymmdrza/libcrypto/refs/heads/main/.github/libcrypto_generate.png 'Libcrypto')


## Quick Start (Command-Line Interface)

```bash
# version
libcrypto -v
``` 

Package Information:
```bash
libcrypto info
```

### Wallet & Address Generation
- Generate a Wallet:
    This is the main command for generating new wallets or deriving addresses from existing keys.
```bash
libcrypto generate [OPTIONS]
```

Options:

-  `-p`, `--private-key` TEXT: Derive addresses from an existing private key (WIF or Hex format). If omitted, a new random wallet is generated.
-  `-c`, `--coin` TEXT: Specify a coin to generate addresses for. This option can be used multiple times. Defaults to bitcoin and ethereum.


1. Generate a new wallet for Bitcoin and Litecoin:
```bash
libcrypto generate -c bitcoin -c litecoin
```

2. Generate a wallet from an existing private key:
```bash
libcrypto generate -p <your-private-key>
```

3. Derive addresses for a specific set of coins from a hex key:
```bash
libcrypto generate -p <your-hex-key> -c bitcoin -c ethereum -c dash -c tron
```

### Mnemonic Management

The mnemonic subcommand is used for all BIP39 mnemonic phrase operations.
Generate a Mnemonic Phrase

Creates a new, cryptographically secure BIP39 mnemonic phrase.

```bash
libcrypto mnemonic generate [OPTIONS]
```

Options:

   - `-w`, `--words` INTEGER: The number of words in the mnemonic. Can be 12, 15, 18, 21, or 24. [Default: 12]

Example:
```bash
libcrypto mnemonic generate --words 24
```

### Validate a Mnemonic Phrase

Checks if a given BIP39 mnemonic phrase is valid according to the checksum rules.

```bash
libcrypto mnemonic validate "PHRASE"
```

Arguments:

- `PHRASE`: The full mnemonic phrase, enclosed in double quotes. [Required]

Example:
```bash
libcrypto mnemonic validate "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about"
```

## Donate

If you find this library useful, consider supporting its development:

- **Bitcoin (BTC)**: `1MMDRZAcM6dzmdMUSV8pDdAPDFpwzve9Fc`

## Contact

For support or inquiries, please contact us at [pymmdrza@gmail.com](mailto:pymmdrza@gmail.com).



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/pymmdrza/libcrypto",
    "name": "libcrypto",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": "Mmdrza",
    "author_email": "Mmdrza <pymmdrza@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/e1/a0/c9c20f6fb4281bf4229ec444dff53c5838354653a9250ef378655ce8ad6a/libcrypto-1.0.6.tar.gz",
    "platform": null,
    "description": "[![Python Version](https://img.shields.io/pypi/v/libcrypto?color=blue&logo=python)](https://pypi.org/project/libcrypto/)\n[![License](https://img.shields.io/pypi/l/libcrypto)](LICENSE)\n\n# LibCrypto\n\nA professional library for Cryptography and Cryptocurrencies in Python.\n\nThis library provides a comprehensive suite of tools for developers working with cryptocurrencies, focusing on key management and address generation with a clean, high-level API.\n\n## Key Features\n\n- **High-Level Wallet API**: A simple `Wallet` class to manage keys and addresses.\n- **Multi-Currency Support**: Correctly generate addresses for numerous secp256k1-based cryptocurrencies, including:\n  - Bitcoin (BTC) - Legacy, SegWit (P2SH & Native)\n  - Ethereum (ETH)\n  - Tron (TRX)\n  - Ripple (XRP)\n  - Bitcoin Cash (BCH) - CashAddr format\n  - Litecoin (LTC)\n  - Dash (DASH)\n  - Dogecoin (DOGE)\n- **Hierarchical Deterministic (HD) Wallets**: Full BIP32 support for generating wallets from a master seed.\n- **BIP39 Mnemonic Support**: Generate, validate, and derive seeds from mnemonic phrases.\n- **Key & Format Conversions**: Easily convert between WIF, Hex, and Bytes for private and public keys.\n- **Powerful Command-Line Interface**: Perform common wallet operations directly from your terminal.\n\n## Installation\n\nInstall the library using pip:\n```bash\npip install libcrypto\n```\n\n## Quick Start (Library Usage)\n\n```python\nfrom libcrypto import Wallet\n\nkey = \"Your private key here (hex)\"\n# Initialize the Wallet with the private key\n# Replace \"Your private key here (hex)\" with your actual private key in hexadecimal format\nwallet = Wallet(key)\n# Generate P2PKH, P2SH-P2WPKH, P2WPKH addresses for Bitcoin\np2pkh = wallet.get_address(coin=\"bitcoin\", address_type=\"p2pkh\")\np2wsh = wallet.get_address(coin=\"bitcoin\", address_type=\"p2sh-p2wpkh\")\np2wpkh = wallet.get_address(coin=\"bitcoin\", address_type=\"p2wpkh\")\n# Generate ethereum Address\nethereum_address = wallet.get_address(coin=\"ethereum\")\n# Generate Dash Address\ndash = wallet.get_address(coin=\"dash\")\n# Generate Dogecoin Address\ndogecoin_address = wallet.get_address(coin=\"dogecoin\")\n# Generate Tron Address\ntron_address = wallet.get_address(coin=\"tron\")\n# Generate Ripple Address\nripple_address = wallet.get_address(coin=\"ripple\")\n# Generate Litecoin Address\nlitecoin_address = wallet.get_address(coin=\"litecoin\")\n# Generate Litecoin Address with specific address types\nlitecoin_address_p2pkh = wallet.get_address(coin=\"litecoin\", address_type=\"p2pkh\")\nlitecoin_address_p2wsh = wallet.get_address(coin=\"litecoin\", address_type=\"p2sh-p2wpkh\")\nlitecoin_address_p2wpkh = wallet.get_address(coin=\"litecoin\", address_type=\"p2wpkh\")\n```\n\nThe library is designed to be straightforward. Here is a basic example of generating addresses from an existing private key.\n\n```python\nfrom libcrypto import Wallet\n\n# Initialize a wallet from a WIF private key\nwif_key = \"L4ZQks37JHUadEqaj2nGB1eaZFcsRZwZGQ7WVYuQiztzg4pqopU6\"  # Example WIF key\nwallet = Wallet(wif_key)\n\n# Generate addresses for different coins\neth_address = wallet.get_address('ethereum')\nbtc_address = wallet.get_address('bitcoin', address_type='p2wpkh') # Native SegWit\nbch_address = wallet.get_address('bitcoin_cash')\n\nprint(f\"Ethereum Address: {eth_address}\")\nprint(f\"Bitcoin (SegWit) Address: {btc_address}\")\nprint(f\"Bitcoin Cash Address: {bch_address}\")\n```\n\n![CLI](https://raw.githubusercontent.com/Pymmdrza/libcrypto/refs/heads/main/.github/libcrypto_generate.png 'Libcrypto')\n\n\n## Quick Start (Command-Line Interface)\n\n```bash\n# version\nlibcrypto -v\n``` \n\nPackage Information:\n```bash\nlibcrypto info\n```\n\n### Wallet & Address Generation\n- Generate a Wallet:\n    This is the main command for generating new wallets or deriving addresses from existing keys.\n```bash\nlibcrypto generate [OPTIONS]\n```\n\nOptions:\n\n-  `-p`, `--private-key` TEXT: Derive addresses from an existing private key (WIF or Hex format). If omitted, a new random wallet is generated.\n-  `-c`, `--coin` TEXT: Specify a coin to generate addresses for. This option can be used multiple times. Defaults to bitcoin and ethereum.\n\n\n1. Generate a new wallet for Bitcoin and Litecoin:\n```bash\nlibcrypto generate -c bitcoin -c litecoin\n```\n\n2. Generate a wallet from an existing private key:\n```bash\nlibcrypto generate -p <your-private-key>\n```\n\n3. Derive addresses for a specific set of coins from a hex key:\n```bash\nlibcrypto generate -p <your-hex-key> -c bitcoin -c ethereum -c dash -c tron\n```\n\n### Mnemonic Management\n\nThe mnemonic subcommand is used for all BIP39 mnemonic phrase operations.\nGenerate a Mnemonic Phrase\n\nCreates a new, cryptographically secure BIP39 mnemonic phrase.\n\n```bash\nlibcrypto mnemonic generate [OPTIONS]\n```\n\nOptions:\n\n   - `-w`, `--words` INTEGER: The number of words in the mnemonic. Can be 12, 15, 18, 21, or 24. [Default: 12]\n\nExample:\n```bash\nlibcrypto mnemonic generate --words 24\n```\n\n### Validate a Mnemonic Phrase\n\nChecks if a given BIP39 mnemonic phrase is valid according to the checksum rules.\n\n```bash\nlibcrypto mnemonic validate \"PHRASE\"\n```\n\nArguments:\n\n- `PHRASE`: The full mnemonic phrase, enclosed in double quotes. [Required]\n\nExample:\n```bash\nlibcrypto mnemonic validate \"abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about\"\n```\n\n## Donate\n\nIf you find this library useful, consider supporting its development:\n\n- **Bitcoin (BTC)**: `1MMDRZAcM6dzmdMUSV8pDdAPDFpwzve9Fc`\n\n## Contact\n\nFor support or inquiries, please contact us at [pymmdrza@gmail.com](mailto:pymmdrza@gmail.com).\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A professional library For Cryptography and Cryptocurrencies in Python.",
    "version": "1.0.6",
    "project_urls": {
        "Bug Tracker": "https://github.com/Pymmdrza/libcrypto/issues",
        "Homepage": "https://libcrypto.readthedocs.io/",
        "Repository": "https://github.com/Pymmdrza/libcrypto"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "8706e50c49ad75c8fc8846700a29eff14e1c7e21974ee9b4fd28dbae4345caa0",
                "md5": "b1cafce616a212ca129935d1ec1d2237",
                "sha256": "88fd41ade6d2791ce237cd9a1f09467b4f65bf3198fe705ee16f604d9032d21c"
            },
            "downloads": -1,
            "filename": "libcrypto-1.0.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b1cafce616a212ca129935d1ec1d2237",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 30955,
            "upload_time": "2025-07-15T00:21:27",
            "upload_time_iso_8601": "2025-07-15T00:21:27.541264Z",
            "url": "https://files.pythonhosted.org/packages/87/06/e50c49ad75c8fc8846700a29eff14e1c7e21974ee9b4fd28dbae4345caa0/libcrypto-1.0.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "e1a0c9c20f6fb4281bf4229ec444dff53c5838354653a9250ef378655ce8ad6a",
                "md5": "eceda063d9de49a976d715c875c1d672",
                "sha256": "2dd2b5e89209f2061376bb5278319a0294da230c95396c2229372cad64fe59d6"
            },
            "downloads": -1,
            "filename": "libcrypto-1.0.6.tar.gz",
            "has_sig": false,
            "md5_digest": "eceda063d9de49a976d715c875c1d672",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 30205,
            "upload_time": "2025-07-15T00:21:28",
            "upload_time_iso_8601": "2025-07-15T00:21:28.481494Z",
            "url": "https://files.pythonhosted.org/packages/e1/a0/c9c20f6fb4281bf4229ec444dff53c5838354653a9250ef378655ce8ad6a/libcrypto-1.0.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-15 00:21:28",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "pymmdrza",
    "github_project": "libcrypto",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "setuptools",
            "specs": []
        },
        {
            "name": "pycryptodome",
            "specs": []
        },
        {
            "name": "wheel",
            "specs": []
        },
        {
            "name": "ecdsa",
            "specs": []
        },
        {
            "name": "typer",
            "specs": []
        },
        {
            "name": "rich",
            "specs": []
        }
    ],
    "lcname": "libcrypto"
}
        
Elapsed time: 1.99985s