https://github.com/cristalhq/slowrand
Slow deterministic random generator
https://github.com/cristalhq/slowrand
deterministic go golang random randomgenerator rng
Last synced: 2 months ago
JSON representation
Slow deterministic random generator
- Host: GitHub
- URL: https://github.com/cristalhq/slowrand
- Owner: cristalhq
- License: mit
- Created: 2020-08-16T09:25:50.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2025-03-19T16:16:32.000Z (3 months ago)
- Last Synced: 2025-03-19T17:26:56.558Z (3 months ago)
- Topics: deterministic, go, golang, random, randomgenerator, rng
- Language: Go
- Homepage:
- Size: 49.8 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# slowrand
[![build-img]][build-url]
[![pkg-img]][pkg-url]
[![reportcard-img]][reportcard-url]
[![coverage-img]][coverage-url]
[![version-img]][version-url]Slow deterministic random generator.
## Rationale
Some problems might require random deterministic generator, but this might be problematic due to brute-force attacks.
This (deterministic) random generator addresses this problem by increasing it's work time.## Note
Inspired by [cornfeedhobo/ssh-keydgen](https://github.com/cornfeedhobo/ssh-keydgen)
## Features
- Slow
- Deterministic
- Random
- Dependency-free## Install
Go version 1.15+
```
go get github.com/cristalhq/slowrand
```## Example
```go
seed := []byte("some-secure-seed")
rounds := 3
time := uint32(5)
memory := uint32(7)
threads := uint8(11)r, err := slowrand.New(seed, rounds, time, memory, threads)
if err != nil {
t.Fatal(err)
}var buf [42]byte
n, err := r.Read(buf[:])
if n != 42 {
panic("not 42")
}
_ = err // is always nil
```## Documentation
See [these docs][pkg-url].
## License
[MIT License](LICENSE).
[build-img]: https://github.com/cristalhq/slowrand/workflows/build/badge.svg
[build-url]: https://github.com/cristalhq/slowrand/actions
[pkg-img]: https://pkg.go.dev/badge/cristalhq/slowrand
[pkg-url]: https://pkg.go.dev/github.com/cristalhq/slowrand
[reportcard-img]: https://goreportcard.com/badge/cristalhq/slowrand
[reportcard-url]: https://goreportcard.com/report/cristalhq/slowrand
[coverage-img]: https://codecov.io/gh/cristalhq/slowrand/branch/main/graph/badge.svg
[coverage-url]: https://codecov.io/gh/cristalhq/slowrand
[version-img]: https://img.shields.io/github/v/release/cristalhq/slowrand
[version-url]: https://github.com/cristalhq/slowrand/releases