diff --git a/src/users/User.pas b/src/users/User.pas index b40feb2c..15d9a401 100644 --- a/src/users/User.pas +++ b/src/users/User.pas @@ -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; end; // class TUser @@ -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; /// ///////////////////////////////////////////////////////////////////////////// @@ -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;