-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathCrypto.cs
31 lines (29 loc) · 858 Bytes
/
Crypto.cs
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
using System;
using System.Text;
using System.Security.Cryptography;
namespace ERPHelper
{
class Crypto
{
public static string Protect(string stringToEncrypt)
{
return Convert.ToBase64String(
ProtectedData.Protect(
Encoding.UTF8.GetBytes(stringToEncrypt)
, null
, DataProtectionScope.CurrentUser));
}
public static string Unprotect(string encryptedString)
{
if (String.IsNullOrEmpty(encryptedString))
{
return "";
}
return Encoding.UTF8.GetString(
ProtectedData.Unprotect(
Convert.FromBase64String(encryptedString)
, null
, DataProtectionScope.CurrentUser));
}
}
}