Store password in .EXE

I want to implement password protection for a program I wrote. I do not want to use an external file to store the password. Is it possible to store it as part of an EXE, and if so, how do I do it.

gvangassAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
WMPetersConnect With a Mentor Commented:
Well, you can not write to an exe file while it is running, there is a trick to run allong this....

You make the main .EXE, and a second .EXE, which can only be started by the main .EXE, and will be after the user changed his password.

When the user changes it's password, the main .EXE stores it in the secondary .EXE, and sets a flag to start the secondary .EXE when the main .EXE quits. After quitting the main .EXE, the secondary .EXE get launched, read its password, and attach this to the main .EXE, and also quits. No need for GUI, just a simple dos or dos-like program can do this, in a split second. So the user will not kown or confronted with odd screens/messages.

So, the secondary .EXE has one job only, and that is to attach passwords to the main .EXE .  By starting the secondary .EXE with parameters, you can avoid users directly starting the secondary .EXE. When a user delete's the secondary .EXE, he/she still can use the main .EXE, but not longer change the password.

It is not that difficult, it's only that Windows locks a file while in use.

Another way could be:
When a .EXE file execute's, it make a copy of itself and that copy can be altered. After quitting, the copy will replace the original. Problem might be....copying while in use (i know that there are tricks herefore too...)

0
 
umuligCommented:
http://homepages.tig.com.au/~lonewolf/delphi/tips/0007.html
I Think this is what you need

Regards

Ted
0
 
King_DavidCommented:
The problem with Exes is that you can
not write to them while they are running.

Regards,
 David.
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
umitdeCommented:
I used this Method in my program to password protection.
procedure TfrmMain.FormCreate(Sender: TObject);
Var
  PCount     : Word;
  MyPassword : String;
begin
  For PCount := 1 To ParamCount Do
  begin
    Case PCount of
      1 : Username := ParamStr(PCount);
      2 : MyPassword := ParamStr(PCount);
    end;
  end;
  if MyPassword <> 'Mypasword' then
  begin
    MessageDlg('You can't use this Program', mtError, [mbOk], 0);
  Application.Terminate;
  end;
end;

first Parameter is User Name, Second Paramater is my password.
0
 
ma8yrCommented:
Do you want this passord to be changeable?

if not then try using a resource file, you can compile them into the exe, without the exe giving the password
away.
the alternative it to hard code it and use an app like AsPak to pack and encrypt it.
you could also consider a simple encrypted registry value, held under an inconspicuous name.


if you do want it changeable then I think you're out of luck, I don't think it's possible.
0
 
SuperSyCommented:
<Listening>
0
All Courses

From novice to tech pro — start learning today.