Skip to content

A Swiss Army knife for developers.

Fixing checksum comparison issue (#396) (#406)

Attila Stéger70e4497bebb9
diff --git a/src/dev/DevToys.Startup/Package.appxmanifest b/src/dev/DevToys.Startup/Package.appxmanifest
index 3bec99355..c7b45eb3b 100644
--- a/src/dev/DevToys.Startup/Package.appxmanifest
+++ b/src/dev/DevToys.Startup/Package.appxmanifest
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Package
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
diff --git a/src/dev/impl/DevToys/DevToys.csproj b/src/dev/impl/DevToys/DevToys.csproj
index 566783b8d..333ce85ab 100644
--- a/src/dev/impl/DevToys/DevToys.csproj
+++ b/src/dev/impl/DevToys/DevToys.csproj
@@ -59,6 +59,7 @@
<Compile Include="Messages\PinToolToStartMessage.cs" />
<Compile Include="Messages\OpenToolInNewWindowMessage.cs" />
<Compile Include="Messages\ChangeSelectedMenuItemMessage.cs" />
+ <Compile Include="Models\HashComparisonResult.cs" />
<Compile Include="Models\HashingAlgorithm.cs" />
<Compile Include="Models\HashingAlgorithmDisplayPair.cs" />
<Compile Include="Models\HashingProgress.cs" />
diff --git a/src/dev/impl/DevToys/LanguageManager.cs b/src/dev/impl/DevToys/LanguageManager.cs
index 731ffd521..ba2ed3efe 100644
--- a/src/dev/impl/DevToys/LanguageManager.cs
+++ b/src/dev/impl/DevToys/LanguageManager.cs
@@ -412,6 +412,16 @@ namespace DevToys
/// Gets the resource SearchKeywords.
/// </summary>
public string SearchKeywords => _resources.GetString("SearchKeywords");
+
+ /// <summary>
+ /// Gets the resource HashesMatch.
+ /// </summary>
+ public string HashesMatch => _resources.GetString("HashesMatch");
+
+ /// <summary>
+ /// Gets the resource HashesMismatch.
+ /// </summary>
+ public string HashesMismatch => _resources.GetString("HashesMismatch");
}
public class ColorBlindnessSimulatorStrings : ObservableObject
diff --git a/src/dev/impl/DevToys/Models/HashComparisonResult.cs b/src/dev/impl/DevToys/Models/HashComparisonResult.cs
new file mode 100644
index 000000000..83131bf5e
--- /dev/null
+++ b/src/dev/impl/DevToys/Models/HashComparisonResult.cs
@@ -0,0 +1,38 @@
+#nullable enable
+
+using Microsoft.UI.Xaml.Controls;
+
+namespace DevToys.Models
+{
+ /// <summary>
+ /// Contains information regarding the result of the hash comparison.
+ /// </summary>
+ internal sealed class HashComparisonResult
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="HashComparisonResult"/> class.
+ /// </summary>
+ /// <param name="severity">The severity of the comparison result message</param>
+ /// <param name="message">The message that can be shown to the user</param>
+ internal HashComparisonResult(InfoBarSeverity severity, string message)
+ {
+ Severity = severity;
+ Message = message;
+ }
+
+ /// <summary>
+ /// Gets a value that represents the severity of the comparison result message
+ /// </summary>
+ public InfoBarSeverity Severity { get; }
+
+ /// <summary>
+ /// Gets a value that represents the message can be shown to the user
+ /// </summary>
+ public string Message { get; }
+
+ /// <summary>
+ /// Gets the default-empty comparison result.
+ /// </summary>
+ public static HashComparisonResult? None { get; }
+ }
+}
diff --git a/src/dev/impl/DevToys/Strings/cs-CZ/CheckSumGenerator.resw b/src/dev/impl/DevToys/Strings/cs-CZ/CheckSumGenerator.resw
index f43258230..7de31d954 100644
--- a/src/dev/impl/DevToys/Strings/cs-CZ/CheckSumGenerator.resw
+++ b/src/dev/impl/DevToys/Strings/cs-CZ/CheckSumGenerator.resw
@@ -156,4 +156,10 @@
<data name="SearchKeywords" xml:space="preserve">
<value />
</data>
+ <data name="HashesMatch" xml:space="preserve">
+ <value>The hashes are the same.</value>
+ </data>
+ <data name="HashesMismatch" xml:space="preserve">
+ <value>The hashes are different.</value>
+ </data>
</root>
\ No newline at end of file
diff --git a/src/dev/impl/DevToys/Strings/de-DE/CheckSumGenerator.resw b/src/dev/impl/DevToys/Strings/de-DE/CheckSumGenerator.resw
index 0e31a4652..0430af8b0 100644
--- a/src/dev/impl/DevToys/Strings/de-DE/CheckSumGenerator.resw
+++ b/src/dev/impl/DevToys/Strings/de-DE/CheckSumGenerator.resw
@@ -156,4 +156,10 @@
<data name="SearchKeywords" xml:space="preserve">
<value />
</data>
+ <data name="HashesMatch" xml:space="preserve">
+ <value>The hashes are the same.</value>
+ </data>
+ <data name="HashesMismatch" xml:space="preserve">
+ <value>The hashes are different.</value>
+ </data>
</root>
\ No newline at end of file
diff --git a/src/dev/impl/DevToys/Strings/en-US/CheckSumGenerator.resw b/src/dev/impl/DevToys/Strings/en-US/CheckSumGenerator.resw
index 0e31a4652..0430af8b0 100644
--- a/src/dev/impl/DevToys/Strings/en-US/CheckSumGenerator.resw
+++ b/src/dev/impl/DevToys/Strings/en-US/CheckSumGenerator.resw
@@ -156,4 +156,10 @@
<data name="SearchKeywords" xml:space="preserve">
<value />
</data>
+ <data name="HashesMatch" xml:space="preserve">
+ <value>The hashes are the same.</value>
+ </data>
+ <data name="HashesMismatch" xml:space="preserve">
+ <value>The hashes are different.</value>
+ </data>
</root>
\ No newline at end of file
diff --git a/src/dev/impl/DevToys/Strings/es-AR/CheckSumGenerator.resw b/src/dev/impl/DevToys/Strings/es-AR/CheckSumGenerator.resw
index 0e31a4652..0430af8b0 100644
--- a/src/dev/impl/DevToys/Strings/es-AR/CheckSumGenerator.resw
+++ b/src/dev/impl/DevToys/Strings/es-AR/CheckSumGenerator.resw
@@ -156,4 +156,10 @@
<data name="SearchKeywords" xml:space="preserve">
<value />
</data>
+ <data name="HashesMatch" xml:space="preserve">
+ <value>The hashes are the same.</value>
+ </data>
+ <data name="HashesMismatch" xml:space="preserve">
+ <value>The hashes are different.</value>
+ </data>
</root>
\ No newline at end of file
diff --git a/src/dev/impl/DevToys/Strings/es-ES/CheckSumGenerator.resw b/src/dev/impl/DevToys/Strings/es-ES/CheckSumGenerator.resw
index 0e31a4652..0430af8b0 100644
--- a/src/dev/impl/DevToys/Strings/es-ES/CheckSumGenerator.resw
+++ b/src/dev/impl/DevToys/Strings/es-ES/CheckSumGenerator.resw
@@ -156,4 +156,10 @@
<data name="SearchKeywords" xml:space="preserve">
<value />
</data>
+ <data name="HashesMatch" xml:space="preserve">
+ <value>The hashes are the same.</value>
+ </data>
+ <data name="HashesMismatch" xml:space="preserve">
+ <value>The hashes are different.</value>
+ </data>
</root>
\ No newline at end of file
diff --git a/src/dev/impl/DevToys/Strings/fr-FR/CheckSumGenerator.resw b/src/dev/impl/DevToys/Strings/fr-FR/CheckSumGenerator.resw
index 0e31a4652..0430af8b0 100644
--- a/src/dev/impl/DevToys/Strings/fr-FR/CheckSumGenerator.resw
+++ b/src/dev/impl/DevToys/Strings/fr-FR/CheckSumGenerator.resw
@@ -156,4 +156,10 @@
<data name="SearchKeywords" xml:space="preserve">
<value />
</data>
+ <data name="HashesMatch" xml:space="preserve">
+ <value>The hashes are the same.</value>
+ </data>
+ <data name="HashesMismatch" xml:space="preserve">
+ <value>The hashes are different.</value>
+ </data>
</root>
\ No newline at end of file
diff --git a/src/dev/impl/DevToys/Strings/hu-HU/CheckSumGenerator.resw b/src/dev/impl/DevToys/Strings/hu-HU/CheckSumGenerator.resw
index 0e31a4652..5ea141a46 100644
--- a/src/dev/impl/DevToys/Strings/hu-HU/CheckSumGenerator.resw
+++ b/src/dev/impl/DevToys/Strings/hu-HU/CheckSumGenerator.resw
@@ -118,42 +118,48 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="AccessibleName" xml:space="preserve">
- <value>Checksum Generator tool</value>
+ <value>Checksum Generátor eszköz</value>
</data>
<data name="Cancel" xml:space="preserve">
- <value>Cancel</value>
+ <value>Mégsem</value>
</data>
<data name="Configuration" xml:space="preserve">
- <value>Configuration</value>
+ <value>Beállítások</value>
</data>
<data name="Description" xml:space="preserve">
- <value>Generate a hash with Checksum based on a file</value>
+ <value>Hash készítése fájl alapján</value>
</data>
<data name="HashingAlgorithmDescription" xml:space="preserve">
- <value>Select which hashing algorithm you want to use</value>
+ <value>Válassza ki a használni kívánt hash függvényt</value>
</data>
<data name="HashingAlgorithmTitle" xml:space="preserve">
- <value>Hashing Algorithm</value>
+ <value>Hash függvény</value>
</data>
<data name="Input" xml:space="preserve">
- <value>Input</value>
+ <value>Bemenet</value>
</data>
<data name="MenuDisplayName" xml:space="preserve">
<value>Checksum</value>
</data>
<data name="Output" xml:space="preserve">
- <value>Output</value>
+ <value>Kimenet</value>
</data>
<data name="OutputComparer" xml:space="preserve">
- <value>Output Comparer</value>
+ <value>Összehasonlító eredmény</value>
</data>
<data name="SearchDisplayName" xml:space="preserve">
<value>Checksum Generator</value>
</data>
<data name="Uppercase" xml:space="preserve">
- <value>Uppercase</value>
+ <value>Nagybetűs</value>
</data>
<data name="SearchKeywords" xml:space="preserve">
<value />
</data>
+ <data name="HashesMatch" xml:space="preserve">
+ <value>A hashek megegyeznek.</value>
+ </data>
+ <data name="HashesMismatch" xml:space="preserve">
+ <value>A hashek nem egyeznek meg.</value>
+ </data>
</root>
\ No newline at end of file
diff --git a/src/dev/impl/DevToys/Strings/id-ID/CheckSumGenerator.resw b/src/dev/impl/DevToys/Strings/id-ID/CheckSumGenerator.resw
index 9ee25ec69..de92a49d9 100644
--- a/src/dev/impl/DevToys/Strings/id-ID/CheckSumGenerator.resw
+++ b/src/dev/impl/DevToys/Strings/id-ID/CheckSumGenerator.resw
@@ -156,4 +156,10 @@
<data name="SearchKeywords" xml:space="preserve">
<value />
</data>
+ <data name="HashesMatch" xml:space="preserve">
+ <value>The hashes are the same.</value>
+ </data>
+ <data name="HashesMismatch" xml:space="preserve">
+ <value>The hashes are different.</value>
+ </data>
</root>
\ No newline at end of file
diff --git a/src/dev/impl/DevToys/Strings/it-IT/CheckSumGenerator.resw b/src/dev/impl/DevToys/Strings/it-IT/CheckSumGenerator.resw
index bf272caca..c6c6bd987 100644
--- a/src/dev/impl/DevToys/Strings/it-IT/CheckSumGenerator.resw
+++ b/src/dev/impl/DevToys/Strings/it-IT/CheckSumGenerator.resw
@@ -156,4 +156,10 @@
<data name="SearchKeywords" xml:space="preserve">
<value />
</data>
+ <data name="HashesMatch" xml:space="preserve">
+ <value>The hashes are the same.</value>
+ </data>
+ <data name="HashesMismatch" xml:space="preserve">
+ <value>The hashes are different.</value>
+ </data>
</root>
\ No newline at end of file
diff --git a/src/dev/impl/DevToys/Strings/ja-JP/CheckSumGenerator.resw b/src/dev/impl/DevToys/Strings/ja-JP/CheckSumGenerator.resw
index 46adebfe8..71ab71e7b 100644
--- a/src/dev/impl/DevToys/Strings/ja-JP/CheckSumGenerator.resw
+++ b/src/dev/impl/DevToys/Strings/ja-JP/CheckSumGenerator.resw
@@ -156,4 +156,10 @@
<data name="SearchKeywords" xml:space="preserve">
<value>Checksum</value>
</data>
+ <data name="HashesMatch" xml:space="preserve">
+ <value>The hashes are the same.</value>
+ </data>
+ <data name="HashesMismatch" xml:space="preserve">
+ <value>The hashes are different.</value>
+ </data>
</root>
\ No newline at end of file
diff --git a/src/dev/impl/DevToys/Strings/ko-KR/CheckSumGenerator.resw b/src/dev/impl/DevToys/Strings/ko-KR/CheckSumGenerator.resw
index 22986da1e..83fa9345f 100644
--- a/src/dev/impl/DevToys/Strings/ko-KR/CheckSumGenerator.resw
+++ b/src/dev/impl/DevToys/Strings/ko-KR/CheckSumGenerator.resw
@@ -156,4 +156,10 @@
<data name="SearchKeywords" xml:space="preserve">
<value>Checksum</value>
</data>
+ <data name="HashesMatch" xml:space="preserve">
+ <value>The hashes are the same.</value>
+ </data>
+ <data name="HashesMismatch" xml:space="preserve">
+ <value>The hashes are different.</value>
+ </data>
</root>
\ No newline at end of file
diff --git a/src/dev/impl/DevToys/Strings/pl-PL/CheckSumGenerator.resw b/src/dev/impl/DevToys/Strings/pl-PL/CheckSumGenerator.resw
index 0e31a4652..0430af8b0 100644
--- a/src/dev/impl/DevToys/Strings/pl-PL/CheckSumGenerator.resw
+++ b/src/dev/impl/DevToys/Strings/pl-PL/CheckSumGenerator.resw
@@ -156,4 +156,10 @@
<data name="SearchKeywords" xml:space="preserve">
<value />
</data>
+ <data name="HashesMatch" xml:space="preserve">
+ <value>The hashes are the same.</value>
+ </data>
+ <data name="HashesMismatch" xml:space="preserve">
+ <value>The hashes are different.</value>
+ </data>
</root>
\ No newline at end of file
diff --git a/src/dev/impl/DevToys/Strings/pt-PT/CheckSumGenerator.resw b/src/dev/impl/DevToys/Strings/pt-PT/CheckSumGenerator.resw
index 504fb5d97..075d40aa2 100644
--- a/src/dev/impl/DevToys/Strings/pt-PT/CheckSumGenerator.resw
+++ b/src/dev/impl/DevToys/Strings/pt-PT/CheckSumGenerator.resw
@@ -156,4 +156,10 @@
<data name="SearchKeywords" xml:space="preserve">
<value />
</data>
+ <data name="HashesMatch" xml:space="preserve">
+ <value>The hashes are the same.</value>
+ </data>
+ <data name="HashesMismatch" xml:space="preserve">
+ <value>The hashes are different.</value>
+ </data>
</root>
\ No newline at end of file
diff --git a/src/dev/impl/DevToys/Strings/ru-RU/CheckSumGenerator.resw b/src/dev/impl/DevToys/Strings/ru-RU/CheckSumGenerator.resw
index 0e31a4652..0430af8b0 100644
--- a/src/dev/impl/DevToys/Strings/ru-RU/CheckSumGenerator.resw
+++ b/src/dev/impl/DevToys/Strings/ru-RU/CheckSumGenerator.resw
@@ -156,4 +156,10 @@
<data name="SearchKeywords" xml:space="preserve">
<value />
</data>
+ <data name="HashesMatch" xml:space="preserve">
+ <value>The hashes are the same.</value>
+ </data>
+ <data name="HashesMismatch" xml:space="preserve">
+ <value>The hashes are different.</value>
+ </data>
</root>
\ No newline at end of file
diff --git a/src/dev/impl/DevToys/Strings/zh-Hans/CheckSumGenerator.resw b/src/dev/impl/DevToys/Strings/zh-Hans/CheckSumGenerator.resw
index 5a1998bb6..b37611000 100644
--- a/src/dev/impl/DevToys/Strings/zh-Hans/CheckSumGenerator.resw
+++ b/src/dev/impl/DevToys/Strings/zh-Hans/CheckSumGenerator.resw
@@ -156,4 +156,10 @@
<data name="SearchKeywords" xml:space="preserve">
<value />
</data>
+ <data name="HashesMatch" xml:space="preserve">
+ <value>The hashes are the same.</value>
+ </data>
+ <data name="HashesMismatch" xml:space="preserve">
+ <value>The hashes are different.</value>
+ </data>
</root>
\ No newline at end of file
diff --git a/src/dev/impl/DevToys/Strings/zh-Hant/CheckSumGenerator.resw b/src/dev/impl/DevToys/Strings/zh-Hant/CheckSumGenerator.resw
index 7da99f9b0..6f409fc5f 100644
--- a/src/dev/impl/DevToys/Strings/zh-Hant/CheckSumGenerator.resw
+++ b/src/dev/impl/DevToys/Strings/zh-Hant/CheckSumGenerator.resw
@@ -156,4 +156,10 @@
<data name="SearchKeywords" xml:space="preserve">
<value />
</data>
+ <data name="HashesMatch" xml:space="preserve">
+ <value>The hashes are the same.</value>
+ </data>
+ <data name="HashesMismatch" xml:space="preserve">
+ <value>The hashes are different.</value>
+ </data>
</root>
\ No newline at end of file
diff --git a/src/dev/impl/DevToys/ViewModels/Tools/Generators/CheckSumGenerator/CheckSumGeneratorToolViewModel.cs b/src/dev/impl/DevToys/ViewModels/Tools/Generators/CheckSumGenerator/CheckSumGeneratorToolViewModel.cs
index ce067605c..11c8079b1 100644
--- a/src/dev/impl/DevToys/ViewModels/Tools/Generators/CheckSumGenerator/CheckSumGeneratorToolViewModel.cs
+++ b/src/dev/impl/DevToys/ViewModels/Tools/Generators/CheckSumGenerator/CheckSumGeneratorToolViewModel.cs
@@ -21,6 +21,7 @@ using DevToys.Shared.Core.Threading;
using DevToys.Views.Tools.CheckSumGenerator;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using Microsoft.Toolkit.Mvvm.Input;
+using Microsoft.UI.Xaml.Controls;
using Windows.ApplicationModel.DataTransfer;
using Windows.Storage;
@@ -61,6 +62,7 @@ namespace DevToys.ViewModels.Tools.CheckSumGenerator
private bool _toolSuccessfullyWorked;
private bool _hasCancelledCalculation;
private bool _shouldDisplayProgress;
+ private HashComparisonResult? _hashComparisonResult;
private HashingAlgorithmDisplayPair? _outputHashingAlgorithm;
private readonly Queue<Task> _computationTaskQueue = new();
@@ -132,13 +134,27 @@ namespace DevToys.ViewModels.Tools.CheckSumGenerator
internal string? Output
{
get => _output;
- set => SetProperty(ref _output, value);
+ set
+ {
+ SetProperty(ref _output, value);
+ HashComparisonResult = EvaluateOutputComparisonResult(value, OutputComparer);
+ }
}
internal string? OutputComparer
{
get => _outputComparer;
- set => SetProperty(ref _outputComparer, value);
+ set
+ {
+ SetProperty(ref _outputComparer, value);
+ HashComparisonResult = EvaluateOutputComparisonResult(Output, value);
+ }
+ }
+
+ internal HashComparisonResult? HashComparisonResult
+ {
+ get => _hashComparisonResult;
+ private set => SetProperty(ref _hashComparisonResult, value);
}
/// <summary>
@@ -343,5 +359,22 @@ namespace DevToys.ViewModels.Tools.CheckSumGenerator
HashingAlgorithm.SHA512 => SHA512.Create(),
_ => throw new ArgumentException("Hash Algorithm not supported", nameof(HashingAlgorithm))
};
+
+ /// <summary>
+ /// Evaluates the Output Comparison.
+ /// </summary>
+ private HashComparisonResult? EvaluateOutputComparisonResult(string? output, string? comparerOutput)
+ {
+ if (!string.IsNullOrEmpty(output) && !string.IsNullOrEmpty(comparerOutput))
+ {
+ return string.Equals(output, comparerOutput, StringComparison.OrdinalIgnoreCase)
+ ? new HashComparisonResult(InfoBarSeverity.Success, Strings.HashesMatch)
+ : new HashComparisonResult(InfoBarSeverity.Error, Strings.HashesMismatch);
+ }
+ else
+ {
+ return HashComparisonResult.None;
+ }
+ }
}
}
diff --git a/src/dev/impl/DevToys/Views/Tools/Generators/CheckSumGenerator/CheckSumGeneratorToolPage.xaml b/src/dev/impl/DevToys/Views/Tools/Generators/CheckSumGenerator/CheckSumGeneratorToolPage.xaml
index 2563b9cd1..725bb4c02 100644
--- a/src/dev/impl/DevToys/Views/Tools/Generators/CheckSumGenerator/CheckSumGeneratorToolPage.xaml
+++ b/src/dev/impl/DevToys/Views/Tools/Generators/CheckSumGenerator/CheckSumGeneratorToolPage.xaml
@@ -13,6 +13,7 @@
<Page.Resources>
<converters:BooleanToVisibilityConverter x:Name="BooleanToVisibilityConverter"/>
<converters:InvertedBooleanConverter x:Name="InvertedBooleanConverter"/>
+ <converters:NullToBooleanConverter x:Name="NullToVisible" IsInverted="True"/>
</Page.Resources>
<StackPanel Margin="0,0,0,16" Spacing="12">
@@ -80,8 +81,14 @@
<controls:CustomTextBox
Header="{x:Bind ViewModel.Strings.OutputComparer}"
- Height="50"
AcceptsReturn="True"
Text="{x:Bind ViewModel.OutputComparer, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
+
+ <muxc:InfoBar Severity="{Binding Severity, Mode=OneWay}"
+ Message="{Binding Message, Mode=OneWay}"
+ IsOpen="{Binding Mode=OneWay, Converter={StaticResource NullToVisible}}"
+ DataContext="{x:Bind ViewModel.HashComparisonResult, Mode=OneWay}"
+ IsClosable="False">
+ </muxc:InfoBar>
</StackPanel>
</Page>
diff --git a/src/dev/shared/SharedAssemblyInfo.cs b/src/dev/shared/SharedAssemblyInfo.cs
index 10b703abb..6f8c30f64 100644
--- a/src/dev/shared/SharedAssemblyInfo.cs
+++ b/src/dev/shared/SharedAssemblyInfo.cs
@@ -1,4 +1,4 @@
-//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//