Created
October 10, 2013 01:21
-
-
Save mchow01/6911526 to your computer and use it in GitHub Desktop.
Generate 100 cryptographically secure random integers between 0 - 99 inclusive in Objective-C.
This file contains 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
FILE *fp = fopen("/dev/random", "r"); | |
if (!fp) { | |
/*UIAlertView *error = [[UIAlertView alloc]initWithTitle:@"Failure" | |
message:@"Sorry, cryptographically secure random numbers could not be generated." | |
delegate:self | |
cancelButtonTitle:@"Ok" | |
otherButtonTitles:nil, nil]; | |
[error show];*/ | |
} | |
int count; | |
for (count = 0 ; count < 100; count++) { | |
NSLog(@"%d", (int)fgetc(fp) % 100); | |
} | |
fclose(fp); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment