Arbitrary random number creation in Objective-C

Where can I find an industrial safe pseudo random number generator for Objective-C? Is there a built-in OS X SDK?

My question is basically the same as this , except that I am looking for PRNG secure .

EDIT:

Thank you all for your help. Here's a simple one-line tool for implementing / dev / random method:

-(NSData *)getRandomBytes:(NSUInteger)length { return [[NSFileHandle fileHandleForReadingAtPath:@"/dev/random"] readDataOfLength:length]; } 
+6
source share
2 answers

For this security function, .framework is called SecRandomCopyBytes () . Although it is really just copying from /dev/random .

+4
source

you can use

 int SecRandomCopyBytes ( SecRandomRef rnd, size_t count, uint8_t *bytes );. 

This function is random numbers.
random (4) Mac OS X manual page
How good are SecRandomCopyBytes?

+3
source

Source: https://habr.com/ru/post/908181/


All Articles