IP Subnet package
Project description
Jamaddr27 Python Package
This package Created by Jamison Emilio and packaged by Todd Albiston
Installation Python2.7.12 and above
pip install jamaddr27
for python3.6 see jamaddr https://github.com/talbiston/jamaddr
Description:
Python Package adds functions to convert IP address or subnet masks to bits and bits back to IP address.
from jamaddr27 import JamAddr
ipbits = JamAddr.ip_to_bits("192.168.0.23")
ipbits
returns = '11000000101010000000000000010111'
from jamaddr27 import JamAddr
bitsip = JamAddr.bits_to_ip("11000000101010000000000000010111")
bitsip
returns = '192.168.0.23'
Of course you could also enter a subnet mask to convert to bits then do the same with its corresponding IP, then work out what the network ID or Broadcast IPs would be or use your imagination on what other use cases could be.
from jamaddr27 import JamAddr
def network_id(ip_cidr):
ip, cidr = ip_cidr.split('/')
ip_bits = JamAddr.ip_to_bits(ip)[:int(cidr)] + '0' * (32 - int(cidr))
return '{}/{}'.format(JamAddr.bits_to_ip(ip_bits), cidr)
networkID = network_id("192.168.0.23/28")
print(networkID)
returns = 192.168.0.16/28
This example above is already included as a function in this package so you could just do the following, but you get the point.
from jamaddr27 import JamAddr
networkID = JamAddr.network_id("192.168.0.23/28")
print(networkID)
returns = 192.168.0.16/28
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jamaddr27-0.5.tar.gz.
File metadata
- Download URL: jamaddr27-0.5.tar.gz
- Upload date:
- Size: 2.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
857e232a45ed5b926d4d4cac01b96da457d1889f0a0669d5e37f7e9e76e31f91
|
|
| MD5 |
509d7ea91e3fdcc5856e3c83293fd87f
|
|
| BLAKE2b-256 |
f231a0ba32e3817fac21319aebadb405db770169404e0300f9879c377fbe0afa
|
File details
Details for the file jamaddr27-0.5-py2-none-any.whl.
File metadata
- Download URL: jamaddr27-0.5-py2-none-any.whl
- Upload date:
- Size: 3.0 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3f20957c7c88ba782de5a89e9054cff87beec882f293a1c855a4d603cdf266f6
|
|
| MD5 |
f343bba201c6ec0e0f34f2e81963f95c
|
|
| BLAKE2b-256 |
edb442fde6dfb1cf69ce2f69cf23a01fe43cdacb7a0b12025d33abce4b1dc6f5
|