Exemple #1
0
        public async void CalcFileCrypt(string path)
        {
            FileInfo fInfor = new FileInfo(path);

            this.textBlockChosenFile.Text = "File name: " + fInfor.Name;
            string strMD5    = "尚未计算";
            string strSHA1   = "尚未计算";
            string strSHA256 = "尚未计算";

            if (checkBoxMD5.IsChecked == true)
            {
                await Task.Run(() =>
                {
                    strMD5 = FilesCryptography.GetFileMD5(path);
                }
                               );

                this.textBoxMD5.Text = strMD5;
            }
            if (checkBoxSHA1.IsChecked == true)
            {
                await Task.Run(() =>
                {
                    strSHA1 = FilesCryptography.GetFileSHA1(path);
                }
                               );

                this.textBoxSHA1.Text = strSHA1;
            }
            if (checkBoxSHA256.IsChecked == true)
            {
                await Task.Run(() =>
                {
                    strSHA256 = FilesCryptography.GetFileSHA256(path);
                }
                               );

                this.textBoxSHA256.Text = strSHA256;
            }
            this.progressBar.IsIndeterminate = false;
            this.progressBar.Value           = 100;
            GlobalVar.strMD5    = strMD5;
            GlobalVar.strSHA1   = strSHA1;
            GlobalVar.strSHA256 = strSHA256;
            GlobalVar.wheCalc   = true;
        }
Exemple #2
0
        public async void CalcMultiFiles(string path)
        {
            this.Width = 1150;
            FilesCryptInfo filesCryptInfo = new FilesCryptInfo();

            if (this.checkBoxMD5.IsChecked == true)
            {
                await Task.Run(() =>
                {
                    filesCryptInfo.md5 = FilesCryptography.GetFileMD5(path);
                });
            }
            if (this.checkBoxSHA1.IsChecked == true)
            {
                await Task.Run(() =>
                {
                    filesCryptInfo.sha1 = FilesCryptography.GetFileSHA1(path);
                });
            }
            if (this.checkBoxSHA256.IsChecked == true)
            {
                await Task.Run(() =>
                {
                    filesCryptInfo.sha256 = FilesCryptography.GetFileSHA256(path);
                });
            }
            filesCryptInfo.path = path;
            GlobalVar.listFilesCryptInfos.Add(filesCryptInfo);
            this.folderResult.AppendText(filesCryptInfo.path + "\n");
            if (this.checkBoxMD5.IsChecked == true)
            {
                this.folderResult.AppendText("MD5: " + filesCryptInfo.md5 + "\n");
            }
            if (this.checkBoxMD5.IsChecked == true)
            {
                this.folderResult.AppendText("SHA1: " + filesCryptInfo.sha1 + "\n");
            }
            if (this.checkBoxMD5.IsChecked == true)
            {
                this.folderResult.AppendText("SHA256: " + filesCryptInfo.sha256 + "\n");
            }
            this.folderResult.AppendText("----------------------------------------------------------------------------------------\n");
            this.folderResult.ScrollToEnd();
        }
Exemple #3
0
        public async void CalcFolderCrypt(string folderPath)
        {
            DirectoryInfo directoryInfo = new DirectoryInfo(folderPath);

            if (!directoryInfo.Exists)
            {
                return;
            }
            FileSystemInfo[] fileSystemInfos = directoryInfo.GetFileSystemInfos();
            foreach (FileSystemInfo item in fileSystemInfos)
            {
                FilesCryptInfo filesCryptInfo = new FilesCryptInfo();
                FileInfo       fileInfo       = item as FileInfo;
                if (fileInfo != null)
                {
                    filesCryptInfo.name = fileInfo.Name;
                    filesCryptInfo.path = Convert.ToString(new FileInfo(fileInfo.DirectoryName + "\\" + fileInfo.Name));
                    if (this.checkBoxMD5.IsChecked == true)
                    {
                        await Task.Run(() =>
                        {
                            filesCryptInfo.md5 = FilesCryptography.GetFileMD5(filesCryptInfo.path);
                        });
                    }
                    if (this.checkBoxSHA1.IsChecked == true)
                    {
                        await Task.Run(() =>
                        {
                            filesCryptInfo.sha1 = FilesCryptography.GetFileSHA1(filesCryptInfo.path);
                        });
                    }
                    if (this.checkBoxSHA256.IsChecked == true)
                    {
                        await Task.Run(() =>
                        {
                            filesCryptInfo.sha256 = FilesCryptography.GetFileSHA256(filesCryptInfo.path);
                        });
                    }
                    GlobalVar.listFilesCryptInfos.Add(filesCryptInfo);
                    this.folderResult.AppendText(filesCryptInfo.path + "\n");
                    if (this.checkBoxMD5.IsChecked == true)
                    {
                        this.folderResult.AppendText("MD5: " + filesCryptInfo.md5 + "\n");
                    }
                    if (this.checkBoxMD5.IsChecked == true)
                    {
                        this.folderResult.AppendText("SHA1: " + filesCryptInfo.sha1 + "\n");
                    }
                    if (this.checkBoxMD5.IsChecked == true)
                    {
                        this.folderResult.AppendText("SHA256: " + filesCryptInfo.sha256 + "\n");
                    }
                    this.folderResult.AppendText("----------------------------------------------------------------------------------------\n");
                    this.folderResult.ScrollToEnd();
                    GlobalVar.cnt++;
                }
                else
                {
                    string deepPath = folderPath + "\\" + item.ToString();
                    CalcFolderCrypt(deepPath);
                }
            }
            this.filecnt.Text = GlobalVar.cnt.ToString();
            this.progressBar.IsIndeterminate = false;
            this.progressBar.Value           = 100;
            GlobalVar.wheCalc = true;
        }