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.8.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: mac-formatter-0.3.8.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.8.tar.gz
Algorithm Hash digest
SHA256 6cdf6fcd5f301c73a36fa7932bfb29e13f30ea91f86c20b69321798ab070e54d
MD5 0bfc5b1306aa4c5dc02b7c146108a86d
BLAKE2b-256 c12c0a9b50777054c633725739df650c80eb9f3777f68df7d66080c830b28efa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mac_formatter-0.3.8-py3-none-any.whl
Algorithm Hash digest
SHA256 fd89a96b948991da8ec01e59a6590aa33fd5f6ac46337c81edfbf930ced748b1
MD5 d333e4b23b0a7db93c4aaa5a7b1c6613
BLAKE2b-256 0ddf118a0bab0ca439abdb4dfec5d427ee47e6b6953696b8f1ab7f15d754307b

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