Facebook   Twitter    YouTube    RSS Feed    Android App    iPhone and iPad App     BlackBerry App    
Subscribe to Newsletter



Results 1 to 4 of 4

Thread: Simple Delphi application - to generate passwords

  1. #1

    Default Simple Delphi application - to generate passwords

    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;

  2. #2
    Grandmaster Scooby_Doo's Avatar
    Join Date
    Sep 2005
    Location
    In a Box, Next to a tree.
    Posts
    4,396

    Default

    Since you can treat a string var as an array try

    Password[ncount] := Alphabets[nIndex];
    =====
    If trees could scream would we be so cavalier about cutting them down. What if they screamed all the time for no reason?
    =====

  3. #3

    Default

    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;
    Telkom Telkom. IF you are wondering about the invisible text, it's to catch Telkoms and other tsotsis

  4. #4

    Default

    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

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •