public static byte[] GetFileCRC64(string path, Crc64 crc64) { if (path == null) { throw new ArgumentNullException("path"); } byte[] buf = new byte[4096]; int len = 0; using (FileStream fs = new FileStream(path, FileMode.Open)) { while ((len = fs.Read(buf, 0, buf.Length)) != 0) { crc64.Update(buf, 0, len); } } return(crc64.Value); }
public static byte[] GetStreamCRC64(Stream stream, Crc64 crc64) { if (stream == null) { throw new ArgumentNullException("stream"); } if (!stream.CanRead) { throw new ArgumentException("stream is not readable."); } stream.Position = 0; byte[] buf = new byte[4096]; int len = 0; while ((len = stream.Read(buf, 0, buf.Length)) != 0) { crc64.Update(buf, 0, len); } stream.Position = 0; return(crc64.Value); }