Skip to content

cristalhq/slowrand

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

slowrand

build-img pkg-img reportcard-img coverage-img version-img

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

Features

  • Slow
  • Deterministic
  • Random
  • Dependency-free

Install

Go version 1.15+

go get github.com/cristalhq/slowrand

Example

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.

License

MIT License.