Basic recording functionality

This commit is contained in:
Owen Gretzinger
2025-07-10 13:09:32 -04:00
parent b9b1fbedd5
commit 417d751d7a
10 changed files with 738 additions and 7 deletions
+42
View File
@@ -0,0 +1,42 @@
// KeychainHelper.swift
// Helper for secure storage
import Foundation
import Security
class KeychainHelper {
static let shared = KeychainHelper()
private init() {}
func save(_ value: String, forKey key: String) -> Bool {
guard let data = value.data(using: .utf8) else { return false }
let query: [String: Any] = [
kSecClass as String: kSecClassGenericPassword,
kSecAttrAccount as String: key,
kSecValueData as String: data,
kSecAttrService as String: "owen.notetaker" // Replace with your bundle ID
]
SecItemDelete(query as CFDictionary) // Delete if exists
let status = SecItemAdd(query as CFDictionary, nil)
return status == errSecSuccess
}
func get(forKey key: String) -> String? {
let query: [String: Any] = [
kSecClass as String: kSecClassGenericPassword,
kSecAttrAccount as String: key,
kSecAttrService as String: "owen.notetaker",
kSecMatchLimit as String: kSecMatchLimitOne,
kSecReturnData as String: true
]
var item: AnyObject?
let status = SecItemCopyMatching(query as CFDictionary, &item)
guard status == errSecSuccess, let data = item as? Data else { return nil }
return String(data: data, encoding: .utf8)
}
}