https://github.com/grishnov/rc4-prng
Implementation of RC4-based stream pseudo-random number generator (PRNG) in C
https://github.com/grishnov/rc4-prng
pseudo-random pseudo-random-generator pseudo-random-number-generation random random-generation random-number-generators rc4 rc4-algorithm
Last synced: about 1 year ago
JSON representation
Implementation of RC4-based stream pseudo-random number generator (PRNG) in C
- Host: GitHub
- URL: https://github.com/grishnov/rc4-prng
- Owner: GRISHNOV
- License: mit
- Created: 2020-11-21T22:58:39.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-03-31T22:25:28.000Z (about 5 years ago)
- Last Synced: 2025-01-28T20:38:27.288Z (over 1 year ago)
- Topics: pseudo-random, pseudo-random-generator, pseudo-random-number-generation, random, random-generation, random-number-generators, rc4, rc4-algorithm
- Language: C
- Homepage: https://tools.ietf.org/html/rfc6229
- Size: 7.81 KB
- Stars: 1
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
RC4-PRNG
Implementation of RC4-based pseudo-random number generator (PRNG) in C.
# Quick start
Download this repository and go to directory with project.
```
git clone https://github.com/GRISHNOV/RC4-PRNG.git
cd RC4-PRNG
```
Run the project build using the make utility.
```
make
```
Now the `build` folder contains the `RC4_PRNG.o` object file. Use it together with the `RC4_PRNG.h` header file from `include` folder to work with RC4-based pseudo-random number generator in your project.
# Example of use
```C
#include
#include
#include
#include "RC4_PRNG.h"
int main(void)
{
uint8_t key[] = { 0x01, 0x02, 0x03, 0x04, 0x05 };
uint16_t keyLength = sizeof(key);
uint64_t streamOffset = 0;
uint64_t streamLength = 32;
uint8_t* result = getPseudoRandomBytesStream(key, keyLength, streamOffset, streamLength);
printPseudoRandomBytesStream(result, streamLength);
free(result);
return 0;
}
```
```
gcc main.c RC4_PRNG.o
./a.out
```
Output:
```
b2 39 63 5 f0 3d c0 27 cc c3 52 4a a 11 18 a8
69 82 94 4f 18 fc 82 d5 89 c4 3 a4 7a d 9 19
```