How to generate random key in iOS

It is a common task to generate a random n char string (alphanumeric string). It can be solved the following way. First, we generate an alphabet, that has m chars. Then in a cycle we generate random indexes from 0 to (m-1) and take a char from alphabet with random index.

Inspired by this post

Leave a Reply

Your email address will not be published. Required fields are marked *