Created
May 3, 2013 15:58
-
-
Save billymeltdown/5510304 to your computer and use it in GitHub Desktop.
Example of taking data from an iOS accelerometer and using it to seed OpenSSL's RAND.
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
- (void)seedFromAcceleration:(UIAcceleration *)accel { | |
UIAccelerationValue value = accel.x; | |
RAND_add(&value, sizeof(value), sizeof(value)); | |
value = accel.y; | |
RAND_add(&value, sizeof(value), sizeof(value)); | |
value = accel.z; | |
RAND_add(&value, sizeof(value), sizeof(value)); | |
NSTimeInterval interval = accel.timestamp; | |
RAND_add(&interval, sizeof(interval), sizeof(interval)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment