Passwort verslüsselt
This commit is contained in:
+21
-3
@@ -14,6 +14,8 @@ using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
using Mysqlx.Cursor;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
|
||||
namespace Casino
|
||||
{
|
||||
@@ -32,7 +34,7 @@ namespace Casino
|
||||
|
||||
private void Anmelden_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (checkLogin(TxtName.Text, TxtPasswort.Text))
|
||||
if (checkLogin(TxtName.Text, TxtPasswort.Password))
|
||||
{
|
||||
|
||||
MainWindow mainWindow = new MainWindow();
|
||||
@@ -51,11 +53,13 @@ namespace Casino
|
||||
Database db = new Database();
|
||||
ObservableCollection<User> users = new ObservableCollection<User>();
|
||||
users = db.GetUser();
|
||||
string hash = HashPassword(passwort);
|
||||
|
||||
for (int i = 0; i < users.Count(); i++)
|
||||
{
|
||||
if (name.Equals(users[i].Name))
|
||||
{
|
||||
if(passwort.Equals(users[i].Passwort)) {
|
||||
if(hash.Equals(users[i].Passwort)) {
|
||||
MainWindow.currentUser = i;
|
||||
return true;
|
||||
}
|
||||
@@ -70,5 +74,19 @@ namespace Casino
|
||||
if (e.LeftButton == MouseButtonState.Pressed)
|
||||
DragMove();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public string HashPassword(string password)
|
||||
{
|
||||
using (SHA256 sha256 = SHA256.Create())
|
||||
{
|
||||
byte[] bytes = Encoding.UTF8.GetBytes(password);
|
||||
byte[] hash = sha256.ComputeHash(bytes);
|
||||
|
||||
return Convert.ToHexString(hash);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user