A simple tool for formatting MAC addresses
Project description
mac-formatter
A simple package to convert MAC-addresses to different formats.
How to use in terminal(cli).
positional arguments:
mac_address: The MAC address to format
options:
-h, --help: show this help message and exit
-f, --format: {'colon','dot','dash','ddash','space','blank','binary','compact','eui64','bpf','reverse'}, The format to use. If not specified, all formats will be printed.
"The format to use. If not specified, all formats will be printed.
Available formats:
colon : Colon-separated format, e.g., ab:12:cd:34:ef:56.
dot : Dot notation, e.g., abcd.ef12.3456.
dash : Hyphen-separated format, e.g., ab-12-cd-34-ef-56.
ddash : Double-dash-separated format, e.g., ab12-cd34-ef56.
space : Space-separated format, e.g., ab 12 cd 34 ef 56.
blank : Continuous string with no delimiters, e.g., ab12cd34ef56.
binary : Binary format, e.g., 10101011 00010010 11001101 00110100 11101111 01010110.
compact : Base64 encoded format, e.g., qXLNTq9W.
eui64 : Cisco EUI-64 format, e.g., ab12.cd34.fffe.ef56.
bpf : BPF format with each byte prefixed by '\x', e.g., \xab\x12\xcd\x34\xef\x56.
reverse : Reverse byte order, e.g., 56ef34cd12ab.
-u, --uppercase: Prints the MAC address in uppercase.
-l, --lowercase: Prints the MAC address in lowercase.
Example usage:
mac-formatter abcdef123456 -f dot
output:
abcd.ef12.3456
There is also a shorter name macf
:
macf abcd.ef12.3456 -f colon -u
output:
AB:CD:EF:12:34:56
How to use in your code.
from mac_formatter import MacFormatter
mac_address = 'ab:cd:ef:12:34:56'
mac = MacFormatter(mac_address)
print(mac.dot)
print(mac.dash)
print(mac.ddash)
print(mac.space)
print(mac.colon)
print(mac.blank)
print(mac.binary)
print(mac.compact)
print(mac.eui64)
print(mac.bpf)
print(mac.reverse)
output:
abcd.ef12.3456
ab-cd-ef-12-34-56
abcd-ef12-3456
ab cd ef 12 34 56
ab:cd:ef:12:34:56
abcdef123456
10101011 11001101 11101111 00010010 00110100 01010110
q83vEjRW
ab12.cd34.fffe.ef56
\xab\xcd\xef\x12\x34\x56
654321fedcba
---
thamuppet
Project details
Release history Release notifications | RSS feed
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
File details
Details for the file mac-formatter-0.4.0.tar.gz
.
File metadata
- Download URL: mac-formatter-0.4.0.tar.gz
- Upload date:
- Size: 5.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f8e782921e4bcd7612ce3c696b2b8d09402b20ebe937ec4a921e37a3408a75bc |
|
MD5 | bf21a628b7b95bc04147fd03409c0a3e |
|
BLAKE2b-256 | 41eb3ee4a636040a3267497ec5080af7f5360b084e1f53060307d2bbad7be0c8 |
File details
Details for the file mac_formatter-0.4.0-py3-none-any.whl
.
File metadata
- Download URL: mac_formatter-0.4.0-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 299edc3bd1f1228dba28a98e3e399c997fa70e92aac382ad1e2428b72fe157c7 |
|
MD5 | 67b7563dcb67115e3e4f7b880b9db28d |
|
BLAKE2b-256 | 9c1f4312cf9d4452520658dac920d7e7811e7b5f97303849926ba54230e41b64 |