-
-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathMCipher.cs
78 lines (65 loc) · 1.95 KB
/
MCipher.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
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
using System;
namespace PDTools.Crypto;
public class MCipherGT5
{
public static byte[] Decrypt(Span<byte> buffer)
{
byte[] outBuf = new byte[buffer.Length - 8];
if (DecryptImpl(buffer, outBuf, buffer.Length, 0x3039))
return outBuf;
return null;
}
private static bool DecryptImpl(Span<byte> buffer, Span<byte> outBuffer, int length, uint crcSeed)
{
int size = SharedCrypto.EncryptUnit_Decrypt(buffer, length, crcSeed, 0.327032387256622, 0.858476877212524, useMt: false, bigEndian: true);
if (size > -1)
buffer.Slice(8).CopyTo(outBuffer);
return size > -1;
}
public static void Encrypt()
{
}
}
public class MCipherGT6
{
public static byte[] Decrypt(Span<byte> buffer)
{
byte[] outBuf = new byte[buffer.Length];
if (DecryptImpl(buffer, outBuf, buffer.Length, 0x3039))
return outBuf;
return null;
}
private static bool DecryptImpl(Span<byte> buffer, Span<byte> outBuffer, int length, uint crcSeed)
{
int size = SharedCrypto.EncryptUnit2_Decrypt(buffer, length, crcSeed, useMt: false, bigEndian: true);
if (size > -1)
buffer.Slice(8).CopyTo(outBuffer);
return size > -1;
}
public static void Encrypt()
{
}
}
/// <summary>
/// Same as GT6
/// </summary>
public class MCipherGTS
{
public static byte[] Decrypt(Span<byte> buffer)
{
byte[] outBuf = new byte[buffer.Length];
if (DecryptImpl(buffer, outBuf, buffer.Length, 0x3039))
return outBuf;
return null;
}
private static bool DecryptImpl(Span<byte> buffer, Span<byte> outBuffer, int length, uint crcSeed)
{
int size = SharedCrypto.EncryptUnit2_Decrypt(buffer, length, crcSeed, useMt: false, bigEndian: true);
if (size > -1)
buffer.Slice(8).CopyTo(outBuffer);
return size > -1;
}
public static void Encrypt()
{
}
}