{"id":26594024,"url":"https://github.com/fkucukkara/dataprotector101","last_synced_at":"2026-04-19T13:32:52.925Z","repository":{"id":283994264,"uuid":"953503386","full_name":"fkucukkara/dataProtector101","owner":"fkucukkara","description":"This project demonstrates how to use ASP.NET Core Data Protection to securely encrypt and decrypt data","archived":false,"fork":false,"pushed_at":"2025-06-29T12:37:22.000Z","size":8,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-29T13:39:43.902Z","etag":null,"topics":["data-protect","minimal-api","netcore-webapi"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fkucukkara.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,"zenodo":null}},"created_at":"2025-03-23T14:21:24.000Z","updated_at":"2025-06-29T12:37:26.000Z","dependencies_parsed_at":"2025-05-27T11:35:24.602Z","dependency_job_id":"fd653824-0d1b-446b-99b2-68a01eb30f29","html_url":"https://github.com/fkucukkara/dataProtector101","commit_stats":null,"previous_names":["fkucukkara/dataprotector101"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/fkucukkara/dataProtector101","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fkucukkara%2FdataProtector101","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fkucukkara%2FdataProtector101/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fkucukkara%2FdataProtector101/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fkucukkara%2FdataProtector101/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fkucukkara","download_url":"https://codeload.github.com/fkucukkara/dataProtector101/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fkucukkara%2FdataProtector101/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32009152,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T20:23:30.271Z","status":"online","status_checked_at":"2026-04-19T02:00:07.110Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["data-protect","minimal-api","netcore-webapi"],"created_at":"2025-03-23T15:33:09.438Z","updated_at":"2026-04-19T13:32:52.917Z","avatar_url":"https://github.com/fkucukkara.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ASP.NET Core Data Protection API\n\nThis project demonstrates how to use **ASP.NET Core Data Protection** to securely encrypt and decrypt data. It provides simple `/protect` and `/unprotect` endpoints to manage sensitive information.\n\n## 🛠️ Features\n\n- Securely **protect** (encrypt) and **unprotect** (decrypt) sensitive data.\n- Supports **HTTPS** for secure data transfer.\n- Customizable **data protection purpose** for scoped encryption.\n- Cloud-ready with support for **persistent key storage** (e.g., Azure Blob, AWS S3).\n\n## 📌 Requirements\n\nEnsure the following are installed on your system:\n\n- .NET 9.0 SDK or later: [Download .NET](https://dotnet.microsoft.com/download)\n\n## 🚀 Getting Started\n\n### 1. Clone the repository:\n```bash\ngit clone https://github.com/fkucukkara/dataProtector101.git\ncd aspnetcore-data-protection\n```\n\n### 2. Run the application:\n\n```bash\ndotnet run\n```\n\nThe application will be available at `https://localhost:5001` (or the default port).\n\n## 📊 API Endpoints\n\n### ➤ **Protect Data**\n\nEncrypts the provided data securely.\n\n```http\nPOST /protect\n```\n\n**Query Parameters:**\n- `data` (string, required) – The data to be encrypted.\n\n**Example Request:**\n```bash\ncurl -X POST \"https://localhost:5001/protect?data=HelloWorld\"\n```\n\n**Response:**\n```json\n{\n  \"ProtectedData\": \"CfDJ8M8...==\"\n}\n```\n\n### ➤ **Unprotect Data**\n\nDecrypts previously protected data.\n\n```http\nPOST /unprotect\n```\n\n**Query Parameters:**\n- `data` (string, required) – The encrypted data to be decrypted.\n\n**Example Request:**\n```bash\ncurl -X POST \"https://localhost:5001/unprotect?data=CfDJ8M8...==\"\n```\n\n**Response:**\n```json\n{\n  \"UnprotectedData\": \"HelloWorld\"\n}\n```\n\n## 🔧 Customization\n\n### ➤ Set Application Name\nEnsure consistent key sharing across different applications.\n\n```csharp\nbuilder.Services.AddDataProtection()\n    .SetApplicationName(\"MySecureApp\");\n```\n\n### ➤ Persist Keys to File System\nStore encryption keys securely on disk.\n\n```csharp\nusing System.IO;\n\nbuilder.Services.AddDataProtection()\n    .PersistKeysToFileSystem(new DirectoryInfo(\"/var/keys\"))\n    .SetDefaultKeyLifetime(TimeSpan.FromDays(90));\n```\n\n### ➤ Custom Protectors\nUse different **purposes** for better data isolation.\n\n```csharp\nvar protector = provider.CreateProtector(\"CustomPurpose\");\n```\n\n## ☁️ Cloud Integration\n\n### ➤ Azure Blob Storage\n\n```csharp\nusing Azure.Storage.Blobs;\n\nbuilder.Services.AddDataProtection()\n    .PersistKeysToAzureBlobStorage(new Uri(\"\u003cBlobContainerUri\u003e\"));\n```\n\n### ➤ AWS S3\n\n```csharp\nusing Amazon.S3;\n\nvar s3Client = new AmazonS3Client();\nbuilder.Services.AddDataProtection()\n    .PersistKeysToAWS(s3Client, \"bucket-name\", \"keys-folder\");\n```\n\n## 🧹 Cleaning Up\nTo **revoke** old keys, delete the key files from the storage location.\n\n## 📝 Notes\n1. Always use **HTTPS** in production.\n2. Use different **purposes** for better data isolation.\n3. Regularly rotate encryption keys using `SetDefaultKeyLifetime()`.\n\n## 📖 Resources\n- [Microsoft Docs: Data Protection](https://learn.microsoft.com/en-us/aspnet/core/security/data-protection/)\n\n## License\n[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)\n\nThis project is licensed under the MIT License. See the [`LICENSE`](LICENSE) file for details.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffkucukkara%2Fdataprotector101","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffkucukkara%2Fdataprotector101","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffkucukkara%2Fdataprotector101/lists"}