OpenStory.Cryptography.RollingIv.GetPacketLength C# (CSharp) Méthode

GetPacketLength() public static méthode

Reads a packet header from an array and extracts the packet's length.
/// Thrown if is . /// /// Thrown if has less than 4 elements. ///
public static GetPacketLength ( byte header ) : int
header byte The array to read from.
Résultat int
        public static int GetPacketLength(byte[] header)
        {
            Guard.NotNull(() => header, header);

            if (header.Length < 4)
            {
                var message = string.Format(CommonStrings.SegmentTooShort, 4);
                throw new ArgumentException(message, "header");
            }

            return ((header[1] ^ header[3]) << 8) | (header[0] ^ header[2]);
        }

Usage Example

Exemple #1
0
        public void GetPacketHeader_Throws_For_Null_Segment()
        {
            Action getPacketLength = () => RollingIv.GetPacketLength(null);

            getPacketLength
            .ShouldThrow <ArgumentNullException>();
        }
All Usage Examples Of OpenStory.Cryptography.RollingIv::GetPacketLength