Created
February 28, 2023 13:27
-
-
Save makeding/9c07f5150601bbb2dec3795d9a373c71 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const generateRandomMac = (/* prefix = '' */) => { | |
// https://stackoverflow.com/questions/24621721/how-would-one-generate-a-mac-address-in-javascript | |
// https://en.wikipedia.org/wiki/MAC_address#Ranges_of_group_and_locally_administered_addresses | |
return 'XR:XX:XX:XX:XX:XX'.replace(/X/ig, (x) => { | |
return "0123456789ABCDEF"[Math.floor(Math.random() * 16)] | |
}).replace('R', '26AE'[Math.floor(Math.random() * 4)]) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment