コード例 #1
0
        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);
        }
コード例 #2
0
 /// <summary>
 /// 改变加密串
 /// </summary>
 /// <param name="encryptKey"></param>
 /// <param name="encryptValue"></param>
 public void ChangeEncrypt(string encryptKey, TByteList encryptValue)
 {
     m_encryptKey   = encryptKey;
     m_encryptValue = encryptValue;
 }