Пример #1
0
        public bool FindOffset(OffsetSafeCRCRecord rec, out int offset)
        {
            if (this.Value.Length != 128 || rec.Value.Length != 128)
            {
                offset = 0;
                return(false);
                //throw new InvalidDataException("Unsupported OffsetSafeCRCRecord");
            }

            for (int i = 0; i < 64; i++)
            {
                if (rec.Value[0] == Value[i])
                {
                    offset = i * 64;
                    return(true);
                }
                if (Value[0] == rec.Value[i])
                {
                    offset = -i * 64;
                    return(true);
                }
                for (int j = 0; j < 64; j++)
                {
                    if (rec.Value[i] == Value[64 + j])
                    {
                        offset = i * 64 + j + 1;
                        return(true);
                    }
                    if (Value[i] == rec.Value[64 + j])
                    {
                        offset = -i * 64 - j - 1;
                        return(true);
                    }
                }
            }
            offset = 0;
            return(false);
        }
        public bool FindOffset(OffsetSafeCRCRecord rec, out int offset)
        {
            if (this.Value.Length != 128 || rec.Value.Length != 128)
            {
                offset = 0;
                return false;
                //throw new InvalidDataException("Unsupported OffsetSafeCRCRecord");
            }

            for (int i = 0; i < 64; i++)
            {
                if (rec.Value[0] == Value[i])
                {
                    offset = i * 64;
                    return true;
                }
                if (Value[0] == rec.Value[i])
                {
                    offset = -i * 64;
                    return true;
                }
                for (int j = 0; j < 64; j++)
                {
                    if (rec.Value[i] == Value[64 + j])
                    {
                        offset = i * 64 + j + 1;
                        return true;
                    }
                    if (Value[i] == rec.Value[64 + j])
                    {
                        offset = -i * 64 - j - 1;
                        return true;
                    }
                }
            }
            offset = 0;
            return false;
        }
Пример #3
0
        public bool DifferByOffset(OffsetSafeCRCRecord rec)
        {
            int offset;

            return(FindOffset(rec, out offset));
        }
 public bool DifferByOffset(OffsetSafeCRCRecord rec)
 {
     int offset;
     return FindOffset(rec, out offset);
 }