Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/soreing/grand
Golang random generator with simple entropy seeding
https://github.com/soreing/grand
entropy go golang random seed
Last synced: 4 days 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 (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-12-02T15:02:56.000Z (about 1 year ago)
- Last Synced: 2024-10-30T14:50:49.203Z (about 2 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
![Build](https://github.com/soreing/grand/actions/workflows/build_status.yaml/badge.svg)
![Coverage](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/Soreing/4b6f950f01f3e6e5b9ed17b268664538/raw/grand)
[![Go Report Card](https://goreportcard.com/badge/github.com/Soreing/grand)](https://goreportcard.com/report/github.com/Soreing/grand)
[![Go Reference](https://pkg.go.dev/badge/github.com/Soreing/grand.svg)](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)
```