Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit unit1;
- {$mode objfpc}{$H+}
- interface
- uses
- Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
- base64;
- const
- cae='ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789!#$%&()[<=?@]^_|0123456789!#$%&()[<=?@]^_|' ;
- type
- { TForm1 }
- TForm1 = class(TForm)
- Button1: TButton;
- Button2: TButton;
- Edit1: TEdit;
- Edit2: TEdit;
- Edit3: TEdit;
- Label1: TLabel;
- Label2: TLabel;
- Label3: TLabel;
- Label4: TLabel;
- Label5: TLabel;
- procedure Button1Click(Sender: TObject);
- procedure Button2Click(Sender: TObject);
- private
- { private declarations }
- public
- { public declarations }
- end;
- var
- Form1: TForm1;
- implementation
- {$R *.lfm}
- { TForm1 }
- function ranEncode(x,flag:ansistring;Private_key:byte):ansistring;//Flag_STring
- Var
- temp:ansistring;
- i,j:longint;
- k:byte;
- begin
- temp:='';
- x:=encodeStringBase64(x);
- for i:=length(x) downto 1 do
- temp:=temp+x[i];
- for i:=1 to Private_key do
- begin
- temp:=flag+temp;
- k:=random(25)+1;
- for j:=1 to length(temp) do
- begin
- temp[j]:=cae[pos(temp[j],cae)+k];
- end;
- end;
- x:='';
- for i:=length(temp) downto 1 do
- x:=x+temp[i];
- temp:='';
- ranencode:=x;
- end;
- function ranDecode(x,FLAG:ansistring;Private_key:byte):ansistring;
- var
- st,temp:ansistring;
- i,j:longint;
- k:byte;
- begin
- temp:='';
- for i:=length(x) downto 1 do
- temp:=temp+x[i];
- x:=temp;
- temp:='';
- for i:=1 to Private_key do
- begin
- for k:=1 to 25 do
- begin
- temp:=x;
- for j:=1 to length(temp) do
- temp[j]:=cae[pos(temp[j],cae)+k];
- st:=copy(temp,1,length(FLAG));
- if st=FLAG then begin x:=copy(temp,length(FLAG)+1,length(temp)-length(FLAG));break; end;
- end;
- end;
- temp:='';
- for i:=length(x) downto 1 do
- temp:=temp+x[i];
- randecode:=decodeStringBase64(temp);
- end;
- procedure TForm1.Button1Click(Sender: TObject);
- begin
- edit2.text:=ranencode(edit1.text,'FLAG',20);
- end;
- procedure TForm1.Button2Click(Sender: TObject);
- begin
- edit3.text:=randecode(edit2.text,'FLAG',20);
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement