update m3u8 ts name
This commit is contained in:
25
internal/pkg/rand/rand.go
Normal file
25
internal/pkg/rand/rand.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package rand
|
||||
|
||||
import (
|
||||
rd "crypto/rand"
|
||||
"encoding/hex"
|
||||
"io"
|
||||
)
|
||||
|
||||
func RandomBytes(n int) []byte {
|
||||
b := make([]byte, n)
|
||||
bs, err := io.ReadFull(rd.Reader, b)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
if bs < n {
|
||||
return nil
|
||||
}
|
||||
|
||||
return b
|
||||
}
|
||||
|
||||
func RandomString(n int) string {
|
||||
b := RandomBytes(n)
|
||||
return hex.EncodeToString(b)
|
||||
}
|
||||
Reference in New Issue
Block a user