Skip to content

Commit

Permalink
Fix type.
Browse files Browse the repository at this point in the history
  • Loading branch information
horacekj committed May 8, 2023
1 parent 5e142f3 commit 4b96b2e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/users/User.pas
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ TUser = class
function ComparePasswd(plain: string): Boolean; overload;
class function ComparePasswd(plain: string; hash: string; salt: string): Boolean; overload;
// check password match; return true iff match
class function GenerateHash(plain: AnsiString): string;
class function GenerateHash(plain: string): string;
class function NameComparer(): IComparer<TUser>;
end; // class TUser

Expand Down Expand Up @@ -201,7 +201,7 @@ procedure TUser.SetPasswd(passwd: string);
begin
// hash password 2 times
Self.fsalt := Self.GenSalt();
Self.fpasswd := TUser.GenerateHash(AnsiString(TUser.GenerateHash(AnsiString(passwd)) + Self.fsalt));
Self.fpasswd := TUser.GenerateHash(TUser.GenerateHash(passwd) + Self.fsalt);
end;

/// /////////////////////////////////////////////////////////////////////////////
Expand All @@ -227,10 +227,10 @@ function TUser.ComparePasswd(plain: string): Boolean;

class function TUser.ComparePasswd(plain: string; hash: string; salt: string): Boolean;
begin
Result := (hash = TUser.GenerateHash(AnsiString(LowerCase(plain + salt))));
Result := (hash = TUser.GenerateHash(LowerCase(plain + salt)));
end;

class function TUser.GenerateHash(plain: AnsiString): string;
class function TUser.GenerateHash(plain: string): string;
begin
Result := LowerCase(System.hash.THashSHA2.GetHashString(plain, SHA256));
end;
Expand Down

0 comments on commit 4b96b2e

Please sign in to comment.