Initial commit
This commit is contained in:
16 files changed
+2890
No files matched your search
@@ -0,0 +1,89 @@
|
||||
//
|
||||
// AppDelegate.m
|
||||
// Password Generator
|
||||
//
|
||||
// Created by User on 9/16/26.
|
||||
// Copyright (c) 2026 User. All rights reserved.
|
||||
//
|
||||
|
||||
#import "AppDelegate.h"
|
||||
|
||||
@implementation AppDelegate
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
|
||||
{
|
||||
[self.regenerateButton sendAction:self.regenerateButton.action to:self.regenerateButton.target];
|
||||
}
|
||||
|
||||
- (IBAction)lengthSliderChanged:(id)sender {
|
||||
[self.lengthText setStringValue:[NSString stringWithFormat:@"Password Length: %ld", (long)[sender integerValue]]];
|
||||
[self.regenerateButton sendAction:self.regenerateButton.action to:self.regenerateButton.target];
|
||||
}
|
||||
|
||||
// preset buttons
|
||||
|
||||
- (IBAction)preset8ButtonClicked:(id)sender
|
||||
{
|
||||
self.lengthSlider.integerValue = 8;
|
||||
[self.lengthSlider sendAction:self.lengthSlider.action to:self.lengthSlider.target];
|
||||
}
|
||||
|
||||
- (IBAction)preset16ButtonClicked:(id)sender
|
||||
{
|
||||
self.lengthSlider.integerValue = 16;
|
||||
[self.lengthSlider sendAction:self.lengthSlider.action to:self.lengthSlider.target];
|
||||
}
|
||||
|
||||
- (IBAction)preset32ButtonClicked:(id)sender
|
||||
{
|
||||
self.lengthSlider.integerValue = 32;
|
||||
[self.lengthSlider sendAction:self.lengthSlider.action to:self.lengthSlider.target];
|
||||
}
|
||||
|
||||
- (IBAction)preset64ButtonClicked:(id)sender
|
||||
{
|
||||
self.lengthSlider.integerValue = 64;
|
||||
[self.lengthSlider sendAction:self.lengthSlider.action to:self.lengthSlider.target];
|
||||
}
|
||||
|
||||
- (IBAction)preset128ButtonClicked:(id)sender
|
||||
{
|
||||
self.lengthSlider.integerValue = 128;
|
||||
[self.lengthSlider sendAction:self.lengthSlider.action to:self.lengthSlider.target];
|
||||
}
|
||||
|
||||
// end
|
||||
|
||||
- (IBAction)checkBoxChange:(id)sender
|
||||
{
|
||||
[self.regenerateButton sendAction:self.regenerateButton.action to:self.regenerateButton.target];
|
||||
}
|
||||
|
||||
- (IBAction)regenerateButtonClicked:(id)sender {
|
||||
NSMutableString *chars = [NSMutableString string];
|
||||
if ([self.uppercaseCheck state] == NSOnState) [chars appendString:@"ABCDEFGHIJKLMNOPQRSTUVWXYZ"];
|
||||
if ([self.lowercaseCheck state] == NSOnState) [chars appendString:@"abcdefghijklmnopqrstuvwxyz"];
|
||||
if ([self.numbersCheck state] == NSOnState) [chars appendString:@"0123456789"];
|
||||
if ([self.symbolsCheck state] == NSOnState) [chars appendString:@"!@#$%^&*"];
|
||||
|
||||
if (chars.length == 0) {
|
||||
[self.outputBox setStringValue:@""];
|
||||
return;
|
||||
}
|
||||
|
||||
NSMutableString *password = [NSMutableString stringWithCapacity:self.lengthSlider.integerValue];
|
||||
for (NSUInteger i = 0; i < self.lengthSlider.integerValue; i++) {
|
||||
uint32_t randomIndex = arc4random_uniform((uint32_t)chars.length);
|
||||
unichar c = [chars characterAtIndex:randomIndex];
|
||||
[password appendFormat:@"%C", c];
|
||||
}
|
||||
|
||||
[self.outputBox setStringValue:[password copy]];
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in new issue
Block a user