Simple Delphi application - to generate passwords

Dumzaz

Active Member
Joined
Jul 23, 2007
Messages
38
Reaction score
0
Hi all I need to develop a simple Delphi app - that generates passwords. Each password must be six characters long - selected randomly - and it must be alpha-numeric. Here is what I have so far. I am using an array to store the alphabets. If i can get the simple version to work, i will extend it.

Problem with mine is that it does not concatenate the string - it only returns one character

begin
Randomize;
Password := '';
for nCounter := 1 to 5 do;
begin
nIndex := Random(5) + 1;
Password := Password + Alphabets[nIndex];
end;
edtShowPassWord.Text := Password;
end;
 
Your random function is all wrong and the randomize must be in form.create not the button code.

//CODE: Produces Upper&Lower case and 0-9 pwds
var Password:String;
Picked,Count:integer;
begin
//Dumzaz's homework
Password:='';
For Count:=1 to 6 do
begin
Picked:=Random(62);
Case Picked of
0..9:Password:=Password+inttostr(picked);
10..35:Password:=Password+chr(Picked-10+65);
36..61:Password:=Password+chr(Picked-36+97);
end;
end;
Showmessage(Password);
end;
 
Thanks, I see I was going about the wrongway altogether. It works. It seems i need to understand how to use this function

function Chr(X: Byte): Char;

Description
Chr returns the character with the ordinal value (ASCII value) of the byte-type expression, X.


Thanks
 
Top
Sign up to the MyBroadband newsletter
X