Fixed bug in entropy calculation when using mixed character sets. Added enforce groups button to UI

This commit is contained in:
Michael Starke
2019-01-31 13:13:05 +01:00
parent 6068260abb
commit 6a1f8e0472
4 changed files with 106 additions and 64 deletions

View File

@@ -114,14 +114,9 @@ static NSString *mergeWithoutDuplicates(NSString* baseCharacters, NSString* cust
return [self composedCharacterAtIndex:arc4random_uniform((int)self.composedCharacterLength)];
}
- (CGFloat)entropyWhithPossibleCharacterSet:(MPPasswordCharacterFlags)allowedCharacters orCustomCharacters:(NSString *)customCharacters {
- (CGFloat)entropyWhithPossibleCharacterSet:(MPPasswordCharacterFlags)allowedCharacters andCustomCharacters:(NSString *)customCharacters {
NSString *characters = nil;
if([NSUserDefaults.standardUserDefaults boolForKey:kMPSettingsKeyPasswordUseCustomString] && nil != customCharacters) {
characters = mergeWithoutDuplicates(allowedCharactersString(allowedCharacters), customCharacters);
}
else {
characters = allowedCharactersString(allowedCharacters);
}
characters = mergeWithoutDuplicates(allowedCharactersString(allowedCharacters), customCharacters);
CGFloat alphabetCount = characters.composedCharacterLength;
CGFloat passwordLength = self.composedCharacterLength;
return passwordLength * ( log10(alphabetCount) / log10(2) );