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.
        encoded : 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.
        mixed : Mixed separator format, e.g., AB:12-CD-34.EF:56.
        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
\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.7.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: mac-formatter-0.3.7.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

Hashes for mac-formatter-0.3.7.tar.gz
Algorithm Hash digest
SHA256 e4c804a3fe6382d5772c421f241296598635400e4bbd4a7c6b1fb2fd31d2bb62
MD5 d8ba0cc6d2a10513f97df37ea90614bb
BLAKE2b-256 6043fa2fb1a938689bd77fad8daf10a1837caec6feac171a76cd0a7a5bafab71

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mac_formatter-0.3.7-py3-none-any.whl
Algorithm Hash digest
SHA256 9676635966f3385ca84061f20951e78d6e745998ba7d3baf3aaeb04c9d7ae41f
MD5 a9f062631f94a26a35f6de74e137903e
BLAKE2b-256 dba2fece079000df6de93eb95c431b36c49062d383fdda554d01b83ee7eaff48

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