[DELPHI] - Generate Random Password

On viernes, 13 de agosto de 2010 0 comentarios

function RandomPassword(PLen: Integer): string;
var
  str: string;
begin
  Randomize;
    str := 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVW XYZ';
    Result := '';

  repeat
    Result := Result + str[Random(Length(str)) + 1];
  until (Length(Result) = PLen)
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  label1.Caption := RandomPassword(10);
end;

0 comentarios:

Publicar un comentario