Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using a date function to check a password

Status
Not open for further replies.

tania20

Programmer
Oct 30, 2006
148
AU
Hi, I am trying to write a pascal script for inno setup that is based on the date, but have no experience with pascal. I have trued the following code but it does not seem to reconise the date functions. Why is this? Or how should i be approaching this?

Cheers

Tania

Var
S1 : String;

function CheckPassword(Password: String): Boolean;
begin

S1:=DateToStr(Now);
String = S1

end;
 
Hi

First of all, what kind of Pascal are you using ? Because good old Pascal has no [tt]DateToStr[/tt] function, only Delphi/Kylix, FreePascal or other modern implementations have it.

Instead you could use the [tt]GetDate[/tt] procedure, which returns the parts of the current date as [tt]Word[/tt] values.

Feherke.
 
its ok, i figured it out-hadnt originally noticed the inno specifc pascal functions...this may come in handy to someone else wanting to set up some form of password using inno...

Var
PassCode,Date, Date1, Date2, Date3, Date4 : String;
DateInt: Longint;

const
Code1 = 't8y';
Code2 = 'pyi';
Code3 = 'nn6l';

function CheckPassword(Password: String): Boolean;
begin

Date := GetDateTimeString ('ddmm', '-', ':'); //returns d1d2m1m2 string
DateInt := StrToIntDef(Date,1);
DateInt := DateInt + 1523;
Date := IntToStr(DateInt);

Date1 := Copy(Date,1,1); //returns d1
Date2 := Copy(Date,2,1); //returns d2
Date3 := Copy(Date,3,1); //returns m1
Date4 := Copy(Date,4,1); //returns m2
PassCode := Code1 + Date1 + Code3 + Date2 + Date3 + Code2 + Date4;

if Password = Passcode then //if entered password matches this passcode then they can continue
Result := True;

end;
 
Hi

It is a nice habit to post the solution when figure it out yourself.

But I feel there is still an open question : in what kind of Pascal is written your code ?

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top