Ver Mensaje Individual
  #4  
Antiguo 26-11-2015
Avatar de AgustinOrtu
[AgustinOrtu] AgustinOrtu is offline
Miembro Premium
NULL
 
Registrado: ago 2013
Ubicación: Argentina
Posts: 1.858
Reputación: 17
AgustinOrtu Es un diamante en brutoAgustinOrtu Es un diamante en brutoAgustinOrtu Es un diamante en brutoAgustinOrtu Es un diamante en bruto
Por cierto este es el codigo que use

Código Delphi [-]
const
  Codes64: array [0 .. 63] of string = ('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F',
    'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c',
    'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
    '+', '/');

function Encode64(S: Integer): string;
var
  cociente, resto: Integer;
  cadena: string;
begin
  cociente := 1;
  cadena := '';
  while cociente > 0 do
  begin
    cociente := S div 64;
    resto := S mod 64;
    cadena := cadena + Codes64[resto];
    S := cociente;
  end;
  Result := cadena;
end;

procedure Test(const BigNumber: Integer; Output, Errors: TStrings);
var
  I, LValue: Integer;
  LBase64: string;
begin
  Output.Clear;
  Errors.Clear;

  Output.BeginUpdate;
  Errors.BeginUpdate;
  try
    Randomize;
    for I := 1 to 500 do
    begin
      LValue := Random(BigNumber);
      try
        LBase64 := Encode64(LValue);
        Output.Add(Format('LValue %d ---> Encode64: %s', [LValue, LBase64]));
      except
        on E: Exception do
          Errors.Add(Format('ERROR: LValue %d, Exception %s', [LValue, E.Message]));
      end;
    end;
  finally
    Output.EndUpdate;
    Errors.EndUpdate;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  Test(StrToInt(Edit1.Text), Memo1.Lines, Memo2.Lines);
end;
Responder Con Cita