I need to generate some random data to append to my file for encryption. How would I go about doing this? Would it be sort of the same idea as generating a string of random characters?
Something like:
NSData *randomData = @"what should i put here?";
And then use the rand() function to randomize the data?
Your help is greatly appreciated
int SecRandomCopyBytes (
SecRandomRef rnd,
size_t count,
uint8_t *bytes
);
For example:
As noted by Peter in the comments, you can also do this:
And as noted by Rob in the comments, you need to link Security.framework for SecRandomCopyBytes to be available. You also need to include
SecRandom.h.