Best way to generate NSData object with random bytes of a specific length?

后端 未结 9 1546
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-05 11:37

If I create a new NSData object of a specific size using dataWithBytes:length:, what is the most efficient way to create the input bytes (20 Mb worth) of random characters, pref

9条回答
  •  我寻月下人不归
    2021-02-05 12:10

    I've open sourced my JFRandom class over at github which can do exactly this. Here's a blog post demonstrating how to obtain/use it to achieve your goal...

    http://jayfuerstenberg.com/devblog/generating-random-numbers-strings-and-data-in-objective-c

提交回复
热议问题