Recorded CRUD Operation In .NET Core 6 Web API & Swagger video.
Please watch it on YouTube.
Kalpesh Satasiya
1:57 PM
ASP.NET Core 1.0, Decryption, Encryption, Web API
No comments
private readonly IDataProtector _protector; public ValuesController(IDataProtectionProvider provider) { _protector = provider.CreateProtector(GetType().FullName); }
using System.Collections.Generic; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.DataProtection; namespace AspNetCoreEncryptionAndDescription.Controllers { [Route("api/[controller]")] public class ValuesController : Controller { private readonly IDataProtector _protector; public ValuesController(IDataProtectionProvider provider) { _protector = provider.CreateProtector(GetType().FullName); } // GET api/values [HttpGet] public IEnumerable<string> Get() { var encrypted = _protector.Protect("This is for testing!!"); var decrypted = _protector.Unprotect(encrypted); return new string[] { encrypted, decrypted }; } } }