Initial Commit
This commit is contained in:
11 files changed
+997
No files matched your search
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"colors" : [
|
||||
{
|
||||
"idiom" : "universal"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"platform" : "ios",
|
||||
"size" : "1024x1024"
|
||||
},
|
||||
{
|
||||
"appearances" : [
|
||||
{
|
||||
"appearance" : "luminosity",
|
||||
"value" : "dark"
|
||||
}
|
||||
],
|
||||
"idiom" : "universal",
|
||||
"platform" : "ios",
|
||||
"size" : "1024x1024"
|
||||
},
|
||||
{
|
||||
"appearances" : [
|
||||
{
|
||||
"appearance" : "luminosity",
|
||||
"value" : "tinted"
|
||||
}
|
||||
],
|
||||
"idiom" : "universal",
|
||||
"platform" : "ios",
|
||||
"size" : "1024x1024"
|
||||
},
|
||||
{
|
||||
"idiom" : "mac",
|
||||
"scale" : "1x",
|
||||
"size" : "16x16"
|
||||
},
|
||||
{
|
||||
"idiom" : "mac",
|
||||
"scale" : "2x",
|
||||
"size" : "16x16"
|
||||
},
|
||||
{
|
||||
"idiom" : "mac",
|
||||
"scale" : "1x",
|
||||
"size" : "32x32"
|
||||
},
|
||||
{
|
||||
"idiom" : "mac",
|
||||
"scale" : "2x",
|
||||
"size" : "32x32"
|
||||
},
|
||||
{
|
||||
"idiom" : "mac",
|
||||
"scale" : "1x",
|
||||
"size" : "128x128"
|
||||
},
|
||||
{
|
||||
"idiom" : "mac",
|
||||
"scale" : "2x",
|
||||
"size" : "128x128"
|
||||
},
|
||||
{
|
||||
"idiom" : "mac",
|
||||
"scale" : "1x",
|
||||
"size" : "256x256"
|
||||
},
|
||||
{
|
||||
"idiom" : "mac",
|
||||
"scale" : "2x",
|
||||
"size" : "256x256"
|
||||
},
|
||||
{
|
||||
"idiom" : "mac",
|
||||
"scale" : "1x",
|
||||
"size" : "512x512"
|
||||
},
|
||||
{
|
||||
"idiom" : "mac",
|
||||
"scale" : "2x",
|
||||
"size" : "512x512"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
//
|
||||
// ContentView.swift
|
||||
// Password Generator
|
||||
//
|
||||
// Created by Travis Harbin on 8/29/26.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import Foundation
|
||||
#if os(macOS)
|
||||
import AppKit
|
||||
#else
|
||||
import UIKit
|
||||
#endif
|
||||
|
||||
func copyToClipboard(text: String) {
|
||||
#if os(macOS)
|
||||
let pasteboard = NSPasteboard.general
|
||||
pasteboard.clearContents()
|
||||
pasteboard.setString(text, forType: .string)
|
||||
#else
|
||||
UIPasteboard.general.string = text
|
||||
#endif
|
||||
}
|
||||
|
||||
struct ContentView: View {
|
||||
@State private var length: Int = 8
|
||||
@State private var useUppercase: Bool = true
|
||||
@State private var useLowercase: Bool = true
|
||||
@State private var useNumbers: Bool = true
|
||||
@State private var useSymbols: Bool = true
|
||||
@State private var password: String = ""
|
||||
|
||||
let charsUpper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
let charsLower = "abcdefghijklmnopqrstuvwxyz"
|
||||
let charsNumber = "0123456789"
|
||||
let charsSymbols = "!@#$%^&*"
|
||||
|
||||
func generatePassword() {
|
||||
let chars =
|
||||
(useUppercase ? charsUpper : "") +
|
||||
(useLowercase ? charsLower : "") +
|
||||
(useNumbers ? charsNumber : "") +
|
||||
(useSymbols ? charsSymbols : "")
|
||||
|
||||
if chars.isEmpty {
|
||||
password = ""
|
||||
return
|
||||
}
|
||||
|
||||
password = String(
|
||||
(0..<length).compactMap { _ in
|
||||
chars.randomElement()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
Text("Password Generator")
|
||||
.font(.title)
|
||||
.fontWeight(.bold)
|
||||
Text("Select a length, or use the slider for a custom value")
|
||||
|
||||
Text("Password Length: " + String(length)).padding(.top)
|
||||
Slider(
|
||||
value: Binding(
|
||||
get: { Double(length) },
|
||||
set: { length = Int($0) }
|
||||
),
|
||||
in: 1...500
|
||||
).onChange(of: length) { generatePassword() }
|
||||
|
||||
HStack {
|
||||
Button("8") {
|
||||
length = 8
|
||||
}
|
||||
.buttonStyle(.bordered)
|
||||
Button("16") {
|
||||
length = 16
|
||||
}
|
||||
.buttonStyle(.bordered)
|
||||
Button("32") {
|
||||
length = 32
|
||||
}
|
||||
.buttonStyle(.bordered)
|
||||
Button("64") {
|
||||
length = 64
|
||||
}
|
||||
.buttonStyle(.bordered)
|
||||
Button("128") {
|
||||
length = 128
|
||||
}
|
||||
.buttonStyle(.bordered)
|
||||
}
|
||||
|
||||
Text("Characters to use").padding()
|
||||
LazyVGrid(
|
||||
columns: [
|
||||
GridItem(.adaptive(minimum: 180))
|
||||
]
|
||||
) {
|
||||
Toggle("Use uppercase", isOn: $useUppercase)
|
||||
.onChange(of: useUppercase) { generatePassword() }
|
||||
Toggle("Use lowercase", isOn: $useLowercase)
|
||||
.onChange(of: useLowercase) { generatePassword() }
|
||||
Toggle("Use numbers", isOn: $useNumbers)
|
||||
.onChange(of: useNumbers) { generatePassword() }
|
||||
Toggle("Use symbols", isOn: $useSymbols)
|
||||
.onChange(of: useSymbols) { generatePassword() }
|
||||
}
|
||||
.frame(maxWidth: 925)
|
||||
|
||||
HStack {
|
||||
Button("Copy") {
|
||||
copyToClipboard(text: password)
|
||||
}
|
||||
.buttonStyle(.bordered)
|
||||
Button("Regenerate") {
|
||||
generatePassword()
|
||||
}
|
||||
.buttonStyle(.bordered)
|
||||
}
|
||||
.padding()
|
||||
|
||||
Text(password)
|
||||
.textSelection(.enabled)
|
||||
.multilineTextAlignment(.center)
|
||||
|
||||
Spacer()
|
||||
}
|
||||
.padding()
|
||||
.onAppear {
|
||||
generatePassword()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
ContentView()
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// Password_GeneratorApp.swift
|
||||
// Password Generator
|
||||
//
|
||||
// Created by Travis Harbin on 8/29/26.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
@main
|
||||
struct Password_GeneratorApp: App {
|
||||
var body: some Scene {
|
||||
WindowGroup {
|
||||
ContentView()
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user