https://github.com/soreing/grand
Golang random generator with simple entropy seeding
https://github.com/soreing/grand
entropy go golang random seed
Last synced: 3 months ago
JSON representation
Golang random generator with simple entropy seeding
- Host: GitHub
- URL: https://github.com/soreing/grand
- Owner: Soreing
- License: mit
- Created: 2023-11-07T21:12:04.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-12-02T15:02:56.000Z (over 1 year ago)
- Last Synced: 2025-02-10T09:44:01.195Z (5 months ago)
- Topics: entropy, go, golang, random, seed
- Language: Go
- Homepage:
- Size: 10.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Go Random Generator


[](https://goreportcard.com/report/github.com/Soreing/grand)
[](https://pkg.go.dev/github.com/Soreing/grand)Grand is a simple random generator wrapper on math/rand seeded by entropy from crypto/rand
## Usage
Create a source that can be used by the randomizer. `NewSource` creates a source
with an optional seed. If there is no seed provided, a truly random seed will be
derived from crypto/rand.If a seed is provided, the function will not return an error. If entropy is used,
the function can return an error if it fails to read bytes from crypto/rand```golang
// New source using entropy
src, err := grand.NewSource()// New source from existing seed
src, _ := grand.NewSource(1552664635341843643)
```The randomizer can use any math/rand source, not only ones created using this
package.```golang
// New randomizer from source
rng := grand.New(src)
```