upd rendom_mac()

This commit is contained in:
ge 2024-01-16 22:24:42 +03:00
parent d2515cace8
commit b211148c0a

View File

@ -15,19 +15,19 @@
"""Random identificators.""" """Random identificators."""
# ruff: noqa: S311, C417 # ruff: noqa: S311
import random import random
def random_mac() -> str: def random_mac() -> str:
"""Retrun random MAC address.""" """Retrun random MAC address."""
mac = [ bits = [
0x00, 0x0A,
0x16, random.randint(0x00, 0xFF),
0x3E, random.randint(0x00, 0xFF),
random.randint(0x00, 0x7F), random.randint(0x00, 0xFF),
random.randint(0x00, 0xFF), random.randint(0x00, 0xFF),
random.randint(0x00, 0xFF), random.randint(0x00, 0xFF),
] ]
return ':'.join(map(lambda x: '%02x' % x, mac)) return ':'.join([f'{b:02x}' for b in bits])