This API is developed as a solution for a challenge offered by Back-End Brasil, the official community hub for Brazilian backenders.
- C#
- .NET
- ASP.NET
- Entity Framework Core
- Microsoft SQL Server
Your challenge will be to implement encryption in a service transparently for both the API and the service layers of your application. The goal is to ensure that sensitive fields of entity objects are not directly visible. This will involve performing encryption at runtime during the conversion of entities to the corresponding columns in the database, and vice versa.
Consider the fields "userDocument" and "creditCardToken" as sensitive fields that need to be encrypted. The example table would look like this:
id | userDocument | creditCardToken | value |
---|---|---|---|
1 | MzYxNDA3ODE4MzM= | YWJjMTIz | 5999 |
2 | MzI5NDU0MTA1ODM= | eHl6NDU2 | 1000 |
3 | NzYwNzc0NTIzODY= | Nzg5eHB0bw== | 1500 |
The structure of the corresponding entity would be as follows:
Field | Type |
---|---|
id | Long |
userDocument | String |
creditCardToken | String |
value | Long |
- Implement a simple CRUD considering the aforementioned fields as sensitive.
- Use the encryption algorithm of your preference.
- Clone the repository:
git clone https://github.com/louresb/CryptographyAPI
- Navigate to the project directory:
cd CryptographyAPI
- Build the project:
dotnet build
- Make sure to have SQL Server
dotnet ef database update
- Run the project:
dotnet run
Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request.