{"id":26745209,"url":"https://github.com/guliveer/secureappvault","last_synced_at":"2026-05-09T15:19:53.901Z","repository":{"id":284634651,"uuid":"955576658","full_name":"Guliveer/SecureAppVault","owner":"Guliveer","description":"A secure application vault that helps you manage and protect your applications with features like two-factor authentication (2FA) and whitelisting. Built with .NET and WPF.","archived":false,"fork":false,"pushed_at":"2025-03-26T21:30:49.000Z","size":22,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-26T22:29:03.961Z","etag":null,"topics":["2fa","csharp","dotnet","locker","vault","wpf"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Guliveer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-26T21:25:04.000Z","updated_at":"2025-03-26T21:33:26.000Z","dependencies_parsed_at":"2025-03-26T22:39:33.267Z","dependency_job_id":null,"html_url":"https://github.com/Guliveer/SecureAppVault","commit_stats":null,"previous_names":["guliveer/secureappvault"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Guliveer%2FSecureAppVault","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Guliveer%2FSecureAppVault/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Guliveer%2FSecureAppVault/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Guliveer%2FSecureAppVault/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Guliveer","download_url":"https://codeload.github.com/Guliveer/SecureAppVault/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245991584,"owners_count":20706129,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["2fa","csharp","dotnet","locker","vault","wpf"],"created_at":"2025-03-28T08:15:53.587Z","updated_at":"2026-05-09T15:19:53.821Z","avatar_url":"https://github.com/Guliveer.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"![C# Badge](https://img.shields.io/badge/C%23-9179E4?style=for-the-badge)\n![.NET Badge](https://img.shields.io/badge/.NET-512BD4?logo=dotnet\u0026logoColor=fff\u0026style=for-the-badge)\n![WPF](https://img.shields.io/badge/WPF-0a75b9?style=for-the-badge\u0026logo=m\u0026logoColor=white)\n\n# SecureAppVault\n\nSecureAppVault is a secure application vault that helps you manage and protect your applications with features like two-factor authentication (2FA) and whitelisting.\n\n## Features\n\n- Minimize to system tray\n- Two-factor authentication\n- Application whitelisting\n\n## Getting Started\n\n### Prerequisites\n\n- .NET 6.0 or later\n- Windows OS\n\n### Usage\n\n1. Run the application.\n2. Configure two-factor authentication if not already configured.\n3. Add applications to the whitelist.\n\n### Object-Oriented Programming (OOP)\n\nSecureAppVault leverages Object-Oriented Programming (OOP) principles to structure the application. Key OOP concepts used include:\n\n- **Encapsulation**: Classes like `TwoFactorAuthService` and `WhitelistService` encapsulate related functionalities and data, providing a clear interface for interaction.\n- **Abstraction**: The services abstract the underlying implementation details, allowing other parts of the application to interact with them without needing to understand the internal workings.\n- **Inheritance**: Although not explicitly shown in the provided code, inheritance can be used to create a hierarchy of classes that share common functionality.\n- **Polymorphism**: Methods like `VerifyCode` in `TwoFactorAuthService` can be overridden in derived classes to provide specific implementations.\n\n### Functional Programming (FP)\n\nWhile SecureAppVault primarily uses OOP, it also incorporates some Functional Programming (FP) principles:\n\n- **Immutability**: The use of immutable data structures where possible, such as the `List\u003cWhitelistedApp\u003e` returned by `LoadWhitelist`.\n- **Pure Functions**: Methods like `GenerateSecretKey` in `TwoFactorAuthService` are pure functions, as they do not cause side effects and always produce the same output for the same input.\n- **Higher-Order Functions**: The use of delegates and lambda expressions, such as the event handler for `_notifyIcon.DoubleClick`.\n\n## Code Overview\n\n### MainWindow.xaml.cs\n\nHandles the main window operations, including minimizing to the system tray.\n\n```csharp\nprivate void InitializeNotifyIcon()\n{\n    _notifyIcon = new NotifyIcon\n    {\n        Icon = new Icon(\"Resources/Icon.ico\"),\n        Visible = true,\n        Text = \"SecureAppVault\"\n    };\n    _notifyIcon.DoubleClick += (s, e) =\u003e RestoreWindow();\n}\n```\n\n### AddAppWindow.xaml.cs\n\nHandles adding applications to the whitelist.\n\n```csharp\nprivate void AddButton_Click(object sender, RoutedEventArgs e)\n{\n    var appName = AppNameTextBox.Text;\n    var appPath = AppPathTextBox.Text;\n\n    if (!string.IsNullOrEmpty(appName) \u0026\u0026 !string.IsNullOrEmpty(appPath))\n    {\n        var app = new WhitelistedApp(appName, appPath);\n        var apps = _whitelistService.LoadWhitelist();\n        apps.Add(app);\n        _whitelistService.SaveWhitelist(apps);\n\n        this.Close();\n    }\n    else\n    {\n        MessageBox.Show(\"Please enter both application name and path.\");\n    }\n}\n```\n\n### TwoFactorAuthWindow.xaml.cs\n\nHandles two-factor authentication.\n\n```csharp\nprivate void VerifyButton_Click(object sender, RoutedEventArgs e)\n{\n    try\n    {\n        var code = CodeTextBox.Text;\n        if (_twoFactorAuthService.VerifyCode(code))\n        {\n            DialogResult = true;\n            Close();\n        }\n        else\n        {\n            MessageBox.Show(\"Invalid code. Please try again.\");\n        }\n    }\n    catch (Exception ex)\n    {\n        MessageBox.Show($\"An error occurred during verification: {ex.Message}\");\n    }\n}\n```\n\n## Technical Details\n\n### Project Structure\n\nThe project is structured as follows:\n\n- `SecureAppVault.csproj`: The project file containing project metadata and dependencies.\n- `App.xaml` and `App.xaml.cs`: The application entry point and application-level event handlers.\n- `MainWindow.xaml` and `MainWindow.xaml.cs`: The main window of the application.\n- `Views/`: Contains additional windows such as `AddAppWindow` and `TwoFactorAuthWindow`.\n- `Models/`: Contains data models such as `WhitelistedApp`.\n- `Services/`: Contains service classes such as `WhitelistService` and `TwoFactorAuthService`.\n- `Resources/`: Contains resource files such as `Icon.ico`.\n\n### Dependency Injection\n\nThe project uses dependency injection to manage service instances. For example, `WhitelistService` is injected into `AddAppWindow`:\n\n```csharp\npublic AddAppWindow(string encryptionKey)\n{\n    InitializeComponent();\n    _whitelistService = new WhitelistService(encryptionKey);\n}\n```\n\n### Two-Factor Authentication\n\nThe `TwoFactorAuthService` class handles two-factor authentication. It verifies the code entered by the user:\n\n```csharp\npublic bool VerifyCode(string code)\n{\n    var totp = new Totp(_secretKey);\n    return totp.VerifyTotp(code, out _);\n}\n```\n\n### Whitelisting\n\nThe `WhitelistService` class manages the list of whitelisted applications. It provides methods to load and save the whitelist:\n\n```csharp\npublic List\u003cWhitelistedApp\u003e LoadWhitelist()\n{\n    if (!File.Exists(_filePath))\n    {\n        return new List\u003cWhitelistedApp\u003e();\n    }\n\n    var encryptedJson = File.ReadAllText(_filePath, Encoding.UTF8);\n    var json = _encryptionService.Decrypt(encryptedJson);\n    return System.Text.Json.JsonSerializer.Deserialize\u003cList\u003cWhitelistedApp\u003e\u003e(json) ?? new List\u003cWhitelistedApp\u003e();\n}\n\npublic void SaveWhitelist(List\u003cWhitelistedApp\u003e apps)\n{\n    var directory = Path.GetDirectoryName(_filePath);\n    if (directory != null \u0026\u0026 !Directory.Exists(directory))\n    {\n        Directory.CreateDirectory(directory);\n    }\n\n    var json = System.Text.Json.JsonSerializer.Serialize(apps);\n    var encryptedJson = _encryptionService.Encrypt(json);\n    File.WriteAllText(_filePath, encryptedJson, Encoding.UTF8);\n}\n```\n\n### Error Handling\n\nThe application includes error handling to manage exceptions and provide user feedback. For example, in `TwoFactorAuthWindow.xaml.cs`:\n\n```csharp\ntry\n{\n    var code = CodeTextBox.Text;\n    if (_twoFactorAuthService.VerifyCode(code))\n    {\n        DialogResult = true;\n        Close();\n    }\n    else\n    {\n        MessageBox.Show(\"Invalid code. Please try again.\");\n    }\n}\ncatch (Exception ex)\n{\n    MessageBox.Show($\"An error occurred during verification: {ex.Message}\");\n}\n```\n\n## Contributing\n\nContributions are welcome! Please open an issue or submit a pull request.\n\n---\nMade with ❤️ by [Oliwer Pawelski](https://github.com/Guliveer/)   \n![Rider Badge](https://img.shields.io/badge/Rider-000?logo=rider\u0026logoColor=fff\u0026style=flat-square)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguliveer%2Fsecureappvault","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fguliveer%2Fsecureappvault","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguliveer%2Fsecureappvault/lists"}