Linear feedback shift register (LFSR) based psuedo random number generator
Random numbers generated by the LFSR implemented in this package will produce a sequence that has a period covering the full range of bits for the chosen LFSR. A well designed n-bit LFSR will return the numbers in the range 1-2^n in a pseudo random order with no repeating numbers until the full range has been exhausted. In this package the following linear feedback registers are provided:
- Lfsr8 - 8 bit LFSR with a period of 255
- Lfsr16 - 16 bit LFSR with a period of 65,535
- Lfsr32 - 32 bit LFSR with a period of 4,294,967,296
- Lfsr64 - 64 bit LFSR with a period of 18,446,744,073,709,551,616
Use the 'go' command:
$go get github.com/taylorza/go-lfsr
// Create a 64 bit LFSR with a time based seed
l := lfsr.NewLfsr64(0)
// Get the next random number in the sequence from the LFSR
v, _ := l.Next();
See tests for more examples
Copyright (C)2013-2019 by Chris Taylor (taylorza) See Licence