$ show frankosterfeld/qtkeychain
QtKeychain is a cross-platform Qt library for securely storing passwords and secrets using platform-native keychain services. It provides a unified QKeychain::Job API (ReadPasswordJob, WritePasswordJob, DeletePasswordJob) that delegates to the appropriate backend: macOS/iOS Keychain, Windows Credential Store (or CryptProtectData), Linux via KWallet, libsecret, or GNOME Keyring, Android Keystore, Haiku's KeyStore, and a WebAssembly bridge using the Credential Management API. The library is primarily a thin abstraction layer with clean separation of platform concerns, an internal job queue for serialization, and a fallback mechanism to store data in plaintext via QSettings when no secure backend is available. It supports Qt 5 and Qt 6, requires C++11/17, and bundles translation files for several languages.
The LLM identified 4 files worth highlighting for reuse:
A lightweight key-value store backed by QSettings with explicit error tracking. Wraps QSettings read/write/remove operations, storing associated metadata such as storage mode (Text/Binary) as sibling keys. The class maintains a separate error and errorString, enabling callers to inspect failures (EntryNotFound, AccessDenied, OtherError). This pattern is reusable in any project needing a simple, portable persistent store with error reporting, without depending on the full keychain abstraction.
Implements a serial job executor (JobExecutor) that enqueues all keychain jobs and runs them one at a time, preventing concurrent access to platform keychains. Uses a QQueue<QPointer<Job>> and signals (finished/destroyed) to dequeue the next job. This pattern ensures sequential, thread-safe execution of asynchronous operations and can be extracted for any single-threaded resource that needs ordered access.
A comprehensive C++ wrapper around Android's Keystore and cryptographic APIs (java.security.KeyStore, javax.crypto.Cipher, etc.) using QAndroidJniObject. It encapsulates the JNI calls, exception handling (ExceptionCheck/Clear), and data conversion (jbyteArray <-> QByteArray). This adapter pattern is reusable for any Qt Android project needing direct access to Java security APIs without embedding raw JNI code.
Implements the macOS/iOS keychain operations using the Security framework with asynchronous Grand Central Dispatch (GCD) and an Objective-C helper class (AppleKeychainInterface). The interface holds QPointers to the job objects to avoid dangling callbacks, and dispatches result handling back to the main thread. This pattern demonstrates safe bridging between C++/Qt and Objective-C async APIs and can be reused for any macOS-specific async callbacks.