mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-18 23:09:21 +00:00
Entropy is now calculated for Custom Alphabets in Password Generator View
Custom String in Password Generator View are now filtered to only include unique characters
This commit is contained in:
@@ -52,9 +52,10 @@ typedef NS_ENUM(NSUInteger, MPPasswordRating) {
|
||||
@property (weak) IBOutlet NSTextField *entropyTextField;
|
||||
@property (weak) IBOutlet NSLevelIndicator *entropyIndicator;
|
||||
|
||||
@property (assign, nonatomic) BOOL useCustomString;
|
||||
@property (assign, nonatomic) NSUInteger passwordLength;
|
||||
@property (assign, nonatomic) CGFloat entropy;
|
||||
@property (nonatomic, copy) NSString *customString;
|
||||
@property (nonatomic, assign) BOOL useCustomString;
|
||||
@property (nonatomic, assign) NSUInteger passwordLength;
|
||||
@property (nonatomic, assign) CGFloat entropy;
|
||||
|
||||
- (IBAction)_generatePassword:(id)sender;
|
||||
- (IBAction)_toggleCharacters:(id)sender;
|
||||
@@ -72,6 +73,7 @@ typedef NS_ENUM(NSUInteger, MPPasswordRating) {
|
||||
_passwordLength = 12;
|
||||
_characterFlags = MPPasswordCharactersAll;
|
||||
_useCustomString = NO;
|
||||
_customString = @"";
|
||||
_entropy = 0.0;
|
||||
}
|
||||
return self;
|
||||
@@ -93,8 +95,10 @@ typedef NS_ENUM(NSUInteger, MPPasswordRating) {
|
||||
|
||||
[self.entropyIndicator bind:NSValueBinding toObject:self withKeyPath:@"entropy" options:nil];
|
||||
[self.entropyTextField bind:NSValueBinding toObject:self withKeyPath:@"entropy" options:nil];
|
||||
|
||||
|
||||
[self.customCharactersTextField setDelegate:self];
|
||||
[_customButton bind:NSValueBinding toObject:self withKeyPath:@"useCustomString" options:nil];
|
||||
|
||||
[_numbersButton setTag:MPPasswordCharactersNumbers];
|
||||
[_upperCaseButton setTag:MPPasswordCharactersUpperCase];
|
||||
[_lowerCaseButton setTag:MPPasswordCharactersLowerCase];
|
||||
@@ -104,6 +108,9 @@ typedef NS_ENUM(NSUInteger, MPPasswordRating) {
|
||||
[self _generatePassword:nil];
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Actions
|
||||
|
||||
- (IBAction)_generatePassword:(id)sender {
|
||||
if(_useCustomString) {
|
||||
if([[_customCharactersTextField stringValue] length] > 0) {
|
||||
@@ -137,6 +144,9 @@ typedef NS_ENUM(NSUInteger, MPPasswordRating) {
|
||||
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Custom Setter
|
||||
|
||||
- (void)setPassword:(NSString *)password {
|
||||
if(![_password isEqualToString:password]) {
|
||||
_password = [password copy];
|
||||
@@ -159,6 +169,18 @@ typedef NS_ENUM(NSUInteger, MPPasswordRating) {
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark NSTextFieldDelegate
|
||||
|
||||
- (void)controlTextDidChange:(NSNotification *)obj {
|
||||
if([obj object] == self.customCharactersTextField) {
|
||||
[self _generatePassword:nil];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Helper
|
||||
|
||||
- (void)_resetCharacters {
|
||||
if(_useCustomString) {
|
||||
[_customButton setState:NSOnState];
|
||||
|
||||
Reference in New Issue
Block a user