mercredi 19 juillet 2023

Generate secure random number in range Swift

I need to generate a secure random number in range (e.g. between 0 and 56, or any other range). But I can't find a way to do that, I looked through this thread. Most of the answers there are generating pseudo random numbers; but those that generate secure random numbers, don't allow to specify a range. For example this answer only allows generating numbers between 0 and 128, but I need to specify a different range.

I have no idea how to do this properly with SecRandomCopyBytes. In particular, I need to do this on iOS.




Aucun commentaire:

Enregistrer un commentaire