diff --git a/Lidgren.Network/NetEncryption.cs b/Lidgren.Network/NetEncryption.cs index bd936d2..dd592d9 100644 --- a/Lidgren.Network/NetEncryption.cs +++ b/Lidgren.Network/NetEncryption.cs @@ -43,7 +43,6 @@ namespace Lidgren.Network throw new NetException("Key too short!"); m_numRounds = rounds; - m_sum0 = new uint[m_numRounds]; m_sum1 = new uint[m_numRounds]; uint[] tmp = new uint[8]; @@ -72,6 +71,14 @@ namespace Lidgren.Network { } + /// + /// String to hash for key + /// + public NetXtea(string key) + : this(NetSha.Hash(Encoding.ASCII.GetBytes(key)), 32) + { + } + public void EncryptBlock( byte[] inBytes, int inOff, diff --git a/Lidgren.Network/NetOutgoingMessage.cs b/Lidgren.Network/NetOutgoingMessage.cs index dc4b256..9a3fe69 100644 --- a/Lidgren.Network/NetOutgoingMessage.cs +++ b/Lidgren.Network/NetOutgoingMessage.cs @@ -114,7 +114,7 @@ namespace Lidgren.Network throw new NetException("Trying to encode NetMessageType " + m_type + " to unconnected endpoint!"); ushort seqNr; - if (m_type >= NetMessageType.UserReliableUnordered) + if (m_type < NetMessageType.UserReliableUnordered) seqNr = conn.GetSendSequenceNumber(m_type); // "disposable" sequence number else seqNr = conn.StoreReliableMessage(now, this); diff --git a/UnitTests/EncryptionTests.cs b/UnitTests/EncryptionTests.cs index 67f8268..2281fa2 100644 --- a/UnitTests/EncryptionTests.cs +++ b/UnitTests/EncryptionTests.cs @@ -13,7 +13,7 @@ namespace UnitTests // // Test XTEA // - NetXtea xtea = new NetXtea(NetSha.Hash(Encoding.ASCII.GetBytes("TopSecret"))); + NetXtea xtea = new NetXtea("TopSecret"); byte[] original = new byte[16]; NetRandom.Instance.NextBytes(original);