Example #1
0
        /// <summary>Calculates byte length (8-bit) XOR-based check-sum on specified portion of a buffer.</summary>
        /// <param name="data">Data buffer to perform XOR check-sum on.</param>
        /// <param name="startIndex">Starts index in data buffer to begin XOR check-sum.</param>
        /// <param name="length">Total number of bytes from <paramref name="startIndex">startIndex</paramref> to
        /// perform XOR check-sum over.</param>
        /// <returns>Byte length XOR check-sum.</returns>
        public static byte Xor8Checksum(this byte[] data, int startIndex, int length)
        {
            Xor8 checksum = new Xor8();

            checksum.Update(data, startIndex, length);

            return(checksum.Value);
        }
        public void ConstructorCollectionTest()
        {
            HashAlgorithmCollection hashCollection = new HashAlgorithmCollection();
            MD5 md5 = new MD5();

            hashCollection.Add(md5);
            Sha1 sha1 = new Sha1();

            hashCollection.Add(sha1);
            Xor8 xor8 = new Xor8();

            hashCollection.Add(xor8);
            MultiHash hasher = new MultiHash(hashCollection);

            Assert.Contains(md5, hasher.HashAlgorithms);
            Assert.Contains(sha1, hasher.HashAlgorithms);
            Assert.Contains(xor8, hasher.HashAlgorithms);
        }
Example #3
0
        /// <summary>Calculates byte length (8-bit) XOR-based check-sum on specified portion of a buffer.</summary>
        /// <param name="data">Data buffer to perform XOR check-sum on.</param>
        /// <param name="startIndex">Starts index in data buffer to begin XOR check-sum.</param>
        /// <param name="length">Total number of bytes from <paramref name="startIndex">startIndex</paramref> to
        /// perform XOR check-sum over.</param>
        /// <returns>Byte length XOR check-sum.</returns>
        public static byte Xor8Checksum(this byte[] data, int startIndex, int length)
        {
            Xor8 checksum = new Xor8();

            checksum.Update(data, startIndex, length);

            return checksum.Value;
        }