forked from VahidN/DNTCommon.Web.Core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProtectionProviderServiceController.cs
More file actions
36 lines (27 loc) · 1.18 KB
/
Copy pathProtectionProviderServiceController.cs
File metadata and controls
36 lines (27 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using Microsoft.AspNetCore.Mvc;
namespace DNTCommon.Web.Core.TestWebApp.Controllers;
public class TestModel
{
public int Id { set; get; }
public string Name { set; get; }
}
public class ProtectionProviderServiceController : Controller
{
private readonly IProtectionProviderService _protectionProviderService;
public ProtectionProviderServiceController(IProtectionProviderService protectionProviderService)
{
_protectionProviderService = protectionProviderService;
}
public IActionResult Index()
{
ViewBag.Msg = "This is a test";
ViewBag.EncryptedMsg1 = _protectionProviderService.Encrypt(ViewBag.Msg);
ViewBag.DecryptMsg1 = _protectionProviderService.Decrypt(ViewBag.EncryptedMsg1);
ViewBag.EncryptedMsg2 = _protectionProviderService.Encrypt(ViewBag.Msg);
ViewBag.DecryptMsg2 = _protectionProviderService.Decrypt(ViewBag.EncryptedMsg2);
var model = new TestModel { Id = 1, Name = "Test" };
ViewBag.EncryptedMsg3 = _protectionProviderService.EncryptObject(model);
ViewBag.DecryptMsg3 = _protectionProviderService.DecryptObject<TestModel>(ViewBag.EncryptedMsg3).Name;
return View();
}
}