forked from EvgBitWhiskey/BitWhiskey
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AppCrypt.cs
27 lines (23 loc) · 785 Bytes
/
AppCrypt.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
using System;
using System.Security.Cryptography;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BitWhiskey
{
class AppCrypt
{
public static string EncryptData(string d)
{
var data = Encoding.UTF8.GetBytes(d);
var encrypted_data = ProtectedData.Protect(data, null, DataProtectionScope.CurrentUser);
return Convert.ToBase64String(encrypted_data);
}
public static string DecryptData(string encrypted_d)
{
var encrypted_data = Convert.FromBase64String(encrypted_d);
var data = ProtectedData.Unprotect(encrypted_data, null, DataProtectionScope.CurrentUser);
return Encoding.UTF8.GetString(data);
}
}
}