Skip to content

Instantly share code, notes, and snippets.

@szhernovoy
Last active August 29, 2015 14:14
Show Gist options
  • Save szhernovoy/7536b8ceda1050ca06dd to your computer and use it in GitHub Desktop.
Save szhernovoy/7536b8ceda1050ca06dd to your computer and use it in GitHub Desktop.
MAC Address generator
func macAddr(maxX : UInt32 = 0xff) -> String {
var s = ""
for n in 1...6 {
let rnd = Int((Double(arc4random())/0x100000000) * Double(maxX))
let srnd = String(format: "%02x:", rnd)
s += srnd
}
return (s as NSString).substringToIndex(countElements(s)-1)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment