fixed Windows tool passwort hash creation

This commit is contained in:
Daniel Schick 2023-08-11 11:17:08 +02:00
parent 6e764aa043
commit c08ba046c9
2 changed files with 7 additions and 7 deletions

View File

@ -238,13 +238,12 @@ namespace RoleEditor
u.Username = this.textBoxUserUserName.Text.Trim(); u.Username = this.textBoxUserUserName.Text.Trim();
if(this.textBoxUserPassword.Text.Trim().Length > 0 ) if(this.textBoxUserPassword.Text.Trim().Length > 0 )
{ {
var data = Encoding.UTF8.GetBytes(this.textBoxUserPassword.Text.Trim()); string passwortText = this.textBoxUserPassword.Text.Trim();
using SHA512 sha = SHA512.Create(); byte[] bytes = Encoding.Default.GetBytes(passwortText);
byte[] hashedInputBytes = sha.ComputeHash(data); passwortText = Encoding.UTF8.GetString(bytes);
var hashedInputStringBuilder = new StringBuilder(128); // Das sollte nicht verändert werden um kompatibel zu der Python Implementierung zu bleiben
foreach (var b in hashedInputBytes) string salt = BCrypt.Net.BCrypt.GenerateSalt(12, 'b');
hashedInputStringBuilder.Append(b.ToString("X2")); u.PasswordHash = BCrypt.Net.BCrypt.HashPassword(passwortText, salt);
u.PasswordHash = hashedInputStringBuilder.ToString();
} }
u.APIKey = this.textBoxUserAPIKey.Text.Trim(); u.APIKey = this.textBoxUserAPIKey.Text.Trim();
await u.Save(_dbManager); await u.Save(_dbManager);

View File

@ -27,6 +27,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="BCrypt.Net-Next" Version="4.0.3" />
<PackageReference Include="Extended.Wpf.Toolkit" Version="4.5.0" /> <PackageReference Include="Extended.Wpf.Toolkit" Version="4.5.0" />
</ItemGroup> </ItemGroup>