mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
For regression test, add srs-bench to 3rdparty
This commit is contained in:
parent
de87dd427d
commit
876210f6c9
1158 changed files with 256967 additions and 3 deletions
30
trunk/3rdparty/srs-bench/vendor/github.com/pion/randutil/crypto.go
generated
vendored
Normal file
30
trunk/3rdparty/srs-bench/vendor/github.com/pion/randutil/crypto.go
generated
vendored
Normal file
|
@ -0,0 +1,30 @@
|
|||
package randutil
|
||||
|
||||
import (
|
||||
crand "crypto/rand"
|
||||
"encoding/binary"
|
||||
"math/big"
|
||||
)
|
||||
|
||||
// GenerateCryptoRandomString generates a random string for cryptographic usage.
|
||||
func GenerateCryptoRandomString(n int, runes string) (string, error) {
|
||||
letters := []rune(runes)
|
||||
b := make([]rune, n)
|
||||
for i := range b {
|
||||
v, err := crand.Int(crand.Reader, big.NewInt(int64(len(letters))))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
b[i] = letters[v.Int64()]
|
||||
}
|
||||
return string(b), nil
|
||||
}
|
||||
|
||||
// CryptoUint64 returns cryptographic random uint64.
|
||||
func CryptoUint64() (uint64, error) {
|
||||
var v uint64
|
||||
if err := binary.Read(crand.Reader, binary.LittleEndian, &v); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue