diff --git a/Toolbox/GUI/HashCalculatorForm.Designer.cs b/Toolbox/GUI/HashCalculatorForm.Designer.cs index 1a5e906e..333535b7 100644 --- a/Toolbox/GUI/HashCalculatorForm.Designer.cs +++ b/Toolbox/GUI/HashCalculatorForm.Designer.cs @@ -48,6 +48,7 @@ this.bruteForceHashTB = new Toolbox.Library.Forms.STTextBox(); this.stLabel5 = new Toolbox.Library.Forms.STLabel(); this.stLabel4 = new Toolbox.Library.Forms.STLabel(); + this.chkLittleEndian = new Toolbox.Library.Forms.STCheckBox(); this.contentContainer.SuspendLayout(); this.stPanel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.maxLengthUD)).BeginInit(); @@ -55,6 +56,7 @@ // // contentContainer // + this.contentContainer.Controls.Add(this.chkLittleEndian); this.contentContainer.Controls.Add(this.stLabel4); this.contentContainer.Controls.Add(this.stPanel1); this.contentContainer.Controls.Add(this.chkUseHex); @@ -74,6 +76,7 @@ this.contentContainer.Controls.SetChildIndex(this.chkUseHex, 0); this.contentContainer.Controls.SetChildIndex(this.stPanel1, 0); this.contentContainer.Controls.SetChildIndex(this.stLabel4, 0); + this.contentContainer.Controls.SetChildIndex(this.chkLittleEndian, 0); // // stringTB // @@ -276,6 +279,19 @@ this.stLabel4.TabIndex = 19; this.stLabel4.Text = "Brute Force:"; // + // chkLittleEndian + // + this.chkLittleEndian.AutoSize = true; + this.chkLittleEndian.Checked = true; + this.chkLittleEndian.CheckState = System.Windows.Forms.CheckState.Checked; + this.chkLittleEndian.Location = new System.Drawing.Point(559, 45); + this.chkLittleEndian.Name = "chkLittleEndian"; + this.chkLittleEndian.Size = new System.Drawing.Size(139, 17); + this.chkLittleEndian.TabIndex = 20; + this.chkLittleEndian.Text = "Preview as Little Endian"; + this.chkLittleEndian.UseVisualStyleBackColor = true; + this.chkLittleEndian.CheckedChanged += new System.EventHandler(this.chkLittleEndian_CheckedChanged); + // // HashCalculatorForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -314,5 +330,6 @@ private Library.Forms.STTextBox characterStartTB; private Library.Forms.STLabel stLabel8; private Library.Forms.STCheckBox chkSearchNumbered; + private Library.Forms.STCheckBox chkLittleEndian; } } \ No newline at end of file diff --git a/Toolbox/GUI/HashCalculatorForm.cs b/Toolbox/GUI/HashCalculatorForm.cs index f1902a10..18de22b5 100644 --- a/Toolbox/GUI/HashCalculatorForm.cs +++ b/Toolbox/GUI/HashCalculatorForm.cs @@ -16,6 +16,8 @@ namespace Toolbox { private bool IsHex => chkUseHex.Checked; + private bool IsLittleEndian => chkLittleEndian.Checked; + public HashCalculatorForm() { InitializeComponent(); @@ -37,18 +39,27 @@ namespace Toolbox private void UpdateHash() { - ulong Hash = CalculateHash(hashTypeCB.GetSelectedText(), stringTB.Text); + dynamic Hash = CalculateHash(hashTypeCB.GetSelectedText(), stringTB.Text); if (IsHex) - resultTB.Text = Hash.ToString("X"); + resultTB.Text = IsLittleEndian ? LittleEndian(Hash) : Hash.ToString("X"); else resultTB.Text = Hash.ToString(); } + static string LittleEndian(dynamic number) + { + byte[] bytes = BitConverter.GetBytes(number); + string retval = ""; + foreach (byte b in bytes) + retval += b.ToString("X2"); + return retval; + } + private void chkUseHex_CheckedChanged(object sender, EventArgs e) { UpdateHash(); } - public static ulong CalculateHash(string type, string text) + public static dynamic CalculateHash(string type, string text) { if (type == "NLG_Hash") return StringToHash(text); @@ -328,5 +339,9 @@ namespace Toolbox private void hashTypeCB_SelectedIndexChanged(object sender, EventArgs e) { UpdateHash(); } + + private void chkLittleEndian_CheckedChanged(object sender, EventArgs e) { + UpdateHash(); + } } }