Skip to content

Instantly share code, notes, and snippets.

@billymeltdown
Created May 3, 2013 15:58
Show Gist options
  • Save billymeltdown/5510304 to your computer and use it in GitHub Desktop.
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.
- (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