|
@@ -21,19 +21,11 @@ namespace Common
|
21
|
21
|
key = QrcodeLoginKey.PadRight(16, '0');
|
22
|
22
|
}
|
23
|
23
|
// 256-AES key
|
24
|
|
- byte[] keyArray = Encoding.ASCII.GetBytes(key);
|
25
|
|
- byte[] toEncryptArray = Encoding.ASCII.GetBytes(data);
|
26
|
|
- RijndaelManaged rDel = new RijndaelManaged
|
27
|
|
- {
|
28
|
|
- Key = keyArray,
|
29
|
|
- Mode = CipherMode.ECB,
|
30
|
|
- Padding = PaddingMode.PKCS7
|
31
|
|
- };
|
32
|
|
-
|
|
24
|
+ byte[] keyArray = Encoding.UTF8.GetBytes(key);
|
|
25
|
+ byte[] toEncryptArray = Encoding.UTF8.GetBytes(data);
|
|
26
|
+ RijndaelManaged rDel = new RijndaelManaged { Key = keyArray, Mode = CipherMode.ECB, Padding = PaddingMode.PKCS7 };
|
33
|
27
|
ICryptoTransform cTransform = rDel.CreateEncryptor();
|
34
|
|
- byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0,
|
35
|
|
- toEncryptArray.Length);
|
36
|
|
-
|
|
28
|
+ byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length);
|
37
|
29
|
return BytesToHexString(resultArray);
|
38
|
30
|
}
|
39
|
31
|
|
|
@@ -50,20 +42,12 @@ namespace Common
|
50
|
42
|
key = QrcodeLoginKey.PadRight(16, '0');
|
51
|
43
|
}
|
52
|
44
|
// 256-AES key
|
53
|
|
- byte[] keyArray = Encoding.ASCII.GetBytes(key);
|
|
45
|
+ byte[] keyArray = Encoding.UTF8.GetBytes(key);
|
54
|
46
|
byte[] toEncryptArray = HexStringToBytes(hexString);
|
55
|
|
-
|
56
|
|
- RijndaelManaged rDel = new RijndaelManaged
|
57
|
|
- {
|
58
|
|
- Key = keyArray,
|
59
|
|
- Mode = CipherMode.ECB,
|
60
|
|
- Padding = PaddingMode.PKCS7
|
61
|
|
- };
|
62
|
|
-
|
|
47
|
+ RijndaelManaged rDel = new RijndaelManaged { Key = keyArray, Mode = CipherMode.ECB, Padding = PaddingMode.PKCS7 };
|
63
|
48
|
ICryptoTransform cTransform = rDel.CreateDecryptor();
|
64
|
|
- byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0,
|
65
|
|
- toEncryptArray.Length);
|
66
|
|
- return Encoding.ASCII.GetString(resultArray);
|
|
49
|
+ byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length);
|
|
50
|
+ return Encoding.UTF8.GetString(resultArray);
|
67
|
51
|
}
|
68
|
52
|
|
69
|
53
|
/// <summary>
|
|
@@ -108,4 +92,4 @@ namespace Common
|
108
|
92
|
return d;
|
109
|
93
|
}
|
110
|
94
|
}
|
111
|
|
-}
|
|
95
|
+}
|