bool xEncrypt(ref DJsIO xNewPayload) { try { if (!xSuccess) { return(false); } if (xIsLive) { byte[] xService = (ThisType == AccountType.Stock ? new byte[] { 0x50, 0x52, 0x4F, 0x44 } : // PROD new byte[] { 0x50, 0x41, 0x53, 0x54 }); // PART xNewPayload.Position = 0x34; xNewPayload.Write(xService); xNewPayload.Flush(); } List <byte> xReturn = new List <byte>(); byte[] xConfounder = xRC4.NewConfounder(8); byte[] NewPay = xNewPayload.ReadStream(); xNewPayload.Dispose(); byte[] xHeaderKey = xComputeHeaderKey(xConfounder, NewPay); xRC4.KeyBinary = xComputeRC4Key(xHeaderKey); xReturn.AddRange(xHeaderKey); xReturn.AddRange(xRC4.KerberosEncrypt(ref xConfounder, ref NewPay)); IO.Position = 0; IO.Write(xReturn.ToArray()); IO.Flush(); return(true); } catch { return(false); } }
/// <summary> /// Runs an RC4 encryption with a specified key /// </summary> /// <param name="xKey"></param> /// <param name="xConfounder"></param> /// <param name="xPayload"></param> /// <returns></returns> public static byte[] RunKerberosEncrypt(byte[] xKey, ref byte[] xConfounder, ref byte[] xPayload) { RC4 xrc4 = new RC4(xKey); return xrc4.KerberosEncrypt(ref xConfounder, ref xPayload); }