Skip to main content

IPv4 Conversions

ipv4-conversions converts an IPv4 address between dotted-decimal notation and four dotted 8-bit binary octets. It is available as a Python library, a command-line tool, and an interactive prompt.

Requirements

Installation

pip install .

Library usage

from ipv4_conversions import binary_to_ipv4, ipv4_to_binary

ipv4_to_binary("192.168.1.1")
# "11000000.10101000.00000001.00000001"

binary_to_ipv4("11000000.10101000.00000001.00000001")
# "192.168.1.1"

Both functions require exactly four octets. Decimal octets must be in the range 0 to 255; binary octets must each contain exactly eight 0 or 1 characters. Invalid input raises ValueError.

Function Description
ipv4_to_binary(ipv4: str) -> str Converts dotted-decimal IPv4 notation to four zero-padded, dotted binary octets.
binary_to_ipv4(binary: str) -> str Converts four dotted 8-bit binary octets to dotted-decimal IPv4 notation.

Command line

# Binary address to dotted decimal
ipv4-conversions --to-decimal 11000000.10101000.00000001.00000001
# The dotted-decimal equivalent of ... is: 192.168.1.1

# Dotted decimal to binary address
ipv4-conversions --to-binary 192.168.1.1
# The binary equivalent of 192.168.1.1 is: 11000000.10101000.00000001.00000001

The short options are -d for --to-decimal and -b for --to-binary. The options are mutually exclusive. Running ipv4-conversions without options opens the interactive menu.

Interactive menu

Run the command without any options to open the interactive menu:

ipv4-conversions

Choose Binary address to dotted decimal or Dotted decimal to binary address, then enter the address when prompted. Choose Exit to quit.

Development

pip install -e ".[dev]"
pytest
ruff check .

License

Released under the MIT License. See LICENSE.

Metadata

Release files for ipv4-conversions 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ipv4-conversions 0.1.0
File Size Uploaded Provenance Actions
ipv4_conversions-0.1.0.tar.gz 4.9 kB Without provenance Details for ipv4_conversions-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ipv4-conversions 0.1.0
File Interpreter ABI Platform Actions
ipv4_conversions-0.1.0-py3-none-any.whl Python 3 none any Details for ipv4_conversions-0.1.0-py3-none-any.whl

Total release size: 10.1 kB

Release files / ipv4_conversions-0.1.0.tar.gz

Download URL ipv4_conversions-0.1.0.tar.gz
Size 4.9 kB
Tags Source
SHA-256 checksum
How to use checksums
9f808bf7ed3fcfd4c0c852fbe5f2d20f3788c7050d02de4533242bcb2283ac14
BLAKE2b-256 checksum
How to use checksums
8c1528b6e7bfb94286af3398f73b4a994089d44284b5ac59169d8d23cf7aebec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / ipv4_conversions-0.1.0-py3-none-any.whl

Download URL ipv4_conversions-0.1.0-py3-none-any.whl
Size 5.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
47ebd389cd28e78230549f075018a4001d78d344a3e02810bba12ffb35e8289d
BLAKE2b-256 checksum
How to use checksums
fbe994aac2c7bbdf06a3e0e7812af72ec3183664ad32fe95343a34d7cedf847b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Security for ipv4-conversions 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page