A Swiss Army knife for developers.
C# blazorcross-platformcsharpdesktopdesktop-appdesktop-applicationdeveloper-toolsextensiblefluentfluent-designlinuxmacosmicasyntax-highlightingtypescriptwindowswindows-10windows-11winui
HashGenerator output on base64 or hex (#240)
Andres84679b5733e0
diff --git a/src/dev/impl/DevToys/LanguageManager.cs b/src/dev/impl/DevToys/LanguageManager.csindex 4dfdf6aad..917607a16 100644--- a/src/dev/impl/DevToys/LanguageManager.cs+++ b/src/dev/impl/DevToys/LanguageManager.cs@@ -828,6 +828,21 @@ namespace DevToys/// Gets the resource SearchDisplayName./// </summary>public string SearchDisplayName => _resources.GetString("SearchDisplayName");++ /// <summary>+ /// Gets the resource OutputBase64.+ /// </summary>+ public string OutputBase64 => _resources.GetString("OutputBase64");++ /// <summary>+ /// Gets the resource OutputHex.+ /// </summary>+ public string OutputHex => _resources.GetString("OutputHex");++ /// <summary>+ /// Gets the resource OutputTypeTitle.+ /// </summary>+ public string OutputTypeTitle => _resources.GetString("OutputTypeTitle");}public class HtmlEncoderDecoderStrings : ObservableObjectdiff --git a/src/dev/impl/DevToys/Strings/cs-CZ/HashGenerator.resw b/src/dev/impl/DevToys/Strings/cs-CZ/HashGenerator.reswindex 376ae2ff8..99461f99a 100644--- a/src/dev/impl/DevToys/Strings/cs-CZ/HashGenerator.resw+++ b/src/dev/impl/DevToys/Strings/cs-CZ/HashGenerator.resw@@ -150,4 +150,13 @@<data name="SearchDisplayName" xml:space="preserve"><value>Hash Generátor</value></data>+ <data name="OutputBase64" xml:space="preserve">+ <value>Base64</value>+ </data>+ <data name="OutputHex" xml:space="preserve">+ <value>Hex</value>+ </data>+ <data name="OutputTypeTitle" xml:space="preserve">+ <value>Typ výstupu</value>+ </data></root>\ No newline at end of filediff --git a/src/dev/impl/DevToys/Strings/de-DE/HashGenerator.resw b/src/dev/impl/DevToys/Strings/de-DE/HashGenerator.reswindex 9f176d3b3..f9c43a620 100644--- a/src/dev/impl/DevToys/Strings/de-DE/HashGenerator.resw+++ b/src/dev/impl/DevToys/Strings/de-DE/HashGenerator.resw@@ -150,4 +150,13 @@<data name="SearchDisplayName" xml:space="preserve"><value>Hash Generator</value></data>+ <data name="OutputBase64" xml:space="preserve">+ <value>Base64</value>+ </data>+ <data name="OutputHex" xml:space="preserve">+ <value>Hex</value>+ </data>+ <data name="OutputTypeTitle" xml:space="preserve">+ <value>Ausgabetyp</value>+ </data></root>\ No newline at end of filediff --git a/src/dev/impl/DevToys/Strings/en-US/HashGenerator.resw b/src/dev/impl/DevToys/Strings/en-US/HashGenerator.reswindex dc57a8091..f6203ba7a 100644--- a/src/dev/impl/DevToys/Strings/en-US/HashGenerator.resw+++ b/src/dev/impl/DevToys/Strings/en-US/HashGenerator.resw@@ -150,4 +150,13 @@<data name="SearchDisplayName" xml:space="preserve"><value>Hash Generator</value></data>+ <data name="OutputBase64" xml:space="preserve">+ <value>Base64</value>+ </data>+ <data name="OutputHex" xml:space="preserve">+ <value>Hex</value>+ </data>+ <data name="OutputTypeTitle" xml:space="preserve">+ <value>Output Type</value>+ </data></root>\ No newline at end of filediff --git a/src/dev/impl/DevToys/Strings/es-AR/HashGenerator.resw b/src/dev/impl/DevToys/Strings/es-AR/HashGenerator.reswindex 91e6aa168..2dcc1b932 100644--- a/src/dev/impl/DevToys/Strings/es-AR/HashGenerator.resw+++ b/src/dev/impl/DevToys/Strings/es-AR/HashGenerator.resw@@ -150,4 +150,13 @@<data name="SearchDisplayName" xml:space="preserve"><value>Generador de Hash</value></data>+ <data name="OutputBase64" xml:space="preserve">+ <value>Base64</value>+ </data>+ <data name="OutputHex" xml:space="preserve">+ <value>Hex</value>+ </data>+ <data name="OutputTypeTitle" xml:space="preserve">+ <value>Tipo de Salida</value>+ </data></root>\ No newline at end of filediff --git a/src/dev/impl/DevToys/Strings/es-ES/HashGenerator.resw b/src/dev/impl/DevToys/Strings/es-ES/HashGenerator.reswindex f361cf2df..cb01fae95 100644--- a/src/dev/impl/DevToys/Strings/es-ES/HashGenerator.resw+++ b/src/dev/impl/DevToys/Strings/es-ES/HashGenerator.resw@@ -150,4 +150,13 @@<data name="SearchDisplayName" xml:space="preserve"><value>Generador de Hash</value></data>+ <data name="OutputBase64" xml:space="preserve">+ <value>Base64</value>+ </data>+ <data name="OutputHex" xml:space="preserve">+ <value>Hex</value>+ </data>+ <data name="OutputTypeTitle" xml:space="preserve">+ <value>Tipo de Salida</value>+ </data></root>\ No newline at end of filediff --git a/src/dev/impl/DevToys/Strings/fr-FR/HashGenerator.resw b/src/dev/impl/DevToys/Strings/fr-FR/HashGenerator.reswindex 44badf3f6..6e895157f 100644--- a/src/dev/impl/DevToys/Strings/fr-FR/HashGenerator.resw+++ b/src/dev/impl/DevToys/Strings/fr-FR/HashGenerator.resw@@ -150,4 +150,13 @@<data name="SearchDisplayName" xml:space="preserve"><value>Générateur de Hash</value></data>+ <data name="OutputBase64" xml:space="preserve">+ <value>Base64</value>+ </data>+ <data name="OutputHex" xml:space="preserve">+ <value>Hex</value>+ </data>+ <data name="OutputTypeTitle" xml:space="preserve">+ <value>Le type de sortie</value>+ </data></root>\ No newline at end of filediff --git a/src/dev/impl/DevToys/Strings/hu-HU/HashGenerator.resw b/src/dev/impl/DevToys/Strings/hu-HU/HashGenerator.reswindex 3bd1aad4f..22e24c3ac 100644--- a/src/dev/impl/DevToys/Strings/hu-HU/HashGenerator.resw+++ b/src/dev/impl/DevToys/Strings/hu-HU/HashGenerator.resw@@ -150,4 +150,13 @@<data name="SearchDisplayName" xml:space="preserve"><value>Hash Generátor</value></data>+ <data name="OutputBase64" xml:space="preserve">+ <value>Base64</value>+ </data>+ <data name="OutputHex" xml:space="preserve">+ <value>Hex</value>+ </data>+ <data name="OutputTypeTitle" xml:space="preserve">+ <value>Kimenet típusa</value>+ </data></root>\ No newline at end of filediff --git a/src/dev/impl/DevToys/Strings/id-ID/HashGenerator.resw b/src/dev/impl/DevToys/Strings/id-ID/HashGenerator.reswindex 7a9834bc1..946374015 100644--- a/src/dev/impl/DevToys/Strings/id-ID/HashGenerator.resw+++ b/src/dev/impl/DevToys/Strings/id-ID/HashGenerator.resw@@ -150,4 +150,13 @@<data name="SearchDisplayName" xml:space="preserve"><value>Pembuat Hash</value></data>+ <data name="OutputBase64" xml:space="preserve">+ <value>Base64</value>+ </data>+ <data name="OutputHex" xml:space="preserve">+ <value>Hex</value>+ </data>+ <data name="OutputTypeTitle" xml:space="preserve">+ <value>Jenis keluaran</value>+ </data></root>\ No newline at end of filediff --git a/src/dev/impl/DevToys/Strings/ja-JP/HashGenerator.resw b/src/dev/impl/DevToys/Strings/ja-JP/HashGenerator.reswindex 9c74c92bd..d833e5433 100644--- a/src/dev/impl/DevToys/Strings/ja-JP/HashGenerator.resw+++ b/src/dev/impl/DevToys/Strings/ja-JP/HashGenerator.resw@@ -150,4 +150,13 @@<data name="SearchDisplayName" xml:space="preserve"><value>ハッシュ生成ツール</value></data>+ <data name="OutputBase64" xml:space="preserve">+ <value>Base64</value>+ </data>+ <data name="OutputHex" xml:space="preserve">+ <value>Hex</value>+ </data>+ <data name="OutputTypeTitle" xml:space="preserve">+ <value>出力タイプ</value>+ </data></root>\ No newline at end of filediff --git a/src/dev/impl/DevToys/Strings/pl-PL/HashGenerator.resw b/src/dev/impl/DevToys/Strings/pl-PL/HashGenerator.reswindex 47a2084ae..0b82fc45b 100644--- a/src/dev/impl/DevToys/Strings/pl-PL/HashGenerator.resw+++ b/src/dev/impl/DevToys/Strings/pl-PL/HashGenerator.resw@@ -150,4 +150,13 @@<data name="SearchDisplayName" xml:space="preserve"><value>Generator Hash'y</value></data>+ <data name="OutputBase64" xml:space="preserve">+ <value>Base64</value>+ </data>+ <data name="OutputHex" xml:space="preserve">+ <value>Hex</value>+ </data>+ <data name="OutputTypeTitle" xml:space="preserve">+ <value>Typ wyjścia</value>+ </data></root>\ No newline at end of filediff --git a/src/dev/impl/DevToys/Strings/pt-PT/HashGenerator.resw b/src/dev/impl/DevToys/Strings/pt-PT/HashGenerator.reswindex 148cf59fd..76c054be2 100644--- a/src/dev/impl/DevToys/Strings/pt-PT/HashGenerator.resw+++ b/src/dev/impl/DevToys/Strings/pt-PT/HashGenerator.resw@@ -150,4 +150,13 @@<data name="SearchDisplayName" xml:space="preserve"><value>Gerador de Hash</value></data>+ <data name="OutputBase64" xml:space="preserve">+ <value>Base64</value>+ </data>+ <data name="OutputHex" xml:space="preserve">+ <value>Hex</value>+ </data>+ <data name="OutputTypeTitle" xml:space="preserve">+ <value>Tipo de saída</value>+ </data></root>\ No newline at end of filediff --git a/src/dev/impl/DevToys/Strings/ru-RU/HashGenerator.resw b/src/dev/impl/DevToys/Strings/ru-RU/HashGenerator.reswindex 6cd7f7413..dc79297ee 100644--- a/src/dev/impl/DevToys/Strings/ru-RU/HashGenerator.resw+++ b/src/dev/impl/DevToys/Strings/ru-RU/HashGenerator.resw@@ -150,4 +150,13 @@<data name="SearchDisplayName" xml:space="preserve"><value>Генерирование Hash</value></data>+ <data name="OutputBase64" xml:space="preserve">+ <value>Base64</value>+ </data>+ <data name="OutputHex" xml:space="preserve">+ <value>Hex</value>+ </data>+ <data name="OutputTypeTitle" xml:space="preserve">+ <value>Тип выхода</value>+ </data></root>\ No newline at end of filediff --git a/src/dev/impl/DevToys/Strings/zh-Hans/HashGenerator.resw b/src/dev/impl/DevToys/Strings/zh-Hans/HashGenerator.reswindex 3be7b8b5b..95cd58cdc 100644--- a/src/dev/impl/DevToys/Strings/zh-Hans/HashGenerator.resw+++ b/src/dev/impl/DevToys/Strings/zh-Hans/HashGenerator.resw@@ -150,4 +150,13 @@<data name="SearchDisplayName" xml:space="preserve"><value>哈希散列(Hash)生成工具</value></data>+ <data name="OutputBase64" xml:space="preserve">+ <value>Base64</value>+ </data>+ <data name="OutputHex" xml:space="preserve">+ <value>Hex</value>+ </data>+ <data name="OutputTypeTitle" xml:space="preserve">+ <value>輸出類型</value>+ </data></root>\ No newline at end of filediff --git a/src/dev/impl/DevToys/ViewModels/Tools/Generators/HashGenerator/HashGeneratorToolViewModel.cs b/src/dev/impl/DevToys/ViewModels/Tools/Generators/HashGenerator/HashGeneratorToolViewModel.csindex 8bd8b682d..9dd32edbd 100644--- a/src/dev/impl/DevToys/ViewModels/Tools/Generators/HashGenerator/HashGeneratorToolViewModel.cs+++ b/src/dev/impl/DevToys/ViewModels/Tools/Generators/HashGenerator/HashGeneratorToolViewModel.cs@@ -30,6 +30,15 @@ namespace DevToys.ViewModels.Tools.HashGeneratorisRoaming: true,defaultValue: false);+ /// <summary>+ /// The Output Code to generate.+ /// </summary>+ private static readonly SettingDefinition<string> OutType+ = new(+ name: $"{nameof(HashGeneratorToolViewModel)}.{nameof(OutType)}",+ isRoaming: true,+ defaultValue: DefaultOutputType);+private readonly IMarketingService _marketingService;private readonly ISettingsProvider _settingsProvider;private readonly Queue<string> _hashCalculationQueue = new();@@ -41,6 +50,9 @@ namespace DevToys.ViewModels.Tools.HashGeneratorprivate string? _sha1;private string? _sha256;private string? _sha512;+ private const string HexOutput = "Hex";+ private const string Base64Output = "Base64";+ private const string DefaultOutputType = HexOutput;public Type View { get; } = typeof(HashGeneratorToolPage);@@ -60,6 +72,20 @@ namespace DevToys.ViewModels.Tools.HashGenerator}}+ internal string OutputType+ {+ get => _settingsProvider.GetSetting(OutType);+ set+ {+ if (_settingsProvider.GetSetting(OutType) != value)+ {+ _settingsProvider.SetSetting(OutType, value);+ OnPropertyChanged();+ QueueHashCalculation();+ }+ }+ }+internal string? Input{get => _input;@@ -161,7 +187,15 @@ namespace DevToys.ViewModels.Tools.HashGeneratorIBuffer buffer = CryptographicBuffer.ConvertStringToBinary(text, BinaryStringEncoding.Utf8);buffer = algorithmProvider.HashData(buffer);- string? hash = CryptographicBuffer.EncodeToHexString(buffer);+ string? hash="";+ if (string.Equals(OutputType, HexOutput))+ {+ hash = CryptographicBuffer.EncodeToHexString(buffer);+ }+ else if (string.Equals(OutputType, Base64Output))+ {+ hash = CryptographicBuffer.EncodeToBase64String(buffer);+ }if (IsUppercase){diff --git a/src/dev/impl/DevToys/Views/Tools/Generators/HashGenerator/HashGeneratorToolPage.xaml b/src/dev/impl/DevToys/Views/Tools/Generators/HashGenerator/HashGeneratorToolPage.xamlindex e9cae4efa..572f5e4a2 100644--- a/src/dev/impl/DevToys/Views/Tools/Generators/HashGenerator/HashGeneratorToolPage.xaml+++ b/src/dev/impl/DevToys/Views/Tools/Generators/HashGenerator/HashGeneratorToolPage.xaml@@ -27,6 +27,19 @@Style="{StaticResource RightAlignedToggleSwitchStyle}"IsOn="{x:Bind ViewModel.IsUppercase, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/></controls:ExpandableSettingControl>+ <controls:ExpandableSettingControl+ TabIndex="0"+ Title="{x:Bind ViewModel.Strings.OutputTypeTitle}">+ <controls:ExpandableSettingControl.Icon>+ <FontIcon Glyph="" />+ </controls:ExpandableSettingControl.Icon>+ <ComboBox+ SelectedValuePath="Tag"+ SelectedValue="{x:Bind ViewModel.OutputType, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">+ <ComboBoxItem Tag="Hex" Content="{x:Bind ViewModel.Strings.OutputHex}" />+ <ComboBoxItem Tag="Base64" Content="{x:Bind ViewModel.Strings.OutputBase64}"/>+ </ComboBox>+ </controls:ExpandableSettingControl></StackPanel><controls:CustomTextBox