mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2025-02-25 08:02:58 +08:00
21 lines
284 B
Go
21 lines
284 B
Go
|
// Copyright (c) 2017 Gorillalabs. All rights reserved.
|
||
|
|
||
|
package utils
|
||
|
|
||
|
import (
|
||
|
"crypto/rand"
|
||
|
"encoding/hex"
|
||
|
)
|
||
|
|
||
|
func CreateRandomString(bytes int) string {
|
||
|
c := bytes
|
||
|
b := make([]byte, c)
|
||
|
|
||
|
_, err := rand.Read(b)
|
||
|
if err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
|
|
||
|
return hex.EncodeToString(b)
|
||
|
}
|