Ejemplo n.º 1
0
        /// <summary>
        /// Gets the name hash.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <returns></returns>
        public UInt16 ComputeNameHash(string name)
        {
            UInt16 hash        = 0;
            var    upCaseTable = GetUpCaseTable();

            foreach (var c in name)
            {
                var uc = upCaseTable.ToUpper(c);
                hash = (UInt16)(hash.RotateRight() + (uc & 0xFF));
                hash = (UInt16)(hash.RotateRight() + (uc >> 8));
            }
            return(hash);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Gets the checksum of the given buffer.
 /// </summary>
 /// <param name="bytes">The bytes.</param>
 /// <param name="offset">The offset.</param>
 /// <param name="count">The count.</param>
 /// <param name="checksum">The checksum.</param>
 /// <returns></returns>
 public static UInt16 GetChecksum16(this byte[] bytes, int offset, int count, UInt16 checksum = 0)
 {
     count += offset;
     for (int index = offset; index < count; index++)
     {
         checksum = (UInt16)(checksum.RotateRight() + bytes[index]);
     }
     return(checksum);
 }