Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Programmieren allgemein (https://www.delphipraxis.net/40-programmieren-allgemein/)
-   -   check username/password (https://www.delphipraxis.net/177245-check-username-password.html)

question 28. Okt 2013 09:01

check username/password
 
hi,
I have a table called "userdata" which contains (username, password)
I have a window in Delphi with two edit fields username and password and one button "Login"
After typing username and password, when I click on "Login" button, I would like to check whether username and password is match or not
I have tried with following code but it is not working
Code:
procedure TForm1.Checkuserdata(Sender: TObject);
begin
  Table.Open;
  Table.First;
  while not Table.Eof do begin
    if (Edit1.Text = Table.FieldByName('username').AsString) and
   (Edit2.Text = Table.FieldByName('password').AsString)
   then
       Showmessage('match the user data');
       exit;
    end;

FBrust 28. Okt 2013 09:15

AW: check username/password
 
Hello,

in your while-loop, you should place a "Table.Next":

Delphi-Quellcode:
procedure TForm1.Checkuserdata(Sender: TObject);
begin
  Table.Open;
  Table.First;
  while not Table.Eof do begin
    if (Edit1.Text = Table.FieldByName('username').AsString) and
       (Edit2.Text = Table.FieldByName('password').AsString)
    then begin
      Showmessage('match the user data');
      exit;
    end;
    Table.Next;
  end;
end;

generic 28. Okt 2013 11:03

AW: check username/password
 
for security you never should store plain password's in databases.
use a hash function with salt, please.

question 28. Okt 2013 12:47

AW: check username/password
 
Zitat:

Zitat von generic (Beitrag 1233406)
for security you never should store plain password's in databases.
use a hash function with salt, please.

Thank you very much for your reply
currently, i am saving the plain text(Edit2.Text) as a password, how can i use hash function with salt
there is already a page about it http://www.delphipraxis.net/176994-s...eichern-2.html
but since my German skill is not that good, therefore, to have a small example would be kind of you

generic 31. Okt 2013 13:33

AW: check username/password
 
Zitat:

Zitat von question (Beitrag 1233444)
Zitat:

Zitat von generic (Beitrag 1233406)
for security you never should store plain password's in databases.
use a hash function with salt, please.

Thank you very much for your reply
currently, i am saving the plain text(Edit2.Text) as a password, how can i use hash function with salt
there is already a page about it http://www.delphipraxis.net/176994-s...eichern-2.html
but since my German skill is not that good, therefore, to have a small example would be kind of you

Try this: https://crackstation.net/hashing-security.htm

Perlsau 31. Okt 2013 13:52

AW: check username/password
 
Why not working with locate?
Delphi-Quellcode:
if not Table.locate('username; passwort', VarArrayOf([Username, Password], []) then
   ShowMessage('Wrong user and password');


Alle Zeitangaben in WEZ +1. Es ist jetzt 22:39 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz