Skip to main content

A simple tool for formatting MAC addresses

Project description

mac-formatter

A simple library 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,doubledash,space,blank}, 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mac-formatter-0.3.9.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

mac_formatter-0.3.9-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file mac-formatter-0.3.9.tar.gz.

File metadata

  • Download URL: mac-formatter-0.3.9.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.4

File hashes

Hashes for mac-formatter-0.3.9.tar.gz
Algorithm Hash digest
SHA256 e1e634a0d469f6275b448362992b1bf931b28072780aef6ceb738157acefabc7
MD5 c00e1808cc04fc4e946a12bdb23f1769
BLAKE2b-256 67349ac8001e68008f845c41a9fc44020a209a2cb28b436f6e3b0cfdcc4583a7

See more details on using hashes here.

File details

Details for the file mac_formatter-0.3.9-py3-none-any.whl.

File metadata

File hashes

Hashes for mac_formatter-0.3.9-py3-none-any.whl
Algorithm Hash digest
SHA256 880fc2db697077af8eef9b84a06d86198f5f89170c4a47f0c2f094e8563a4336
MD5 3eaf90163b9adedbb254fba29e5cb217
BLAKE2b-256 5028f15c0c9ee4f0ca843165d5dd2eb9810dc224ee69f6836d29d98066a7f96d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page