mirror of
https://github.com/neon443/RNG_Swift.git
synced 2026-03-11 06:49:12 +00:00
add ip and mac addr
animated the changes
This commit is contained in:
BIN
IconDark.png
Normal file
BIN
IconDark.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 115 KiB |
BIN
IconDark.pxd
Normal file
BIN
IconDark.pxd
Normal file
Binary file not shown.
BIN
IconLight.png
Normal file
BIN
IconLight.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 137 KiB |
BIN
IconLight.pxd
Normal file
BIN
IconLight.pxd
Normal file
Binary file not shown.
BIN
IconTint.png
Normal file
BIN
IconTint.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 47 KiB |
BIN
IconTint.pxd
Normal file
BIN
IconTint.pxd
Normal file
Binary file not shown.
@@ -7,6 +7,8 @@
|
|||||||
objects = {
|
objects = {
|
||||||
|
|
||||||
/* Begin PBXBuildFile section */
|
/* 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 */; };
|
A9794C832CB70ADA00527984 /* RNGApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9794C822CB70ADA00527984 /* RNGApp.swift */; };
|
||||||
A9794C852CB70ADA00527984 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9794C842CB70ADA00527984 /* ContentView.swift */; };
|
A9794C852CB70ADA00527984 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9794C842CB70ADA00527984 /* ContentView.swift */; };
|
||||||
A9794C872CB70AE100527984 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A9794C862CB70AE100527984 /* Assets.xcassets */; };
|
A9794C872CB70AE100527984 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A9794C862CB70AE100527984 /* Assets.xcassets */; };
|
||||||
@@ -17,6 +19,8 @@
|
|||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
/* Begin PBXFileReference section */
|
/* Begin PBXFileReference section */
|
||||||
|
A92723A82D300BE200D595BE /* IPView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IPView.swift; sourceTree = "<group>"; };
|
||||||
|
A977CC932DBBE67F00DED8C0 /* MACView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MACView.swift; sourceTree = "<group>"; };
|
||||||
A9794C7F2CB70ADA00527984 /* RNG.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = RNG.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
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 = "<group>"; };
|
A9794C822CB70ADA00527984 /* RNGApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RNGApp.swift; sourceTree = "<group>"; };
|
||||||
A9794C842CB70ADA00527984 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
|
A9794C842CB70ADA00527984 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
|
||||||
@@ -63,6 +67,8 @@
|
|||||||
A9794C952CB70C8000527984 /* PasswordView.swift */,
|
A9794C952CB70C8000527984 /* PasswordView.swift */,
|
||||||
A9794C912CB70BF600527984 /* DiceView.swift */,
|
A9794C912CB70BF600527984 /* DiceView.swift */,
|
||||||
A9794C932CB70C1400527984 /* NumberView.swift */,
|
A9794C932CB70C1400527984 /* NumberView.swift */,
|
||||||
|
A92723A82D300BE200D595BE /* IPView.swift */,
|
||||||
|
A977CC932DBBE67F00DED8C0 /* MACView.swift */,
|
||||||
A9794C862CB70AE100527984 /* Assets.xcassets */,
|
A9794C862CB70AE100527984 /* Assets.xcassets */,
|
||||||
A9794C882CB70AE100527984 /* RNG.entitlements */,
|
A9794C882CB70AE100527984 /* RNG.entitlements */,
|
||||||
A9794C892CB70AE100527984 /* Preview Content */,
|
A9794C892CB70AE100527984 /* Preview Content */,
|
||||||
@@ -106,7 +112,7 @@
|
|||||||
attributes = {
|
attributes = {
|
||||||
BuildIndependentTargetsInParallel = 1;
|
BuildIndependentTargetsInParallel = 1;
|
||||||
LastSwiftUpdateCheck = 1540;
|
LastSwiftUpdateCheck = 1540;
|
||||||
LastUpgradeCheck = 1540;
|
LastUpgradeCheck = 1620;
|
||||||
TargetAttributes = {
|
TargetAttributes = {
|
||||||
A9794C7E2CB70ADA00527984 = {
|
A9794C7E2CB70ADA00527984 = {
|
||||||
CreatedOnToolsVersion = 15.4;
|
CreatedOnToolsVersion = 15.4;
|
||||||
@@ -149,9 +155,11 @@
|
|||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
A9794C962CB70C8000527984 /* PasswordView.swift in Sources */,
|
A9794C962CB70C8000527984 /* PasswordView.swift in Sources */,
|
||||||
|
A92723A92D300BE200D595BE /* IPView.swift in Sources */,
|
||||||
A9794C852CB70ADA00527984 /* ContentView.swift in Sources */,
|
A9794C852CB70ADA00527984 /* ContentView.swift in Sources */,
|
||||||
A9794C922CB70BF600527984 /* DiceView.swift in Sources */,
|
A9794C922CB70BF600527984 /* DiceView.swift in Sources */,
|
||||||
A9794C942CB70C1400527984 /* NumberView.swift in Sources */,
|
A9794C942CB70C1400527984 /* NumberView.swift in Sources */,
|
||||||
|
A977CC942DBBE67F00DED8C0 /* MACView.swift in Sources */,
|
||||||
A9794C832CB70ADA00527984 /* RNGApp.swift in Sources */,
|
A9794C832CB70ADA00527984 /* RNGApp.swift in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
@@ -193,6 +201,7 @@
|
|||||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||||
COPY_PHASE_STRIP = NO;
|
COPY_PHASE_STRIP = NO;
|
||||||
|
DEAD_CODE_STRIPPING = YES;
|
||||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||||
ENABLE_TESTABILITY = YES;
|
ENABLE_TESTABILITY = YES;
|
||||||
@@ -254,6 +263,7 @@
|
|||||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||||
COPY_PHASE_STRIP = NO;
|
COPY_PHASE_STRIP = NO;
|
||||||
|
DEAD_CODE_STRIPPING = YES;
|
||||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||||
ENABLE_NS_ASSERTIONS = NO;
|
ENABLE_NS_ASSERTIONS = NO;
|
||||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||||
@@ -281,8 +291,9 @@
|
|||||||
CODE_SIGN_ENTITLEMENTS = RNG/RNG.entitlements;
|
CODE_SIGN_ENTITLEMENTS = RNG/RNG.entitlements;
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
CURRENT_PROJECT_VERSION = 1;
|
CURRENT_PROJECT_VERSION = 1;
|
||||||
|
DEAD_CODE_STRIPPING = YES;
|
||||||
DEVELOPMENT_ASSET_PATHS = "\"RNG/Preview Content\"";
|
DEVELOPMENT_ASSET_PATHS = "\"RNG/Preview Content\"";
|
||||||
DEVELOPMENT_TEAM = 8626DL2GW3;
|
DEVELOPMENT_TEAM = 8JGND254B7;
|
||||||
ENABLE_HARDENED_RUNTIME = YES;
|
ENABLE_HARDENED_RUNTIME = YES;
|
||||||
ENABLE_PREVIEWS = YES;
|
ENABLE_PREVIEWS = YES;
|
||||||
GENERATE_INFOPLIST_FILE = YES;
|
GENERATE_INFOPLIST_FILE = YES;
|
||||||
@@ -304,7 +315,9 @@
|
|||||||
PRODUCT_BUNDLE_IDENTIFIER = com.neon443.RNG;
|
PRODUCT_BUNDLE_IDENTIFIER = com.neon443.RNG;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
SDKROOT = auto;
|
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_EMIT_LOC_STRINGS = YES;
|
||||||
SWIFT_VERSION = 5.0;
|
SWIFT_VERSION = 5.0;
|
||||||
TARGETED_DEVICE_FAMILY = "1,2";
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
@@ -319,8 +332,9 @@
|
|||||||
CODE_SIGN_ENTITLEMENTS = RNG/RNG.entitlements;
|
CODE_SIGN_ENTITLEMENTS = RNG/RNG.entitlements;
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
CURRENT_PROJECT_VERSION = 1;
|
CURRENT_PROJECT_VERSION = 1;
|
||||||
|
DEAD_CODE_STRIPPING = YES;
|
||||||
DEVELOPMENT_ASSET_PATHS = "\"RNG/Preview Content\"";
|
DEVELOPMENT_ASSET_PATHS = "\"RNG/Preview Content\"";
|
||||||
DEVELOPMENT_TEAM = 8626DL2GW3;
|
DEVELOPMENT_TEAM = 8JGND254B7;
|
||||||
ENABLE_HARDENED_RUNTIME = YES;
|
ENABLE_HARDENED_RUNTIME = YES;
|
||||||
ENABLE_PREVIEWS = YES;
|
ENABLE_PREVIEWS = YES;
|
||||||
GENERATE_INFOPLIST_FILE = YES;
|
GENERATE_INFOPLIST_FILE = YES;
|
||||||
@@ -342,7 +356,9 @@
|
|||||||
PRODUCT_BUNDLE_IDENTIFIER = com.neon443.RNG;
|
PRODUCT_BUNDLE_IDENTIFIER = com.neon443.RNG;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
SDKROOT = auto;
|
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_EMIT_LOC_STRINGS = YES;
|
||||||
SWIFT_VERSION = 5.0;
|
SWIFT_VERSION = 5.0;
|
||||||
TARGETED_DEVICE_FAMILY = "1,2";
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<Scheme
|
<Scheme
|
||||||
LastUpgradeVersion = "1610"
|
LastUpgradeVersion = "1620"
|
||||||
version = "1.7">
|
version = "1.7">
|
||||||
<BuildAction
|
<BuildAction
|
||||||
parallelizeBuildables = "YES"
|
parallelizeBuildables = "YES"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<Scheme
|
<Scheme
|
||||||
LastUpgradeVersion = "1540"
|
LastUpgradeVersion = "1620"
|
||||||
version = "1.7">
|
version = "1.7">
|
||||||
<BuildAction
|
<BuildAction
|
||||||
parallelizeBuildables = "YES"
|
parallelizeBuildables = "YES"
|
||||||
|
|||||||
@@ -1,6 +1,31 @@
|
|||||||
{
|
{
|
||||||
"images" : [
|
"images" : [
|
||||||
{
|
{
|
||||||
|
"filename" : "IconLight.png",
|
||||||
|
"idiom" : "universal",
|
||||||
|
"platform" : "ios",
|
||||||
|
"size" : "1024x1024"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"appearances" : [
|
||||||
|
{
|
||||||
|
"appearance" : "luminosity",
|
||||||
|
"value" : "dark"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"filename" : "IconDark.png",
|
||||||
|
"idiom" : "universal",
|
||||||
|
"platform" : "ios",
|
||||||
|
"size" : "1024x1024"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"appearances" : [
|
||||||
|
{
|
||||||
|
"appearance" : "luminosity",
|
||||||
|
"value" : "tinted"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"filename" : "IconTint.png",
|
||||||
"idiom" : "universal",
|
"idiom" : "universal",
|
||||||
"platform" : "ios",
|
"platform" : "ios",
|
||||||
"size" : "1024x1024"
|
"size" : "1024x1024"
|
||||||
|
|||||||
BIN
RNG/Assets.xcassets/AppIcon.appiconset/IconDark.png
Normal file
BIN
RNG/Assets.xcassets/AppIcon.appiconset/IconDark.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 115 KiB |
BIN
RNG/Assets.xcassets/AppIcon.appiconset/IconLight.png
Normal file
BIN
RNG/Assets.xcassets/AppIcon.appiconset/IconLight.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 137 KiB |
BIN
RNG/Assets.xcassets/AppIcon.appiconset/IconTint.png
Normal file
BIN
RNG/Assets.xcassets/AppIcon.appiconset/IconTint.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 47 KiB |
@@ -48,6 +48,24 @@ struct ContentView: View {
|
|||||||
Image(systemName: "rectangle.and.pencil.and.ellipsis")
|
Image(systemName: "rectangle.and.pencil.and.ellipsis")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
NavigationLink() {
|
||||||
|
IPView()
|
||||||
|
} label: {
|
||||||
|
HStack {
|
||||||
|
Text("IP Adresses")
|
||||||
|
Spacer()
|
||||||
|
Image(systemName: "network")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
NavigationLink() {
|
||||||
|
MACView()
|
||||||
|
} label: {
|
||||||
|
HStack {
|
||||||
|
Text("MAC Adresses")
|
||||||
|
Spacer()
|
||||||
|
Image(systemName: "antenna.radiowaves.left.and.right")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.navigationTitle("RNG")
|
.navigationTitle("RNG")
|
||||||
.navigationBarTitleDisplayMode(.inline)
|
.navigationBarTitleDisplayMode(.inline)
|
||||||
|
|||||||
@@ -71,22 +71,25 @@ struct DiceView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Text(String(result))
|
Text(String(result))
|
||||||
.font(.system(size: 50, weight: .bold))
|
.font(.system(size: 50))
|
||||||
.foregroundColor(.gray)
|
.foregroundColor(.gray)
|
||||||
.frame(height: 40)
|
.frame(height: 40)
|
||||||
|
.contentTransition(.numericText())
|
||||||
Text(resultDescription)
|
Text(resultDescription)
|
||||||
.frame(height: 10)
|
.frame(height: 10)
|
||||||
.font(.system(size: 10))
|
.font(.system(size: 10))
|
||||||
Button {
|
Button {
|
||||||
generated = rngN6DieArr(dies: Int(dies))
|
withAnimation {
|
||||||
displayDies = generated
|
generated = rngN6DieArr(dies: Int(dies))
|
||||||
displayMultiDieMode = multiDieMode
|
displayDies = generated
|
||||||
result = arrCombine(arr: generated, combineMode: multiDieMode)
|
displayMultiDieMode = multiDieMode
|
||||||
resultDescription = describeResult(inp: displayDies, combineMode: multiDieMode)
|
result = arrCombine(arr: generated, combineMode: multiDieMode)
|
||||||
|
resultDescription = describeResult(inp: displayDies, combineMode: multiDieMode)
|
||||||
|
}
|
||||||
} label: {
|
} label: {
|
||||||
Text("Generate")
|
Text("Generate")
|
||||||
.padding(.horizontal)
|
.padding(.horizontal)
|
||||||
.font(.system(size: 25, weight: .bold))
|
.font(.system(size: 25))
|
||||||
}
|
}
|
||||||
.buttonStyle(BorderedProminentButtonStyle())
|
.buttonStyle(BorderedProminentButtonStyle())
|
||||||
.cornerRadius(15)
|
.cornerRadius(15)
|
||||||
|
|||||||
63
RNG/IPView.swift
Normal file
63
RNG/IPView.swift
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
//
|
||||||
|
// IPView.swift
|
||||||
|
// RNG
|
||||||
|
//
|
||||||
|
// Created by Nihaal Sharma on 09/01/2025.
|
||||||
|
//
|
||||||
|
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
struct IPView: View {
|
||||||
|
@State var ipType = 4
|
||||||
|
@State var ip: String = ""
|
||||||
|
var body: some View {
|
||||||
|
List {
|
||||||
|
Picker("IP Version", selection: $ipType) {
|
||||||
|
Text("IPv4").tag(4)
|
||||||
|
Text("IPv6").tag(6)
|
||||||
|
}
|
||||||
|
.pickerStyle(SegmentedPickerStyle())
|
||||||
|
Text(ip)
|
||||||
|
.contentTransition(.numericText())
|
||||||
|
}
|
||||||
|
Button {
|
||||||
|
withAnimation {
|
||||||
|
ip = generateIPv(ipType)
|
||||||
|
}
|
||||||
|
} label: {
|
||||||
|
Text("Generate")
|
||||||
|
.padding(.horizontal)
|
||||||
|
.font(.system(size: 25))
|
||||||
|
.monospaced()
|
||||||
|
}
|
||||||
|
.buttonStyle(BorderedProminentButtonStyle())
|
||||||
|
.cornerRadius(15)
|
||||||
|
.padding(.vertical)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func generateIPv(_ type: Int) -> 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()
|
||||||
|
}
|
||||||
122
RNG/MACView.swift
Normal file
122
RNG/MACView.swift
Normal file
@@ -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()
|
||||||
|
}
|
||||||
@@ -52,16 +52,19 @@ struct NumberView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Text(generated)
|
Text(generated)
|
||||||
.font(.system(size: 50, weight: .bold))
|
.font(.system(size: 50))
|
||||||
.foregroundColor(.gray)
|
.foregroundColor(.gray)
|
||||||
.frame(height: 40)
|
.frame(height: 40)
|
||||||
|
.contentTransition(.numericText())
|
||||||
Button {
|
Button {
|
||||||
prevGen = generated
|
withAnimation {
|
||||||
generated = rng3(min: low, max: high, exclude: exclude)
|
prevGen = generated
|
||||||
|
generated = rng3(min: low, max: high, exclude: exclude)
|
||||||
|
}
|
||||||
} label: {
|
} label: {
|
||||||
Text("Generate")
|
Text("Generate")
|
||||||
.padding(.horizontal)
|
.padding(.horizontal)
|
||||||
.font(.system(size: 25, weight: .bold))
|
.font(.system(size: 25))
|
||||||
}
|
}
|
||||||
.buttonStyle(BorderedProminentButtonStyle())
|
.buttonStyle(BorderedProminentButtonStyle())
|
||||||
.cornerRadius(15)
|
.cornerRadius(15)
|
||||||
|
|||||||
@@ -59,16 +59,19 @@ struct PasswordView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Text(String(generated))
|
Text(String(generated))
|
||||||
.font(.system(size: 50, weight: .bold))
|
.font(.system(size: 50))
|
||||||
.foregroundColor(.gray)
|
.foregroundColor(.gray)
|
||||||
.frame(height: 40)
|
.frame(height: 40)
|
||||||
|
.contentTransition(.numericText())
|
||||||
|
|
||||||
Button {
|
Button {
|
||||||
generated = genPass(selectdOpts: selectedOptions, len: (presetLen == -1 ? customLen : presetLen))
|
withAnimation {
|
||||||
|
generated = genPass(selectdOpts: selectedOptions, len: (presetLen == -1 ? customLen : presetLen))
|
||||||
|
}
|
||||||
} label: {
|
} label: {
|
||||||
Text("Generate")
|
Text("Generate")
|
||||||
.padding(.horizontal)
|
.padding(.horizontal)
|
||||||
.font(.system(size: 25, weight: .bold))
|
.font(.system(size: 25))
|
||||||
}
|
}
|
||||||
.buttonStyle(BorderedProminentButtonStyle())
|
.buttonStyle(BorderedProminentButtonStyle())
|
||||||
.cornerRadius(15)
|
.cornerRadius(15)
|
||||||
|
|||||||
Reference in New Issue
Block a user