Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aviate-labs/rand.mo
Pseudo Random Number Generators in Motoko
https://github.com/aviate-labs/rand.mo
Last synced: 3 months ago
JSON representation
Pseudo Random Number Generators in Motoko
- Host: GitHub
- URL: https://github.com/aviate-labs/rand.mo
- Owner: aviate-labs
- License: apache-2.0
- Created: 2021-09-01T12:38:16.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-12-16T17:39:07.000Z (almost 2 years ago)
- Last Synced: 2024-04-19T01:33:16.090Z (7 months ago)
- Language: Motoko
- Homepage:
- Size: 13.7 KB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-motoko - rand - Pseudo Random Number Generators. (Libraries / Cryptography)
README
# Pseudo Random Number Generators
## LFSR (linear feedback shift register)
### Types of LFSR
#### 8-bit
```text
X^8 + X^6 + X^5 + X^4 + 1
-> 2^8 -1 = 255
```#### 16-bit
```text
X^16 + X^14 + X^13 + X^11 + 1
-> 2^16 - 1 = 65_535
```#### 32-bit
```text
X^32+ X^22 + X^2 + X^1 + 1
-> 2^32 - 1
```### Usage
```motoko
let feed = LFSR.LFSR8(0);
let (v, _) = feed.next();// Iter
let iter = LFSR.toIter(feed);
```
## XorShiftReference: [prng](https://vigna.di.unimi.it/ftp/papers/xorshift.pdf).