Skip to content

Commit

Permalink
Add icon && refactor GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
mjbohn committed Jul 22, 2024
1 parent be7bce3 commit 7359ce9
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 19 deletions.
30 changes: 16 additions & 14 deletions TokenGeneratorJWT/Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 19 additions & 4 deletions TokenGeneratorJWT/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public partial class Form1 : Form
public Form1()
{
InitializeComponent();
SetParamsForKeyAlgorithm(SecurityAlgorithm,MinKeyLength);
StatusLabelVersion.Text = Assembly.GetEntryAssembly().GetName().Version.ToString();
SetParamsForKeyAlgorithm(SecurityAlgorithm, MinKeyLength);
StatusLabelVersion.Text = GetVersion();
}

private void buttonBuildToken_Click(object sender, EventArgs e)
Expand Down Expand Up @@ -75,7 +75,15 @@ private void buttonBuildToken_Click(object sender, EventArgs e)
signingCredentials: credentials);


TokenString = new JwtSecurityTokenHandler().WriteToken(token);
try
{
TokenString = new JwtSecurityTokenHandler().WriteToken(token);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}

PayloadJSON = JsonNode.Parse(token.Payload.SerializeToJson()).ToString();

Expand Down Expand Up @@ -201,7 +209,7 @@ private void exitToolStripMenuItem_Click(object sender, EventArgs e)
}
#endregion // MenuEvents

#region helper
#region Helper
private void ShowKeylength(TextBox tb)
{
textBoxKeyLength.Text = (tb.Text.Length * 8).ToString() + " bit";
Expand Down Expand Up @@ -240,6 +248,13 @@ private void SetEncryptionAlgorithm(object sender, EventArgs e)
break;
}
}

private string GetVersion()
{
return $"v{Assembly.GetEntryAssembly().GetName().Version.Major}" +
$".{Assembly.GetEntryAssembly().GetName().Version.Minor}" +
$".{Assembly.GetEntryAssembly().GetName().Version.Build}";
}
#endregion //helper
}
}
20 changes: 20 additions & 0 deletions TokenGeneratorJWT/Form1.resx
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,24 @@
<metadata name="menuStripMainMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>417, 17</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
AAABAAEAEBAAAAEAGABoAwAAFgAAACgAAAAQAAAAIAAAAAEAGAAAAAAAAAAAAEgAAABIAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAdGhQpJRwBAQEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAZAEYYAEMAAABV
TTt6blQEBAMKCQBEPQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIABZTAOpQAOAIABhVTTt6blQEBAOYiAD+
5ABPRgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAjAGNXAPVAALNWTTx6blRWTQP/5QDMtwAGBgAAAAAAAAAA
AAAAAAAAAAC1AJuMAHg6ADI9AKdXAPVVOWhqX0fu1QHy2QAlIQAvIwhwUxMAAAAAAAAAAAAYABXnAMb5
ANX5ANXeAMc3AHYKARgLCgecjADAmhPTnCP2tin2tikqHwcAAAAAAAAAAAAFAARDADqXBH7CDZoqACQA
AAAAAAAjGgbsrifmqiaachpKNwwHBQEAAAAAAAAHBQFLNwyZcRnkqSbtsCgjGgYAAAAAAAAoACPBDJmb
BIFEADoFAAQAAAAAAAAAAAAqHwf2tin2tinXnyTBmhSciwALCQcKARk3AHfeAMb5ANX5ANXnAMUYABQA
AAAAAAAAAABxUxMzJggmIQDz2gDs1AFpXkhWOWpXAPU8AKc1AC6IAHS0AJoAAAAAAAAAAAAAAAAAAAAG
BQDMtwD/5QBXTwN6blRVTDw/ALJXAPUjAGMAAAAAAAAAAAAAAAAAAAAAAAAAAABNRQD+5ACXiAAFBAN6
blRVTDoIABhPAOBTAOoHABUAAAAAAAAAAAAAAAAAAAAAAAAAAABDPAAKCQAFBAN6blRVTDoAAAAYAEQa
AEkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAQEpJRwdGhQAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//wAA/j8AAPIP
AADgBwAA8AcAAMADAACAAQAAwYEAAIGDAACAAQAAwAMAAOAPAADgBwAA8E8AAPx/AAD//wAA
</value>
</data>
</root>
15 changes: 14 additions & 1 deletion TokenGeneratorJWT/TokenGeneratorJWT.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,22 @@
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
<Version>1.3.1</Version>
<Version>1.4.0</Version>
<PackageIcon>icons8-jwt-128.png</PackageIcon>
<ApplicationIcon>icons8-jwt-128.ico</ApplicationIcon>
</PropertyGroup>

<ItemGroup>
<Content Include="icons8-jwt-128.ico" />
</ItemGroup>

<ItemGroup>
<None Include="..\icons\icons8-jwt-128.png">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
</ItemGroup>

<ItemGroup>
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.0.0" />
</ItemGroup>
Expand Down
Binary file added TokenGeneratorJWT/icons8-jwt-128.ico
Binary file not shown.
Binary file added icons/icons8-jwt-128.ico
Binary file not shown.
Binary file added icons/icons8-jwt-16tr.ico
Binary file not shown.

0 comments on commit 7359ce9

Please sign in to comment.