mirror of
https://github.com/pion/webrtc.git
synced 2025-10-04 23:02:48 +08:00
18 lines
386 B
Go
18 lines
386 B
Go
package util
|
|
|
|
import (
|
|
"math/rand"
|
|
"time"
|
|
)
|
|
|
|
// RandSeq generates a random alpha numeric sequence of the requested length
|
|
func RandSeq(n int) string {
|
|
r := rand.New(rand.NewSource(time.Now().UnixNano()))
|
|
letters := []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
|
|
b := make([]rune, n)
|
|
for i := range b {
|
|
b[i] = letters[r.Intn(len(letters))]
|
|
}
|
|
return string(b)
|
|
}
|