Esempio n. 1
0
        public static string GetCRC32Stream(Stream stream)
        {
            if (stream == null)
            {
                return("");
            }
            CCRC32 crc32 = new CCRC32();
            String hash  = String.Empty;

            stream.Position = 0;
            foreach (byte b in crc32.ComputeHash(stream))
            {
                hash += b.ToString("x2").ToLower();
            }
            return(hash.ToUpper());
        }
Esempio n. 2
0
        public static string GetCRC32File(string FileName)
        {
            if (!File.Exists(FileName))
            {
                return("");
            }
            CCRC32 crc32 = new CCRC32();
            String hash  = String.Empty;

            using (FileStream fs = File.Open(FileName, FileMode.Open))
            {
                foreach (byte b in crc32.ComputeHash(fs))
                {
                    hash += b.ToString("x2").ToLower();
                }
                fs.Close();
            }
            return(hash.ToUpper());
        }