Ver Mensaje Individual
  #2  
Antiguo 07-06-2010
Avatar de Casimiro Notevi
Casimiro Notevi Casimiro Notevi is offline
Moderador
 
Registrado: sep 2004
Ubicación: En algún lugar.
Posts: 32.057
Reputación: 10
Casimiro Notevi Tiene un aura espectacularCasimiro Notevi Tiene un aura espectacular
Si es aleatoria entonces será una cadena de texto, no?

Código Delphi [-]
function DameClave( iLongitud:integer; iTipo:integer=1 ) : string;
const
  cValoresNum      = '0123456789';
  cValoresAlpha    = 'abcdefghijklmnopqrstuvwxyz';
  cValoresAlphaNum = cValoresNum + cValoresAlpha;
var
  iX : integer;
begin
  Result := '';
  //
  Randomize;  
  //
  case iTipo of
    0 : for iX := 1 to iLongitud do
          Result := Result + cValoresNum[ Random(length(cValoresNum))+1 ];
    1 : for iX := 1 to iLongitud do
          Result := Result + cValoresAlpha[ Random(length(cValoresAlpha))+1 ];
    2 : for iX := 1 to iLongitud do
          Result := Result + cValoresAlphaNum[ Random(length(cValoresAlphaNum))+1 ];
  end;
end;

Y para llamarla está claro, le dices la longitud y el tipo.
Responder Con Cita