Avoid modulo bias for PIN generation

This commit is contained in:
Cameron Gutman 2020-07-12 11:40:31 -07:00
parent 46b9f84a31
commit e0bb48320f

View File

@ -229,8 +229,8 @@
- (NSString*) generatePIN {
NSString* PIN = [NSString stringWithFormat:@"%d%d%d%d",
arc4random() % 10, arc4random() % 10,
arc4random() % 10, arc4random() % 10];
arc4random_uniform(10), arc4random_uniform(10),
arc4random_uniform(10), arc4random_uniform(10)];
return PIN;
}