Ver Mensaje Individual
  #3  
Antiguo 01-06-2006
Avatar de seoane
[seoane] seoane is offline
Miembro Premium
 
Registrado: feb 2004
Ubicación: A Coruña, España
Posts: 3.717
Reputación: 24
seoane Va por buen camino
Si te entendi bien el problema es que alguien abra el archivo .ini y lea el password. Una posible solucion puede ser encriptar ese password, si algun curioso abriera el archivo no podria descifrar la clave.

Este metodo es seguro mientras no estemos hablando de un "hacker" porque destripando tu programa podria averiguar el metodo para encriptar la clave.

Por lo de pronto, aqui te dejo dos sencillas funciones para cifrar texto:
Código Delphi [-]
Const
  Password = $1978; // Puede ser un numero cualquiera

function Cifrar(Texto: string): string;
var
  i: integer;
begin
  Result:= '';
  RandSeed:= Password;
  for i:= 1 to Length(Texto) do
    Result:= Result + IntToHex(Byte(Texto[i]) xor Byte(Random(256)),2);
end;

function Descifrar(Texto: string): string;
var
  i: integer;
begin
  Result:= '';
  RandSeed:= Password;
  while Length(Texto) > 0 do
  begin
    if not TryStrToInt('$'+Copy(Texto,1,2),i) then
    begin
      Result:= '';
      Exit;
    end;
    Result:= Result + Char(Byte(i) xor Byte(Random(256)));
    Delete(Texto,1,2);
  end;
end;
Responder Con Cita