private static void code(byte[] In, int inOffset, int inPos, byte[] Out, int outOffset, int outPos, byte[] key) { if (outPos > 0) { for (int i = 0; i < 8; i++) { In[outOffset + outPos + i] = System.BitConverter.GetBytes(In[inOffset + inPos + i] ^ Out[outOffset + outPos + i - 8])[0]; } } uint[] array = QQTea.FormatKey(key); uint num = QQTea.ConvertByteArrayToUInt(In, outOffset + outPos); uint num2 = QQTea.ConvertByteArrayToUInt(In, outOffset + outPos + 4); uint num3 = 0u; uint num4 = 2654435769u; uint num5 = 16u; while (num5-- > 0u) { num3 += num4; num += ((num2 << 4) + array[0] ^ num2 + num3 ^ (num2 >> 5) + array[1]); num2 += ((num << 4) + array[2] ^ num + num3 ^ (num >> 5) + array[3]); } Array.Copy(QQTea.ConvertUIntToByteArray(num), 0, Out, outOffset + outPos, 4); Array.Copy(QQTea.ConvertUIntToByteArray(num2), 0, Out, outOffset + outPos + 4, 4); if (inPos > 0) { for (int j = 0; j < 8; j++) { Out[outOffset + outPos + j] = System.BitConverter.GetBytes(Out[outOffset + outPos + j] ^ In[inOffset + inPos + j - 8])[0]; } } }
private static uint[] FormatKey(byte[] key) { if (key.Length == 0) { throw new ArgumentException("Key must be between 1 and 16 characters in length"); } byte[] array = new byte[16]; if (key.Length < 16) { Array.Copy(key, 0, array, 0, key.Length); for (int i = key.Length; i < 16; i++) { array[i] = 32; } } else { Array.Copy(key, 0, array, 0, 16); } uint[] array2 = new uint[4]; int num = 0; for (int j = 0; j < array.Length; j += 4) { array2[num++] = QQTea.ConvertByteArrayToUInt(array, j); } return(array2); }