libcrypto


Namelibcrypto JSON
Version 1.1.4 PyPI version JSON
download
home_pagehttps://github.com/pymmdrza/libcrypto
SummaryA professional library For Cryptography and Cryptocurrencies in Python.
upload_time2025-11-06 00:22:04
maintainerNone
docs_urlNone
authorMmdrza
requires_python>=3.8
licenseMIT
keywords cryptocurrency bitcoin ethereum wallet bip39 bip32 bip44 mnemonic private-key public-key address hdwallet crypto blockchain litecoin dash dogecoin bitcoin-cash secp256k1 pycryptodome cryptography
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": "cryptocurrency, bitcoin, ethereum, wallet, bip39, bip32, bip44, mnemonic, private-key, public-key, address, hdwallet, crypto, blockchain, litecoin, dash, dogecoin, bitcoin-cash, secp256k1, pycryptodome, cryptography",
    "author": "Mmdrza",
    "author_email": "Mmdrza <pymmdrza@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/d2/6e/d2f0d1cea1b0efd17765e1e637539961e8e721142e47594679bb0dae14ef/libcrypto-1.1.4.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.1.4",
    "project_urls": {
        "Bug Tracker": "https://github.com/Pymmdrza/libcrypto/issues",
        "Documentation": "https://libcrypto.readthedocs.io",
        "Homepage": "https://libcrypto.readthedocs.io/",
        "PyPI": "https://pypi.org/project/libcrypto/",
        "Repository": "https://github.com/Pymmdrza/libcrypto"
    },
    "split_keywords": [
        "cryptocurrency",
        " bitcoin",
        " ethereum",
        " wallet",
        " bip39",
        " bip32",
        " bip44",
        " mnemonic",
        " private-key",
        " public-key",
        " address",
        " hdwallet",
        " crypto",
        " blockchain",
        " litecoin",
        " dash",
        " dogecoin",
        " bitcoin-cash",
        " secp256k1",
        " pycryptodome",
        " cryptography"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "340c44791195fa477263d8c52d4c8a0d1e610c23a3f376d64ae7e51fefa8d0a5",
                "md5": "62b5b7f26b4dbf537fdabfdaab5d3288",
                "sha256": "a33f591ea9169bf6b4d0ba3f151f055cbefccf9b56e80eea916cdeb039513570"
            },
            "downloads": -1,
            "filename": "libcrypto-1.1.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "62b5b7f26b4dbf537fdabfdaab5d3288",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 31275,
            "upload_time": "2025-11-06T00:22:03",
            "upload_time_iso_8601": "2025-11-06T00:22:03.282622Z",
            "url": "https://files.pythonhosted.org/packages/34/0c/44791195fa477263d8c52d4c8a0d1e610c23a3f376d64ae7e51fefa8d0a5/libcrypto-1.1.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "d26ed2f0d1cea1b0efd17765e1e637539961e8e721142e47594679bb0dae14ef",
                "md5": "9a3dee09110cf692ada196fadc250429",
                "sha256": "db7cd98adff6bb1f6982603e5e4bc31dc70b2983183d24031dc756cab7a3c786"
            },
            "downloads": -1,
            "filename": "libcrypto-1.1.4.tar.gz",
            "has_sig": false,
            "md5_digest": "9a3dee09110cf692ada196fadc250429",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 30741,
            "upload_time": "2025-11-06T00:22:04",
            "upload_time_iso_8601": "2025-11-06T00:22:04.242782Z",
            "url": "https://files.pythonhosted.org/packages/d2/6e/d2f0d1cea1b0efd17765e1e637539961e8e721142e47594679bb0dae14ef/libcrypto-1.1.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-11-06 00:22:04",
    "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: 3.97310s