If NUMBER_OF_CHARS is a compile-time constant, you can speed up your code by avoiding re-creating the object. You can make your program shorter by one line:
char data[NUMBER_OF_CHARS]; for (int x=0;x<NUMBER_OF_CHARS;data[x++] = (char)('A' + (arc4random_uniform(26)))); return [[NSString alloc] initWithBytes:data length:NUMBER_OF_CHARS encoding:NSUTF8StringEncoding];
As far as I know, arc4random_uniform should be good enough for cryptographic applications, but you may need to contact a cryptography specialist if the data you plan to protect is of great value to you or especially to your customers.
EDIT: Edited in response to nielsbot comment.
dasblinkenlight
source share