blob: 6a5dde1d0cb1a6dbe39574380405cf5cb167dba0 (
plain)
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
37
38
39
40
41
|
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.Core.Cryptography;
using Tango.FSE.BL;
namespace Tango.FSE.UI.Cryptography
{
public class DefaultCryptographyProvider : ICryptographyProvider
{
private ICryptographer _cryptographer;
public DefaultCryptographyProvider()
{
_cryptographer = new MachineLevelCryptographer();
}
public string Encrypt(string text)
{
return _cryptographer.Encrypt(text);
}
public string Decrypt(string encryptedText)
{
return _cryptographer.Decrypt(encryptedText);
}
public string Encrypt(object obj)
{
return Encrypt(JsonConvert.SerializeObject(obj));
}
public T Decrypt<T>(string encryptedText)
{
return JsonConvert.DeserializeObject<T>(Decrypt(encryptedText));
}
}
}
|