aqi/utils/random.go

17 lines
222 B
Go
Raw Normal View History

2024-06-18 18:08:39 +08:00
package utils
import (
"crypto/rand"
"fmt"
)
func GetRandomString(n int) string {
randBytes := make([]byte, n/2)
_, err := rand.Read(randBytes)
if err != nil {
return ""
}
return fmt.Sprintf("%x", randBytes)
}