diff --git a/IconDark.png b/IconDark.png new file mode 100644 index 0000000..1a69fe3 Binary files /dev/null and b/IconDark.png differ diff --git a/IconDark.pxd b/IconDark.pxd new file mode 100644 index 0000000..0a00aac Binary files /dev/null and b/IconDark.pxd differ diff --git a/IconLight.png b/IconLight.png new file mode 100644 index 0000000..bebd652 Binary files /dev/null and b/IconLight.png differ diff --git a/IconLight.pxd b/IconLight.pxd new file mode 100644 index 0000000..882c73d Binary files /dev/null and b/IconLight.pxd differ diff --git a/IconTint.png b/IconTint.png new file mode 100644 index 0000000..07f5733 Binary files /dev/null and b/IconTint.png differ diff --git a/IconTint.pxd b/IconTint.pxd new file mode 100644 index 0000000..888f4ee Binary files /dev/null and b/IconTint.pxd differ diff --git a/RNG.xcodeproj/project.pbxproj b/RNG.xcodeproj/project.pbxproj index df8ddc0..8039883 100644 --- a/RNG.xcodeproj/project.pbxproj +++ b/RNG.xcodeproj/project.pbxproj @@ -7,6 +7,8 @@ objects = { /* Begin PBXBuildFile section */ + A92723A92D300BE200D595BE /* IPView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A92723A82D300BE200D595BE /* IPView.swift */; }; + A977CC942DBBE67F00DED8C0 /* MACView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A977CC932DBBE67F00DED8C0 /* MACView.swift */; }; A9794C832CB70ADA00527984 /* RNGApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9794C822CB70ADA00527984 /* RNGApp.swift */; }; A9794C852CB70ADA00527984 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9794C842CB70ADA00527984 /* ContentView.swift */; }; A9794C872CB70AE100527984 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A9794C862CB70AE100527984 /* Assets.xcassets */; }; @@ -17,6 +19,8 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + A92723A82D300BE200D595BE /* IPView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IPView.swift; sourceTree = ""; }; + A977CC932DBBE67F00DED8C0 /* MACView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MACView.swift; sourceTree = ""; }; A9794C7F2CB70ADA00527984 /* RNG.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = RNG.app; sourceTree = BUILT_PRODUCTS_DIR; }; A9794C822CB70ADA00527984 /* RNGApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RNGApp.swift; sourceTree = ""; }; A9794C842CB70ADA00527984 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; @@ -63,6 +67,8 @@ A9794C952CB70C8000527984 /* PasswordView.swift */, A9794C912CB70BF600527984 /* DiceView.swift */, A9794C932CB70C1400527984 /* NumberView.swift */, + A92723A82D300BE200D595BE /* IPView.swift */, + A977CC932DBBE67F00DED8C0 /* MACView.swift */, A9794C862CB70AE100527984 /* Assets.xcassets */, A9794C882CB70AE100527984 /* RNG.entitlements */, A9794C892CB70AE100527984 /* Preview Content */, @@ -106,7 +112,7 @@ attributes = { BuildIndependentTargetsInParallel = 1; LastSwiftUpdateCheck = 1540; - LastUpgradeCheck = 1540; + LastUpgradeCheck = 1620; TargetAttributes = { A9794C7E2CB70ADA00527984 = { CreatedOnToolsVersion = 15.4; @@ -149,9 +155,11 @@ buildActionMask = 2147483647; files = ( A9794C962CB70C8000527984 /* PasswordView.swift in Sources */, + A92723A92D300BE200D595BE /* IPView.swift in Sources */, A9794C852CB70ADA00527984 /* ContentView.swift in Sources */, A9794C922CB70BF600527984 /* DiceView.swift in Sources */, A9794C942CB70C1400527984 /* NumberView.swift in Sources */, + A977CC942DBBE67F00DED8C0 /* MACView.swift in Sources */, A9794C832CB70ADA00527984 /* RNGApp.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -193,6 +201,7 @@ CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; + DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = dwarf; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; @@ -254,6 +263,7 @@ CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; + DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; @@ -281,8 +291,9 @@ CODE_SIGN_ENTITLEMENTS = RNG/RNG.entitlements; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; + DEAD_CODE_STRIPPING = YES; DEVELOPMENT_ASSET_PATHS = "\"RNG/Preview Content\""; - DEVELOPMENT_TEAM = 8626DL2GW3; + DEVELOPMENT_TEAM = 8JGND254B7; ENABLE_HARDENED_RUNTIME = YES; ENABLE_PREVIEWS = YES; GENERATE_INFOPLIST_FILE = YES; @@ -304,7 +315,9 @@ PRODUCT_BUNDLE_IDENTIFIER = com.neon443.RNG; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = auto; - SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx"; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; + SUPPORTS_MACCATALYST = NO; + SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES; SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; @@ -319,8 +332,9 @@ CODE_SIGN_ENTITLEMENTS = RNG/RNG.entitlements; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; + DEAD_CODE_STRIPPING = YES; DEVELOPMENT_ASSET_PATHS = "\"RNG/Preview Content\""; - DEVELOPMENT_TEAM = 8626DL2GW3; + DEVELOPMENT_TEAM = 8JGND254B7; ENABLE_HARDENED_RUNTIME = YES; ENABLE_PREVIEWS = YES; GENERATE_INFOPLIST_FILE = YES; @@ -342,7 +356,9 @@ PRODUCT_BUNDLE_IDENTIFIER = com.neon443.RNG; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = auto; - SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx"; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; + SUPPORTS_MACCATALYST = NO; + SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES; SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; diff --git a/RNG.xcodeproj/xcshareddata/xcschemes/RNG-noDebug.xcscheme b/RNG.xcodeproj/xcshareddata/xcschemes/RNG-noDebug.xcscheme index 7361d06..1d3eef5 100644 --- a/RNG.xcodeproj/xcshareddata/xcschemes/RNG-noDebug.xcscheme +++ b/RNG.xcodeproj/xcshareddata/xcschemes/RNG-noDebug.xcscheme @@ -1,6 +1,6 @@ String { + let randomNumber = Int.random(in: 0..<256) + let randomNumber2 = Int.random(in: 0..<256) + let randomNumber3 = Int.random(in: 0..<256) + let randomNumber4 = Int.random(in: 0..<256) + switch type { + case 4: + return "\(randomNumber).\(randomNumber2).\(randomNumber3).\(randomNumber4)" + case 6: + for _ in 0..<6 { + for _ in 0..<4 { + let randomChar = Int.random(in: 0..<10) + print(randomChar) + } + } + // eg: fd7a:115c:a1e0:0000:6501:6f07 + return "unimplemenented" + default: + return "" + } +} + +#Preview { + IPView() +} diff --git a/RNG/MACView.swift b/RNG/MACView.swift new file mode 100644 index 0000000..5fad525 --- /dev/null +++ b/RNG/MACView.swift @@ -0,0 +1,122 @@ +// +// IPView.swift +// RNG +// +// Created by Nihaal Sharma on 09/01/2025. +// + +import Foundation +import SwiftUI + +struct MACView: View { + @State var mac: String = "" + @State var maclook: String = "" + var body: some View { + Button("test") { + mac = "1c:57:dc:7f:d4:ce" + Task { + maclook = await maclookup(mac) + } + } + + List { + HStack { + Label("Vendor", systemImage: "building.2.fill") + Spacer() + Text(maclook) + .bold() + } + } + + Text(mac) + .font(.system(size: 30)) + .foregroundColor(.gray) + .frame(height: 40) + .contentTransition(.numericText()) + .monospaced() + Button { + withAnimation { + mac = generateMAC() + } + Task { + maclook = await maclookup(mac) + } + } label: { + Text("Generate") + .padding(.horizontal) + .font(.system(size: 25)) + .monospaced() + } + .buttonStyle(BorderedProminentButtonStyle()) + .cornerRadius(15) + .padding(.vertical) + } +} + +func generateMAC() -> String { + var output = "" + for _ in 0..<6 { + output.append(hex(Int.random(in: 0...15)).hex) + output.append(hex(rng(min: 0, max: 15)).hex) + output.append(":") + } + output.removeLast() + return output +} + +func maclookup(_ mac: String) async -> String { + let url = URL(string: "https://api.macvendors.com/\(mac)")! + var request = URLRequest(url: url) + request.httpMethod = "GET" + + do { + let (data, _) = try await URLSession(configuration: .ephemeral).data(for: request) + let result = String(data: data, encoding: .utf8) ?? "Lookup Error" + if result.contains("{") { + let dict = try JSONDecoder().decode([String: [String: String]].self, from: data) + if let dict = dict["error"] { + print(dict["detail"] as Any) + } + } + + return "sd" + } catch { + print(error.localizedDescription) + return "Lookup Error" + } +} + +class hex { + @Published var hex: String + init(_ int: Int) { + switch int { + case 16...Int.max: + self.hex = "F" + case Int.min...(-1): + self.hex = "0" + + case 10: + self.hex = "A" + case 11: + self.hex = "B" + case 12: + self.hex = "C" + case 13: + self.hex = "D" + case 14: + self.hex = "E" + case 15: + self.hex = "F" + + case 0...15: + self.hex = "\(int)" + + default: + self.hex = "0" + } + self.hex = self.hex.lowercased() + } +} +#Preview { + MACView() +} diff --git a/RNG/NumberView.swift b/RNG/NumberView.swift index 30d150c..c5e4b6e 100644 --- a/RNG/NumberView.swift +++ b/RNG/NumberView.swift @@ -52,16 +52,19 @@ struct NumberView: View { } } Text(generated) - .font(.system(size: 50, weight: .bold)) + .font(.system(size: 50)) .foregroundColor(.gray) .frame(height: 40) + .contentTransition(.numericText()) Button { - prevGen = generated - generated = rng3(min: low, max: high, exclude: exclude) + withAnimation { + prevGen = generated + generated = rng3(min: low, max: high, exclude: exclude) + } } label: { Text("Generate") .padding(.horizontal) - .font(.system(size: 25, weight: .bold)) + .font(.system(size: 25)) } .buttonStyle(BorderedProminentButtonStyle()) .cornerRadius(15) diff --git a/RNG/PasswordView.swift b/RNG/PasswordView.swift index af7dc55..13e31f9 100644 --- a/RNG/PasswordView.swift +++ b/RNG/PasswordView.swift @@ -59,16 +59,19 @@ struct PasswordView: View { } Text(String(generated)) - .font(.system(size: 50, weight: .bold)) + .font(.system(size: 50)) .foregroundColor(.gray) .frame(height: 40) + .contentTransition(.numericText()) Button { - generated = genPass(selectdOpts: selectedOptions, len: (presetLen == -1 ? customLen : presetLen)) + withAnimation { + generated = genPass(selectdOpts: selectedOptions, len: (presetLen == -1 ? customLen : presetLen)) + } } label: { Text("Generate") .padding(.horizontal) - .font(.system(size: 25, weight: .bold)) + .font(.system(size: 25)) } .buttonStyle(BorderedProminentButtonStyle()) .cornerRadius(15)