/// <summary>
        /// Computes Crc64 Hash
        /// </summary>
        /// <param name="rawData"></param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException"></exception>
        public static string ComputeCrc64IsoHash(string rawData)
        {
            _ = rawData ?? throw new ArgumentNullException(nameof(rawData));

            using var cr64 = Crc64Iso.Create();
            return(cr64.GenerateHashString(rawData));
        }
Exemple #2
0
 public HashReadStream(Stream strm, bool Appendhash, long filelen, int cancellreadafterms = 0, bool closestrm = true)
 {
     CloseStream = closestrm;
     FileLength  = filelen > 0 ? filelen : strm.Length;
     crc64       = new Crc64Iso();
     stream      = strm;
     ReadBytes   = 0;
     Append      = Appendhash;
     if (cancellreadafterms > 0)
     {
         TimeOut     = cancellreadafterms;
         TokenSource = new CancellationTokenSource(TimeOut);
     }
 }
Exemple #3
0
        /* CRC */
        private static byte[] CalculateCRC(string chksmFile)
        {
            List <byte> checksum = new List <byte>();
            var         crc64    = new Crc64Iso();

            using (FileStream fs = File.Open(chksmFile, FileMode.Open))
            {
                foreach (byte b in crc64.ComputeHash(fs))
                {
                    checksum.Add(b);
                }
            }

            return(checksum.ToArray());
        }
Exemple #4
0
        private void getMissingVideoFiles(List <FileInfo> _rawVideoList)
        {
            var presentVideoFiles = new List <string>();
            var crc64             = new Crc64Iso();

            using (var connection = new SQLiteConnection(ConfigurationManager.ConnectionStrings["Primary"].ToString()))
            {
                connection.Open();
                using (var command = connection.CreateCommand())
                {
                    command.CommandText = "Select distinct [File_Path] From [VideoRecords] Where [Deleted] = 0;";

                    using (var reader = command.ExecuteReader())
                        while (reader.Read())
                        {
                            presentVideoFiles.Add(reader.GetString(0));
                        }
                }
            }

            foreach (var file in _rawVideoList)
            {
                if (!presentVideoFiles.Contains(file.FullName))
                {
                    //string hash = string.Empty;

                    //using (var fs = File.Open(file.FullName, FileMode.Open))
                    //    foreach (var b in crc64.ComputeHash(fs))
                    //        hash += b.ToString("x2").ToLower();

                    Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() => {
                        MissingVideoFiles.Add(new MissingVideoFile(file));
                    }));
                }
            }
        }
Exemple #5
0
        public void IsoStaticDefaultSeedAndPolynomialWithShortAsciiString()
        {
            var actual = Crc64Iso.Compute(SimpleBytesAscii);

            Assert.Equal(0x7e210eb1b03e5a1dUL, actual);
        }
Exemple #6
0
        public void IsoStaticDefaultSeedAndPolynomialWithShortAsciiString2()
        {
            var actual = Crc64Iso.Compute(SimpleBytes2Ascii);

            Assert.Equal(0x416b4150508661eeUL, actual);
        }
Exemple #7
0
        public void IsoStaticDefaultSeedAndPolynomialWithShortAsciiString()
        {
            var actual = Crc64Iso.Compute(SimpleBytesAscii);

            Assert.AreEqual(0x7E210EB1B03E5A1D, actual);
        }
Exemple #8
0
        public VideoDetailsPageViewModel(string _path) : this()
        {
            vid = Guid.NewGuid().ToString();
            VideoAccesser.CreateNewRecord(vid);

            EditMode.Value = true;

            var fileInfo  = new FileInfo(_path);
            var mediaInfo = MediaAccessor.GetMetaData(_path);

            VideoAccesser.UpdateScore(vid, -1);
            VideoAccesser.UpdateFavorite(vid, false);
            VideoAccesser.UpdateIntensity(vid, "N/A");

            VideoAccesser.UpdateAlias(vid, fileInfo.Name);
            Alias.Value = fileInfo.Name;

            VideoAccesser.UpdateSeries(vid, fileInfo.DirectoryName);
            Series.Value = fileInfo.DirectoryName;

            VideoAccesser.UpdateDuration(vid, mediaInfo.Metadata.Duration);
            Duration.Value = mediaInfo.Metadata.Duration.ToString(@"mm\:ss");
            Bitrate.Value  = Math.Round(fileInfo.Length / mediaInfo.Metadata.Duration.TotalSeconds).ToString() + "bps";

            VideoAccesser.UpdateResolution(vid, mediaInfo.Metadata.VideoData.FrameSize);
            Frame.Value = mediaInfo.Metadata.VideoData.FrameSize;

            VideoAccesser.UpdateFormat(vid, mediaInfo.Metadata.VideoData.Format);
            Format.Value = mediaInfo.Metadata.VideoData.Format;

            VideoAccesser.UpdateFilePath(vid, fileInfo.FullName);
            FilePath.Value = fileInfo.FullName;

            VideoAccesser.UpdateFileName(vid, fileInfo.Name);
            FileName.Value = fileInfo.Name;

            VideoAccesser.UpdateFileExtention(vid, fileInfo.Extension);
            Extention.Value = fileInfo.Extension;

            VideoAccesser.UpdateFileSize(vid, fileInfo.Length);
            FileSize.Value = Math.Round(fileInfo.Length / 1048576d, 1).ToString() + "MB";

            ScoreUI     = new ScoreEntity();
            IntensityUI = new IntensityEntity();
            DurationUI  = new DurationEntity(mediaInfo.Metadata.Duration);

            LoadingIndicatorVisibility.Value = Visibility.Visible;

            Task.Factory.StartNew(new Action(() => {
                BitmapSource result = MediaAccessor.CreateGridScreenlist(mediaInfo, LoadingIndicatorCurrent, LoadingIndicatorMax);

                Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() => { Screenlist.Value = result; }));
                Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() => { LoadingIndicatorVisibility.Value = Visibility.Hidden; }));

                var crc64   = new Crc64Iso();
                string hash = string.Empty;

                using (var fs = File.Open(fileInfo.FullName, FileMode.Open))
                    foreach (var b in crc64.ComputeHash(fs))
                    {
                        hash += b.ToString("x2").ToLower();
                    }

                VideoAccesser.UpdateChecksum(vid, hash);
            }));

            Icon.PropertyChanged += (object sender, PropertyChangedEventArgs e) => { VideoAccesser.UpdateIcon(vid, Icon.Value); };

            Playlist.PropertyChanged += (object sender, PropertyChangedEventArgs e) => { throw new NotImplementedException(); };
            Favorite.PropertyChanged += (object sender, PropertyChangedEventArgs e) => { VideoAccesser.UpdateFavorite(vid, Favorite.Value); };

            ScoreUI.PropertyChanged     += (object sender, PropertyChangedEventArgs e) => { VideoAccesser.UpdateScore(vid, ScoreUI.Score.Value); };
            IntensityUI.PropertyChanged += (object sender, PropertyChangedEventArgs e) => { VideoAccesser.UpdateIntensity(vid, IntensityUI.Intensity.Value); };

            VideoTags.Entities.ListChanged += (object o, ListChangedEventArgs e) => {
                if (e.ListChangedType == ListChangedType.ItemChanged)
                {
                    var collection = (BindingList <TagEntityBase>)o;
                    var tag        = (TagEntity)collection[e.NewIndex];

                    VideoAccesser.UpsertTag(vid, tag.Text, tag.Intensity, tag.Deleted);
                }
            };

            Alias.PropertyChanged      += (object sender, PropertyChangedEventArgs e) => { VideoAccesser.UpdateAlias(vid, Alias.Value); };
            Series.PropertyChanged     += (object sender, PropertyChangedEventArgs e) => { VideoAccesser.UpdateSeries(vid, Series.Value); };
            Alt_Alias.PropertyChanged  += (object sender, PropertyChangedEventArgs e) => { VideoAccesser.UpdateAltAlias(vid, Alt_Alias.Value); };
            Alt_Series.PropertyChanged += (object sender, PropertyChangedEventArgs e) => { VideoAccesser.UpdateAltSeries(vid, Alt_Series.Value); };

            Screenlist.PropertyChanged += (object sender, PropertyChangedEventArgs e) => { VideoAccesser.UpsertScreenlist(vid, Screenlist.Value); };
        }
Exemple #9
0
 public HashWriteStream(Stream strm, long filelen)
 {
     crc64      = new Crc64Iso();
     stream     = strm;
     FileLength = filelen;
 }