Skip to content
Snippets Groups Projects
Commit 8aea5e3c authored by Dennis Eisold's avatar Dennis Eisold
Browse files

Merge branch 'master' into 'master'

FrontendId in settings

See merge request wetterstation/frontend!9
parents 008e15cc e662cac4
No related branches found
No related tags found
No related merge requests found
......@@ -308,6 +308,7 @@
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.Name = "Settings";
this.Text = "Settings";
this.Load += new System.EventHandler(this.Settings_Load);
this.ResumeLayout(false);
this.PerformLayout();
......
......@@ -8,6 +8,7 @@ using System.Management;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Security.Cryptography;
namespace Wetterstation
{
......@@ -16,7 +17,7 @@ namespace Wetterstation
public Settings()
{
InitializeComponent();
generateId();
lblFrontendId.Text = "Frontend Id: " + generateId();
}
private void TextBox2_TextChanged(object sender, EventArgs e)
......@@ -29,7 +30,10 @@ namespace Wetterstation
}
private void generateId() {
private String generateId()
{
String result = "Could not found id";
try {
ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_Processor");
......@@ -41,11 +45,42 @@ namespace Wetterstation
Console.WriteLine("Caption: {0}", queryObj["Caption"]);
Console.WriteLine("Family: {0}", queryObj["Family"]);
Console.WriteLine("ProcessorId: {0}", queryObj["ProcessorId"]);
Console.WriteLine("Username: {0}", Environment.UserName);
result = queryObj["ProcessorId"] + Environment.UserName;
}
}
catch (ManagementException e) {
MessageBox.Show("An error occurred while querying for WMI data: " + e.Message);
}
using (MD5 md5Hash = MD5.Create())
{
return GetMd5Hash(md5Hash, result);
}
}
private string GetMd5Hash(MD5 md5Hash, string input)
{
// Convert the input string to a byte array and compute the hash.
byte[] data = md5Hash.ComputeHash(Encoding.UTF8.GetBytes(input));
// Create a new Stringbuilder to collect the bytes
// and create a string.
StringBuilder sBuilder = new StringBuilder();
// Loop through each byte of the hashed data
// and format each one as a hexadecimal string.
for (int i = 0; i < data.Length; i++)
{
sBuilder.Append(data[i].ToString("x2"));
}
// Return the hexadecimal string.
return sBuilder.ToString();
}
private void Settings_Load(object sender, EventArgs e)
{
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment