hi everyone...
i am in grade 11 at a college in australia and i was wondering if i could get a little help with an assignment i am having trouble with..
what i need to know is:
what is the appropriate coding to put password security on a program i am making? the password for the program needs to be 6 chaacters (numbers only) long and the user has three attempts access the program with the correct code before it terminates.
i would be sooo grateful if you could help me with this..
Thankyou very much!
-Natalia
Comments
: i am in grade 11 at a college in australia and i was wondering if i could get a little help with an assignment i am having trouble with..
:
: what i need to know is:
:
: what is the appropriate coding to put password security on a program i am making? the password for the program needs to be 6 chaacters (numbers only) long and the user has three attempts access the program with the correct code before it terminates.
:
: i would be sooo grateful if you could help me with this..
:
: Thankyou very much!
: -Natalia
:
See the main Delphi board for the answer to this question.
[code]
const
C1 = 52845;
C2 = 22719;
function encrypt(const S: String; Key: Word): String;
var
I: byte;
begin
Result[0] := S[0];
for I := 1 to Length(S) do begin
Result[I] := char(byte(S[I]) xor (Key shr 8));
Key := (byte(Result[I]) + Key) * C1 + C2;
end;
end;
function Decrypt(const S: String; Key: Word): String;
var
I: byte;
begin
Result[0] := S[0];
for I := 1 to Length(S) do begin
Result[I] := char(byte(S[I]) xor (Key shr 8));
Key := (byte(S[I]) + Key) * C1 + C2;
end;
end;
[/code]