Created
July 24, 2013 14:19
-
-
Save rjzak/6070996 to your computer and use it in GitHub Desktop.
Generate & store random data in a file. Designed to create a large random file to use as a key file for TrueCrypt.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <time.h> | |
int main(int argc, char* argv[] ) { | |
if (argc != 3) { | |
printf("Error, you must provide a destination file and number of iterations\n"); | |
return -1; | |
} | |
FILE *fp; | |
int i = 0; | |
srand(time(NULL)); | |
const int iters = atoi(argv[2]); | |
printf("Writing %d number of times...\n", iters); | |
fp = fopen(argv[1], "w"); | |
for(i = 0; i < iters; i++) { | |
int d = rand(); | |
int s = rand() % 2; | |
d = d << s; | |
s = d % 100; | |
d = d / 2; | |
fwrite(&d, sizeof(d), 1, fp); | |
fwrite(&s, sizeof(s), 1, fp); | |
//printf("Writing: %d %d\n", d, s); | |
} | |
fclose(fp); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment