mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-18 14:34:52 +02:00
Use crypto/rand rather than math/rand
Who knows how random math/rand actually is
This commit is contained in:
@@ -3,9 +3,11 @@
|
||||
package shm
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"encoding/base32"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
not_rand "math/rand"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -42,8 +44,12 @@ func prefix_and_suffix(pattern string) (prefix, suffix string, err error) {
|
||||
}
|
||||
|
||||
func next_random() string {
|
||||
num := rand.Uint32()
|
||||
return strconv.FormatUint(uint64(num), 16)
|
||||
b := make([]byte, 8)
|
||||
_, err := rand.Read(b)
|
||||
if err != nil {
|
||||
return strconv.FormatUint(uint64(not_rand.Uint32()), 16)
|
||||
}
|
||||
return base32.StdEncoding.WithPadding(base32.NoPadding).EncodeToString(b)
|
||||
}
|
||||
|
||||
type MMap interface {
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
package shm
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"math/rand"
|
||||
"os"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
Reference in New Issue
Block a user