dcsimg
Login | Register   
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: Design Patterns
Expertise: Beginner
Oct 30, 1998

WEBINAR:

On-Demand

Application Security Testing: An Integral Part of DevOps


Application Design and Passwords

Question:
How do you protect an application with a password and store it in the application's exe-file?

Answer:
You'd have to hard code the password in. Then in the FormCreate method of your main form, you'd do something like this:

procedure TForm1.FormCreate(Sender: TObject);
var
  pwrd : String;
  PassOK : Boolean;
begin
  Counter := 1;
  PassOK := False;
  while (Counter < 4) do begin
    InputQuery('Type in a password',
               'You have ' + IntToStr(4 - Counter) + ' tries left',
               pwrd);
    if (pwrd = 'MyPassword') then begin
      PassOK := True;
      Break;
    end;
      Inc(Counter);
  end;

  if NOT PassOK then begin
    ShowMessage('Exceeded maximum number of tries. ' +
                'Press OK to terminate.');
    Application.Terminate;
  end;
end;
This simple password validation gives the user three tries to come up with the correct password. You could be more elaborate by using a resource file with a string resource that is read at run time.
DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date