Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for incorrect base64 hashes #397

Merged
merged 1 commit into from
Feb 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -190,21 +190,15 @@ private async Task<string> CalculateHashAsync(string alrogithmName, string text)
string? hash="";
if (string.Equals(OutputType, HexOutput))
{
hash = CryptographicBuffer.EncodeToHexString(buffer);
hash = IsUppercase
? CryptographicBuffer.EncodeToHexString(buffer).ToUpperInvariant()
: CryptographicBuffer.EncodeToHexString(buffer).ToLowerInvariant();
}
else if (string.Equals(OutputType, Base64Output))
{
hash = CryptographicBuffer.EncodeToBase64String(buffer);
}

if (IsUppercase)
{
return hash.ToUpperInvariant();
}
else
{
return hash.ToLowerInvariant();
}
return hash;
}
catch (Exception ex)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<FontIcon Glyph="&#xF7B2;" />
</controls:ExpandableSettingControl.Icon>
<ToggleSwitch
x:Name="IsUppercaseToggleSwitch"
Style="{StaticResource RightAlignedToggleSwitchStyle}"
IsOn="{x:Bind ViewModel.IsUppercase, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
</controls:ExpandableSettingControl>
Expand All @@ -35,7 +36,8 @@
</controls:ExpandableSettingControl.Icon>
<ComboBox
SelectedValuePath="Tag"
SelectedValue="{x:Bind ViewModel.OutputType, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
SelectedValue="{x:Bind ViewModel.OutputType, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
SelectionChanged="OutputType_SelectionChanged">
<ComboBoxItem Tag="Hex" Content="{x:Bind ViewModel.Strings.OutputHex}" />
<ComboBoxItem Tag="Base64" Content="{x:Bind ViewModel.Strings.OutputBase64}"/>
</ComboBox>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,17 @@ protected override void OnNavigatedTo(NavigationEventArgs e)

base.OnNavigatedTo(e);
}

private void OutputType_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if ((sender as ComboBox)?.SelectedValue as string == "Base64")
{
IsUppercaseToggleSwitch.IsEnabled = false;
}
else
{
IsUppercaseToggleSwitch.IsEnabled = true;
}
}
}
}