From c08ba046c9b3f148bf2085b9090a66e4d832583d Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Fri, 11 Aug 2023 11:17:08 +0200 Subject: [PATCH] fixed Windows tool passwort hash creation --- src/RoleEditor/MainWindow.xaml.cs | 13 ++++++------- src/RoleEditor/RoleEditor.csproj | 1 + 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/RoleEditor/MainWindow.xaml.cs b/src/RoleEditor/MainWindow.xaml.cs index 3ce2d2d..b628d14 100644 --- a/src/RoleEditor/MainWindow.xaml.cs +++ b/src/RoleEditor/MainWindow.xaml.cs @@ -238,13 +238,12 @@ namespace RoleEditor u.Username = this.textBoxUserUserName.Text.Trim(); if(this.textBoxUserPassword.Text.Trim().Length > 0 ) { - var data = Encoding.UTF8.GetBytes(this.textBoxUserPassword.Text.Trim()); - using SHA512 sha = SHA512.Create(); - byte[] hashedInputBytes = sha.ComputeHash(data); - var hashedInputStringBuilder = new StringBuilder(128); - foreach (var b in hashedInputBytes) - hashedInputStringBuilder.Append(b.ToString("X2")); - u.PasswordHash = hashedInputStringBuilder.ToString(); + string passwortText = this.textBoxUserPassword.Text.Trim(); + byte[] bytes = Encoding.Default.GetBytes(passwortText); + passwortText = Encoding.UTF8.GetString(bytes); + // Das sollte nicht verändert werden um kompatibel zu der Python Implementierung zu bleiben + string salt = BCrypt.Net.BCrypt.GenerateSalt(12, 'b'); + u.PasswordHash = BCrypt.Net.BCrypt.HashPassword(passwortText, salt); } u.APIKey = this.textBoxUserAPIKey.Text.Trim(); await u.Save(_dbManager); diff --git a/src/RoleEditor/RoleEditor.csproj b/src/RoleEditor/RoleEditor.csproj index 24a3f9e..d2383ef 100644 --- a/src/RoleEditor/RoleEditor.csproj +++ b/src/RoleEditor/RoleEditor.csproj @@ -27,6 +27,7 @@ +