LUCHO,
Cita:
|
Empezado por LUCHO
...Quisiera saber como encriptar palabras...
|
Revisa este código
Código Delphi
[-]
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Edit1: TEdit;
Label2: TLabel;
Edit2: TEdit;
Label3: TLabel;
Edit3: TEdit;
Label4: TLabel;
Edit4: TEdit;
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
public
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function EnDeCrypt(const Value, Key : String) : String;
var
i : Integer;
KeyAlt : Integer;
begin
KeyAlt := Length(Key);
for i := 1 to Length(Key) do
KeyAlt := KeyAlt xor Ord(Key[i]);
Result := Value;
for i := 1 to Length(Value) do
begin
Result[i] := chr(not(ord(Value[i]) xor Ord(KeyAlt)));
end
end;
procedure TForm1.Button1Click(Sender: TObject);
var
Data : String;
Key : String;
begin
Data := Edit1.Text;
Key := Edit2.Text;
Edit3.Text := EnDeCrypt(Data,Key);
end;
procedure TForm1.Button2Click(Sender: TObject);
var
DataEnc : String;
Key : String;
begin
DataEnc := Edit3.Text;
Key := Edit2.Text;
Edit4.Text := EnDeCrypt(DataEnc,Key);
end;
end.
El código anterior en un ejemplo básico de
Encriptación y Desencriptación de un String con una Clave por medio de las funciones lógicas Not y Xor.
El ejemplo anterior esta disponible en el link :
http://terawiki.clubdelphi.com/Delph...=EnDeCrypt.rar
Te sugiero revisar estos links:
Espero sea útil
Nelson.