public static bool Decrypt(TByteList encryptValue, ByteArray protocolData) { if (encryptValue != null && encryptValue.GetElements().Count > 0) { for (var i = ByteArray.HEADERLENGTH; i < protocolData.Length; ++i) { var v = encryptValue.GetElements()[i % encryptValue.GetElements().Count]; protocolData.Buffer[i] = (byte)(protocolData.Buffer[i] ^ 0xaa); protocolData.Buffer[i] = (byte)((protocolData.Buffer[i] - v + 256) % 256); } return(true); } return(false); }
/// <summary> /// 改变加密串 /// </summary> /// <param name="encryptKey"></param> /// <param name="encryptValue"></param> public void ChangeEncrypt(string encryptKey, TByteList encryptValue) { m_encryptKey = encryptKey; m_encryptValue = encryptValue; }