delphi base64加解密


代码效果如下


按钮1是将edit1内容加密,并存入text文件中,按钮2是在text文件中读取加密后的内容,并解密。

unit Unit1;interfaceuses  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,  Dialogs, EncdDecd,StdCtrls;type  TForm1 = class(TForm)    edt1: TEdit;    edt2: TEdit;    edt3: TEdit;    btn1: TButton;    btn2: TButton;    procedure FormCreate(Sender: TObject);    procedure btn1Click(Sender: TObject);    procedure btn2Click(Sender: TObject);  private    { Private declarations }  public    { Public declarations }  end;var  Form1: TForm1;  t:Text;  f:string;  implementation{$R *.dfm}procedure TForm1.btn1Click(Sender: TObject);begin  edt2.Text:=EncodeString(edt1.Text);  if FileExists(f) then    begin      AssignFile(t,f);    end    else    begin      AssignFile(t,f);      Rewrite(t);    end;    Append(t);    Writeln(t,edt2.text);    CloseFile(t);end;procedure TForm1.btn2Click(Sender: TObject);vars:string;begin  if FileExists(f) then    begin      AssignFile(t,f);      Reset(t);      while not Eof(t) do        Readln(t,s);        edt3.Text:=DecodeString(s);    end;    CloseFile(t);end;procedure TForm1.FormCreate(Sender: TObject);begin  f:=ExtractFilePath(ParamStr(0))+'text.txt';end;end.

联系电话:
020-00000000
联系电话:
020-00000000
联系电话:
020-12345678