Ver Mensaje Individual
  #3  
Antiguo 15-11-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: 26
seoane Va por buen camino
Y por si alguien tiene curiosidad por el algoritmo:

Código Delphi [-]
function Descifrar(Str: String; Clave: Integer): string;
var
  i,k: integer;
begin
  Str:= Uppercase(Str);
  Result:= '';
  for i:= 1 to Length(Str) do
  begin
    if Str[i] in ['A'..'Z'] then
    begin
      k:= Ord(Str[i]) - Clave;
      if k < Ord('A') then
        k:= Ord('Z') - Ord('A') + k + 1;
      Result:= Result + Chr(k);
    end else
      Result:= Result + Str[i];
  end;
end;

// Ejemplo
ShowMessage(Descifrar('hsaovbno wlymljapvu pz haahpuhisl, pa vjjbyz vusf hz hu hjjpklua',7));

Mira que era fácil, y di un montón de vueltas ...

Última edición por seoane fecha: 10-06-2007 a las 16:55:55.
Responder Con Cita