Пример #1
0
        public static string GetHash(string Name)
        {
            if (Name == string.Empty)
                return string.Empty;

            CRC crc = new CRC();

            string Hash = string.Empty;

            using (FileStream fileStream = File.Open(Name, FileMode.Open))
            {
                foreach (byte b in crc.ComputeHash(fileStream))
                {
                    Hash += b.ToString("x2").ToLower();
                }
            }

            return Hash;
        }
 public static uint Compute(uint polynomial, uint seed, byte[] buffer)
 {
     return(~CRC.CalculateHash(CRC.InitializeTable(polynomial), seed, buffer, 0, buffer.Length));
 }
 public static uint Compute(uint seed, byte[] buffer)
 {
     return(CRC.Compute(0xedb88320, seed, buffer));
 }
 public static uint Compute(byte[] buffer)
 {
     return(CRC.Compute(uint.MaxValue, buffer));
 }
 protected override byte[] HashFinal()
 {
     byte[] array = CRC.UInt32ToBigEndianBytes(~this.hash);
     this.HashValue = array;
     return(array);
 }
 protected override void HashCore(byte[] buffer, int start, int length)
 {
     this.hash = CRC.CalculateHash(this.table, this.hash, buffer, start, length);
 }
 public CRC(uint polynomial, uint seed)
 {
     this.table = CRC.InitializeTable(polynomial);
     this.hash  = seed;
     this.seed  = seed;
 }
Пример #8
0
 public static uint Compute(uint seed, byte[] buffer)
 {
     return(CRC.Compute(3988292384U, seed, buffer));
 }
Пример #9
0
 protected override byte[] HashFinal()
 {
     byte[] bigEndianBytes = CRC.UInt32ToBigEndianBytes(~this.hash);
     this.HashValue = bigEndianBytes;
     return(bigEndianBytes);
 }
Пример #10
0
        private string GetHash(string Name)
        {
            if (Name == string.Empty)
                return null;

            CRC crc = new CRC();

            string Hash = string.Empty;

            try
            {
                using (FileStream fileStream = File.Open(Name, FileMode.Open))
                {
                    foreach (byte b in crc.ComputeHash(fileStream))
                    {
                        Hash += b.ToString("x2").ToLower();
                    }
                }
            }
            catch
            {
                MessageBox.Show(Name + " cannot be opened.");
            }

            return Hash;
        }