Created
April 30, 2019 13:42
-
-
Save thebitbrine/32c5637e197119dabb1af98f19411e90 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
internal static byte[] EncryptMessage(byte[] pMessage, ProtocolType pProtocolType) | |
{ | |
List<byte> byteList = new List<byte>(); | |
int num1 = 171; | |
if (pMessage != null && pMessage.Length != 0) | |
{ | |
if (pProtocolType == ProtocolType.Tcp) | |
{ | |
byteList.Add((byte)0); | |
byteList.Add((byte)0); | |
byteList.Add((byte)0); | |
byteList.Add((byte)0); | |
} | |
for (int index = 0; index < pMessage.Length; ++index) | |
{ | |
byte num2 = (byte)((uint)num1 ^ (uint)pMessage[index]); | |
num1 = (int)num2; | |
byteList.Add(num2); | |
} | |
} | |
return byteList.ToArray(); | |
} | |
internal static byte[] DecryptMessage(byte[] pMessage, ProtocolType pProtocolType) | |
{ | |
List<byte> byteList = new List<byte>(); | |
int num1 = 171; | |
byte num2 = pProtocolType == ProtocolType.Udp ? (byte)0 : (byte)4; | |
if (pMessage != null && pMessage.Length != 0) | |
{ | |
for (int index = (int)num2; index < pMessage.Length; ++index) | |
{ | |
byte num3 = (byte)((uint)num1 ^ (uint)pMessage[index]); | |
num1 = (int)pMessage[index]; | |
byteList.Add(num3); | |
} | |
} | |
return byteList.ToArray(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment