Library for generating Ethernet MAC addresses
Project description
Python-generate_mac
Python library for Generating Ethernet MAC addresses. Can use the wireshark manuf for specific vendors, and or a random, but assigned address. Will work with any file formated the same as said file.
Supported functions:
total_random() - Procedurely generated MAC address, using random function.
vid_file_random(file) - uses random line from wireshark's manuf file
vid_file_vendor(file, name) - specify a vendor name, uses wireshark's manuf file instead of being completely random
vid_provided(vid bytes) - specify the VID bytes when calling the function. Random device bytes will be generated.
list_vendors(file) - return a python list [] with valid vendors
is_mac_address(mac) - Takes a string, and checks if it is a valid Ethernet MAC address. returns True or False(bool type)
Usage
Import and set up an object.
import generate_mac
g = generate_mac.generate_mac
Procedurely generated Vendor and Host bytes. Checks for broadcast bit
g.total_random()
'12:7E:C4:B5:F1:8E'
Read Vendor bytes from random line in a file. This has to be formated the same as wireshark's manuf file.
g.vid_file_random('/usr/share/wireshark/manuf')
'00:55:DA:10:FB:D8'
Read from a manuf file like above, but find Vendor bytes belonging to a specific vendor, by name.
g.vid_file_vendor('/usr/share/wireshark/manuf', 'Apple')
'94:0C:98:BC:74:1C'
Provide the vendor bytes in a string. Generate Host bytes only
g.vid_provided('AA:BB:CC')
'AA:BB:CC:B8:B3:01'
List valid vendor options as a list.
g.list_vendors('/usr/share/wireshark/manuf')
['Vendor1','Vendor2','etc']
Check if a MAC address is valid
if g.is_mac_address('94:0C:98:BC:74:1C') == True:
print('Valid Ethernet Address')
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
Hashes for python-generate_mac-1.2.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 69d68f4cc2a4de5cfaf1c7af6076097ca9433137907239b9914b99913f016fd9 |
|
MD5 | 755d0bfdd7cb41f0c3f08ce3ff263b59 |
|
BLAKE2b-256 | 219c92bd7e1acd7eb5fa452c0c5fe9bc9e08b9b10922de67db05a70860f4c595 |
Hashes for python_generate_mac-1.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e431a5f31afc4bae9f08f4341a07e2833ac918483ab742910a6571c3ff388ce7 |
|
MD5 | 0d56d500cab14d4fd47df0357ccf80cd |
|
BLAKE2b-256 | 4b17456a2d17e1f54855a6cf9010bc6c25becf10792c900a76424c9cd7125f34 |