Topic: Password Char in InputBox

Can anyone help on how to hide the password on this code.
i want the output like when I input a character in input box it looks like this '*'.

This is the code:

procedure Form1_Button7_OnClick (Sender: string; var Cancel: boolean);
begin

If InputBox('To continue, enter Admin Password!', 'Enter Password:', '')='xray2024' then

    begin
      Form1.Button6.click;
    end else
    begin
      MessageDlg('Incorrect Password', mtError, mbOk, 0);
    end;
end;

2 (edited by sparrow 2024-07-19 10:07:04)

Re: Password Char in InputBox

Try this

procedure Form1_Button7_OnClick (Sender: string; var Cancel: boolean);
begin

If InputBox('To continue, enter Admin Password!',  #0 + 'Enter Password:', '')='xray2024' then

    begin
      Form1.Button6.click;
    end else
    begin
      MessageDlg('Incorrect Password', mtError, mbOk, 0);
    end;
end;

///////  OR this ////////////

procedure Form1_Button7_OnClick (Sender: string; var Cancel: boolean);
var
  pasVal: string;
begin
  if InputQuery('To continue, enter Admin Password!', #0 + 'Enter Password:', pasVal)
    then if pasVal = 'xray2024' then MessageDlg('Correct Password', mtInformation , mbOk, 0) else MessageDlg('Incorrect Password', mtError, mbOk, 0);
  pasVal := '';
end;

Re: Password Char in InputBox

Hi Aceg86705, Привіт Sparrow - Як поживаєш?
Welcome to the Forum.
MVD also has standard 'role-based' functionality that can password protect not just logging on to your application but which can also limit / grant access (or read-only access etc)  to different functions, different forms, different fields etc within your application depending on the assigned role.  Passwords are fully encrypted and no script is required.
However, holding passwords directly in a script as per your message does make it relatively straightforward to uncover.
You should also be aware that MVD is no longer being actively developed but support is always available from volunteers via this Forum.
Regards,
Derek.

4 (edited by k245 2024-07-19 15:21:10)

Re: Password Char in InputBox

Use StrToMD5() function:

procedure Form1_Button7_OnClick (Sender: string; var Cancel: boolean);
begin

If  StrToMD5(InputBox('To continue, enter Admin Password!', 'Enter Password:', ''))='8765BF543ААА8765А45300CCA' then

    begin
      Form1.Button6.click;
    end else
    begin
      MessageDlg('Incorrect Password', mtError, mbOk, 0);
    end;
end;

Calculate the hash value in advance.  And don't forget to delete the scpript.pas file from the end user's copy of the program.


Some info about Authentication

https://k245.ru/wp-content/uploads/2022/09/autentifikatsiya.jpg
https://k245.ru/en/mvdb-en/authentication.html

Визуальное программирование: блог и телеграм-канал.