diff --git a/MacPass/NSString+MPPasswordCreation.m b/MacPass/NSString+MPPasswordCreation.m index 1f169208..1ab8c9c0 100644 --- a/MacPass/NSString+MPPasswordCreation.m +++ b/MacPass/NSString+MPPasswordCreation.m @@ -105,12 +105,17 @@ static NSString *mergeWithoutDuplicates(NSString* baseCharacters, NSString* cust } - (CGFloat)entropyWhithPossibleCharacterSet:(MPPasswordCharacterFlags)allowedCharacters orCustomCharacters:(NSString *)customCharacters { - CGFloat alphabetCount = customCharacters.length; + NSString *characters = nil; if(nil == customCharacters) { - NSString *stringSet = allowedCharactersString(allowedCharacters); - alphabetCount = stringSet.length; + characters = allowedCharactersString(allowedCharacters); } - CGFloat passwordLegnth = self.length; - return passwordLegnth * ( log10(alphabetCount) / log10(2) ); + else { + NSString *characters = mergeWithoutDuplicates( + allowedCharactersString(allowedCharacters), + customCharacters); + } + CGFloat alphabetCount = characters.length; + CGFloat passwordLength = self.length; + return passwordLength * ( log10(alphabetCount) / log10(2) ); } @end