```c#
Random random = new Random();
return string.Format("{0}{1}:{2}{3}:{4}{5}:{6}{7}:{8}{9}:{10}{11}", new object[]
{
random.Next(0, 16).ToString("x"),
"6",
random.Next(0, 16).ToString("x"),
random.Next(0, 16).ToString("x"),
random.Next(0, 16).ToString("x"),
random.Next(0, 16).ToString("x"),
random.Next(0, 16).ToString("x"),
random.Next(0, 16).ToString("x"),
random.Next(0, 16).ToString("x"),
random.Next(0, 16).ToString("x"),
random.Next(0, 16).ToString("x"),
random.Next(0, 16).ToString("x")
}).ToLower();
```
<a href="/user/hellsam" title="@hellsam">@hellsam</a>
```go
package main
import (
"fmt"
"math/rand"
"time"
)
func main() {
mac := GetRandMac()
fmt.Println(mac)
}
func GetRandMac() string {
rand.Seed(time.Now().Unix())
a := make([]byte, 6)
rand.Read(a)
return fmt.Sprintf("%02x:%02x:%02x:%02x:%02x:%02x", a[0], a[1], a[2], a[3], a[4], a[5])
}
```
#7
更多评论
<a href="/user/hshd123" title="@hshd123">@hshd123</a> 是生成一组随机数字 mac,转换16进制
#2