mirror of
https://github.com/pion/webrtc.git
synced 2025-10-05 15:16:52 +08:00

Use seeded mathematical random where uniqueness is needed but not required to be cryptographic.
19 lines
447 B
Go
19 lines
447 B
Go
package signal
|
|
|
|
import (
|
|
"math/rand"
|
|
)
|
|
|
|
// RandSeq generates a random string to serve as dummy data
|
|
//
|
|
// It returns a deterministic sequence of values each time a program is run.
|
|
// Use rand.Seed() function in your real applications.
|
|
func RandSeq(n int) string {
|
|
letters := []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
|
|
b := make([]rune, n)
|
|
for i := range b {
|
|
b[i] = letters[rand.Intn(len(letters))]
|
|
}
|
|
return string(b)
|
|
}
|