@@ -8,16 +8,26 @@ namespace SPHDecode.Implementations
8
8
{
9
9
public static class Cryptography
10
10
{
11
- private static byte [ ] KEY = new byte [ ] { 22 , 39 , 41 , 141 , 146 , 199 , 249 , 4 , 22 , 135 , 33 , 125 , 42 , 121 , 133 , 198 , 243 , 104 , 188 , 35 , 46 , 48 , 11 , 1 , 142 , 200 , 248 , 130 , 113 , 81 , 73 , 62 } ; // "1627298D92C7F9041687217D2A7985C6F368BC232E300B018EC8F8827151493E"
12
- private static byte [ ] IV = new byte [ ] { 89 , 48 , 127 , 77 , 236 , 78 , 199 , 214 , 97 , 87 , 151 , 33 , 145 , 150 , 117 , 0 } ; // "59307F4DEC4EC7D66157972191967500"
11
+ private static byte [ ] V2KEY = new byte [ ] { 22 , 39 , 41 , 141 , 146 , 199 , 249 , 4 , 22 , 135 , 33 , 125 , 42 , 121 , 133 , 198 , 243 , 104 , 188 , 35 , 46 , 48 , 11 , 1 , 142 , 200 , 248 , 130 , 113 , 81 , 73 , 62 } ; // "1627298D92C7F9041687217D2A7985C6F368BC232E300B018EC8F8827151493E"
12
+ private static byte [ ] V2IV = new byte [ ] { 89 , 48 , 127 , 77 , 236 , 78 , 199 , 214 , 97 , 87 , 151 , 33 , 145 , 150 , 117 , 0 } ; // "59307F4DEC4EC7D66157972191967500"
13
13
14
- public static byte [ ] Decrypt ( byte [ ] clearText )
14
+ private static byte [ ] V3KEY = new byte [ ] { 221 , 31 , 187 , 117 , 150 , 208 , 213 , 139 , 191 , 51 , 106 , 186 , 57 , 19 , 102 , 237 , 62 , 215 , 70 , 8 , 73 , 187 , 158 , 250 , 185 , 100 , 156 , 153 , 152 , 99 , 191 , 37 } ; // "DD1FBB7596D0D58BBF336ABA391366ED3ED7460849BB9EFAB9649C999863BF25"
15
+ private static byte [ ] V3IV = new byte [ ] { 179 , 128 , 225 , 122 , 12 , 71 , 110 , 138 , 72 , 11 , 85 , 37 , 58 , 186 , 230 , 102 } ; // "B380E17A0C476E8A480B55253ABAE666"
16
+
17
+ public static byte [ ] Decrypt ( byte [ ] clearText )
15
18
{
16
19
byte [ ] response ;
17
20
18
21
try
19
22
{
20
- byte [ ] data = AESHelper ( clearText , true ) ;
23
+ byte [ ] data ;
24
+ try {
25
+ data = AESHelper ( V3KEY , V3IV , clearText , true ) ;
26
+ }
27
+ catch ( Exception )
28
+ {
29
+ data = AESHelper ( V2KEY , V2IV , clearText , true ) ;
30
+ }
21
31
22
32
response = Zlib . DecompressData ( data ) ;
23
33
}
@@ -53,7 +63,7 @@ public static byte[] Encrypt(byte[] data)
53
63
{
54
64
byte [ ] comp = Zlib . CompressData ( clearText ) ;
55
65
56
- response = AESHelper ( comp ) ;
66
+ response = AESHelper ( V2KEY , V2IV , comp ) ;
57
67
}
58
68
catch ( Exception ex )
59
69
{
@@ -65,7 +75,7 @@ public static byte[] Encrypt(byte[] data)
65
75
return response ;
66
76
}
67
77
68
- private static byte [ ] AESHelper ( byte [ ] data , bool decrypt = false )
78
+ private static byte [ ] AESHelper ( byte [ ] key , byte [ ] iv , byte [ ] data , bool decrypt = false )
69
79
{
70
80
Aes encryptor = Aes . Create ( ) ;
71
81
@@ -78,8 +88,8 @@ private static byte[] AESHelper (byte[] data, bool decrypt = false)
78
88
encryptor . BlockSize = 128 ;
79
89
encryptor . Mode = CipherMode . CBC ;
80
90
encryptor . Padding = PaddingMode . Zeros ;
81
- encryptor . Key = KEY ;
82
- encryptor . IV = IV ;
91
+ encryptor . Key = key ;
92
+ encryptor . IV = iv ;
83
93
84
94
MemoryStream ms = new MemoryStream ( ) ;
85
95
CryptoStream cs = new CryptoStream ( ms , encryptor . CreateEncryptor ( ) , CryptoStreamMode . Write ) ;
0 commit comments