A native, secure, and modern 2FA (Two-Factor Authentication) app built with SwiftUI for macOS.
- TOTP Code Generation - Generate time-based one-time passwords (6 or 8 digits)
- Advanced QR Code Scanning - Multiple scanning methods with enhanced detection
- Google Authenticator Migration - Import accounts from Google Authenticator export QR codes
- Manual Entry - Add accounts by entering secret keys manually
- Multiple Algorithms - Support for SHA1, SHA256, and SHA512
- Bulk Account Management - Select and delete multiple accounts at once
- Keychain Storage - All secrets are securely stored in macOS Keychain with device-only access
- Offline Operation - No internet connection required, all codes generated locally
- Native Settings Integration - Secure preferences with macOS Settings window
- Native macOS Design - Built with SwiftUI for a modern Mac experience
- Account Management - Add, edit, delete, search, and reorder accounts
- Enhanced Search & Filter - Quickly find accounts by name or issuer
- One-Click Copy - Copy codes to clipboard instantly with visual feedback
- Dynamic Visual Indicators - Color-coded progress bars (green → orange → red)
- Dark Mode Support - Automatic theme switching
- Keyboard Shortcuts - Cmd+N to add account, Cmd+, for Settings, Escape to cancel
- Empty State Views - Helpful guidance when no accounts exist
- macOS 13.0 (Ventura) or later
- Xcode 15.0 or later (for building from source)
-
Clone the repository:
git clone https://github.com/brutalharsh/TwoFactorAuth.git cd TwoFactorAuth -
Open in Xcode:
- Open Xcode
- File → Open → Select the
TwoFactorAuthfolder - Create a new macOS App project with SwiftUI
- Replace the generated files with the source files
-
Configure the project:
- Set the bundle identifier (e.g.,
com.yourname.TwoFactorAuth) - Enable Camera usage in Capabilities
- Enable Keychain Sharing if needed
- Set the bundle identifier (e.g.,
-
Build and Run:
- Press
Cmd + Rto build and run - Or Archive → Distribute App for release build
- Press
chmod +x build.sh
./build.shMethod 1: QR Code Scanning The QR scanner now offers multiple capture methods:
-
Live Camera Scanning
- Click the QR code scanner button in the toolbar
- Allow camera access when prompted
- Point the camera at the QR code
- Click the "Capture QR Code" button to scan
-
Upload QR Code Image
- In the QR scanner, click "Upload Image"
- Select a QR code image file from your computer
- The app will automatically detect and process the QR code
-
Screenshot Capture
- In the QR scanner, click "Capture Screenshot"
- The app will scan your screen for any visible QR codes
- Useful for QR codes displayed on your screen
Method 2: Google Authenticator Migration
- In Google Authenticator, go to Settings → Transfer accounts → Export accounts
- Scan the migration QR code using any of the methods above
- All accounts will be imported at once
Method 3: Manual Entry
- Click the "+" button in the toolbar
- Enter the service name (e.g., "GitHub")
- Enter your account name or email
- Paste or type the secret key
- Optionally configure:
- Algorithm (SHA1, SHA256, SHA512)
- Digits (6 or 8)
- Period (default 30 seconds)
- Click "Add Account"
Method 4: Import from URI
- Copy an
otpauth://URI to clipboard - The app will automatically detect and offer to import it
- View Code: Select an account from the sidebar
- Copy Code: Click the copy button or use right-click menu
- Edit Account: Right-click → Edit or use the Edit button
- Delete Account: Right-click → Delete or swipe left
- Bulk Delete: Click "Select" → Choose multiple accounts → Delete
- Reorder Accounts: Use up/down buttons to rearrange account order
- Search: Use the search bar to filter by account name or issuer
- Track Usage: Accounts show when they were last used
Access the Settings window via Cmd+, or Menu → Settings:
General Tab
- Toggle Touch ID preference (UI only)
- Configure menu bar code display
Security Tab
- Clear all accounts with confirmation
About Tab
- View app version and information
- Keychain Storage: All secret keys are stored in the macOS Keychain with
kSecAttrAccessibleWhenUnlockedThisDeviceOnlyflag - No Network Access: The app works completely offline
- Device-Only Access: Secrets are only accessible when device is unlocked
- No Cloud Sync: All data remains local to your device
- Go to System Settings → Privacy & Security → Camera
- Ensure TwoFactorAuth has permission enabled
- Try using "Upload Image" or "Capture Screenshot" as alternatives
- Manual Capture Required: The app uses manual capture mode - click "Capture QR Code" button
- Poor Quality QR: Try the image enhancement options in the scanner
- Google Authenticator Export: Ensure you're scanning the export QR, not a regular account QR
- Alternative Methods: Use "Upload Image" for saved QR codes or "Capture Screenshot" for on-screen codes
- Restart the app
- Check Keychain Access app for any prompts
- Ensure the app has keychain permissions in System Settings
- Ensure the QR code is a valid
otpauth://orotpauth-migration://URI - Check if the service uses TOTP (not HOTP)
- Try manual entry if QR scanning fails
TwoFactorAuth/
├── TwoFactorAuth/
│ ├── App/
│ │ ├── TwoFactorAuthApp.swift # Main app entry point
│ │ └── ContentView.swift # Main content view with navigation
│ ├── Models/
│ │ ├── Account.swift # Account data model
│ │ ├── TOTPGenerator.swift # TOTP algorithm implementation
│ │ └── GoogleAuthenticatorMigration.swift # Google Auth migration parser
│ ├── Views/
│ │ ├── AccountListView.swift # Sidebar account list with bulk operations
│ │ ├── AccountDetailView.swift # Account detail view with code display
│ │ ├── AddAccountView.swift # Add/Edit account forms
│ │ ├── QRScannerView.swift # Enhanced QR scanner with multiple methods
│ │ └── SettingsView.swift # Native macOS Settings window
│ ├── Services/
│ │ ├── KeychainService.swift # Keychain operations with secure storage
│ │ └── DataManager.swift # Data management layer
│ └── Info.plist # App configuration
├── Package.swift # Swift Package Manager config
├── build.sh # Build script
└── README.md # This file
- SwiftUI - Modern declarative UI framework
- CryptoKit - Apple's cryptography framework for TOTP generation
- AVFoundation - Camera access for QR code scanning
- Security Framework - Keychain Services for secure storage
- Combine - Reactive programming for data binding
Contributions are welcome! Please feel free to submit pull requests.
This project is provided as-is for educational and personal use.
- TOTP algorithm implementation based on RFC 6238
- Base32 encoding/decoding adapted from Swift community implementations
For issues, questions, or suggestions, please open an issue on GitHub.
Security Notice: Never share your secret keys or backup files with anyone. Always use strong, unique passwords for your exports.






