📄 main32.pas
字号:
Repeat
Inc(i);
If HStr[i] In ['/','\','?','*','"',':','<','>','|'] Then
FName:=FName
else FName:=FName+HStr[i];
Until i=len;
End;
Mout:=ExtractFilePath(Edit2.Text);
{<changes 2.1>}
len:=Length(Mout);
GetDir(0,CurPath);
If len=0 Then Mout:=CurPath;
If Mout[len]='/' Then Mout:=Copy(Mout,1,len-1);
{$I-}
ChDir(Mout);
If IOResult<>0 Then Begin
MessageDlg(ml.GetCodeString('main32',61){'The directory is invalid.'},mtError,[mbOK],250); // code061
ChDir(CurPath);
{$I+}
End
Else Begin
len:=Length(Mout);
If Mout[len]<>'/' Then Mout:=Mout+'/';
{</changes 2.1>}
If ExtractFileExt(FName)='' Then Begin
Mout:=Mout+FName+OrigFileExt;
End
Else Mout:=Mout+FName;
If FName='' Then MessageDlg(ml.GetCodeString('main32',62){'Please enter a valid filename.'},mtWarning,[mbOK],250) // code062
Else Begin
If Not(IsRegd) Then Begin
Crypt:=False;
Mix:=False;
Transmit:=False;
CryptAlgo:=0;
End;
WStep:=7;
ws_title.Caption:=WSM[WStep,BoolToInt(Codec)];
ws_x1.Caption:=IntToStr(WStep);
ws_x2.Caption:=IntToStr(WStep);
S6.Visible:=True;
Ltin2.Visible:=True;
Lin2.Visible:=True;
Ltin1.Caption:=ml.GetCodeString('main32',63);{'Carrier file:'; } // code063
Lin1.Caption:=ExtractFileName(Bin);
Ltin2.Caption:=ml.GetCodeString('main32',64);{'Encoded data:'; } // code064
Lin2.Caption:=ExtractFileName(Din);
Ltout.Caption:=ml.GetCodeString('main32',65);{'Manipulated file:';} // code065
Lout.Caption:=ExtractFileName(Mout);
{If Not(Mix Or Crypt) Then lcrypt.Caption:=ml.GetCodeString('main32',66)// code066
Else Begin
lcrypt.Caption:='';
If Mix Then Begin
lcrypt.Caption:=ml.GetCodeString('main32',67); // code067
If Crypt Then lcrypt.Caption:=lcrypt.caption+ml.GetCodeString('main32',68);//code068
End
Else lcrypt.Caption:=ml.GetCodeString('main32',69); // code069
If Transmit Then lcrypt.Caption:=lcrypt.Caption+ml.GetCodeString('main32',70); // code070
End; }
lcrypt.Caption:=EncryptionString;
End;
End;
End
Else MessageDlg(ml.GetCodeString('main32',71){'Please enter a valid filename.'},mtWarning,[mbOK],250); // code071
End
Else Begin
StartAction;
End;
End;
7: Begin
StartAction;
End;
End;
end;
procedure TForm14.Button1Click(Sender: TObject);
var
AllData: Boolean;
begin
if Codec then begin
Label13.Font.Color:=clBtnFace;
Label8.Font.Color:=clBlack;
end
else begin
Label8.Font.Color:=clBtnFace;
Label13.Font.Color:=clBlack;
end;
if Bin<>'' then FormatLabels(Bin,Label1);
if Din<>'' then FormatLabels(Din,Label2);
if Mout<>'' then FormatLabels(Mout,Label3);
if Min<>'' then FormatLabels(Min,Label4);
if Dout<>'' then FormatLabels(Dout,Label5);
AllData:=True;
If Codec Then Begin
If Bin='' Then AllData:=False;
If Din='' Then AllData:=False;
If Mout='' Then AllData:=False;
End
Else Begin
If Min='' Then AllData:=False;
If Dout='' Then AllData:=False;
End;
If (Codec And AllData) Then SBar.Caption:=ml.GetCodeString('main32',85);{'Click on "Start", to encode data in the carrier file'; } // code085
If (Not(Codec) And AllData) Then SBar.Caption:=ml.GetCodeString('main32',86);{'Click on "Start", to decode data from the carrier file'; } // code086
If Not(AllData) Then SBar.Caption:=ml.GetCodeString('main32',87);{'Select input and output data';} // code087
SBar.Visible:=True;
WzPanel.Visible:=False;
end;
procedure TForm14.RadioButton1Click(Sender: TObject);
begin
Codec:=True;
end;
procedure TForm14.RadioButton2Click(Sender: TObject);
begin
Codec:=False;
end;
procedure TForm14.StartAction;
var
i: Byte;
{j: Byte; }
// DoIt: Boolean;
{ SpaceNeeded: Longint;
SpaceAvailable: Longint;
XFile: File Of Byte; }
FID: Integer;
usable: String;
space: Integer;
ext: String;
wrote: Boolean;
myEDF: TEncryptedDataFile;
{ lastpos: Integer; }
pwdok: Boolean;
diffext: Boolean;
begin
// deactivate transmitting
Transmit:=false;
//////////////////////////
Form14.Cursor:=crHourGlass;
SBar.Cursor:=crHourGlass;
WzPanel.Cursor:=crHourGlass;
S6.Cursor:=crHourGlass;
wbz.Cursor:=crHourGlass;
wbw.Cursor:=crHourGlass;
wbh.Cursor:=crHourGlass;
Application.ProcessMessages;
if Codec then begin
myCarrier.LoadFromFile(Bin);
myCarrier.SetFileType(FileType,0);
myData.LoadFromFile(Din);
ext:=ExtractFileExt(Din);
if Length(ext)>3 then ext:=Copy(ext,2,3)
else begin
if Length(ext)=0 then ext:='///'
else begin
if Length(ext)=1 then ext:='///'
else begin
if Length(ext)=2 then ext:=Copy(ext,2,1)+'//'
else if Length(ext)=3 then ext:=Copy(ext,2,2)+'/';
end;
end;
end;
myData.Prepend3CharExt(ext);
Enabled:=False;
Form11.Show;
if (Crypt or Mix or Transmit or (CryptAlgo>0)) then begin
myEDF:=TEncryptedDataFile.Create;
myEDF.CreateFromDataFile(myData,False);
myEDF.SetMix(Mix);
myEDF.SetPassword(Pwd);
myEDF.SetCrypt(Crypt);
myEDF.SetTransmit(Transmit);
myEDF.setAlgorithm(CryptAlgo);
myEDF.Encrypt;
myEDF.ExportToDataFile(myData,True);
myEDF.Free;
end;
//myData.PrependSize(Distribute);
usable:='OK';
space:=0;
if FileType='ASC' then begin
myASC:=TASCIIReplace.Create;
myASC.OnPercentChange:=Form11.PercentUpdate;
myASC.OnActionChange:=Form11.ActionUpdate;
myASC.OnWantCancel:=Form11.WantCancel;
myASC.CreateFromCarrierFile(myCarrier);
usable:=myASC.isUsable;
if usable='OK' then begin
Application.ProcessMessages;
space:=myASC.GetAvailSize;
if space<(myData.GetSize) then MessageDlg(ml.GetCodeString('main32',97),mtError,[mbOK],250)
else begin
if Distribute then myData.Distribute(space)
else myData.PrependSize(myData.GetSize);
myASC.Encode(myData);
myASC.ExportToCarrierFile(myCarrier);
myCarrier.SaveToFile(Mout);
Form11.PercentUpdate(self,100);
Application.ProcessMessages;
MessageDlg(ml.GetCodeString('main32',98),mtInformation,[mbOK],0);
end;
end else MessageDlg(usable,mtError,[mbOK],250);
myASC.Free;
end;
if FileType='TXT' then begin
myTXT:=TASCIIInsert.Create;
myTXT.OnPercentChange:=Form11.PercentUpdate;
myTXT.OnActionChange:=Form11.ActionUpdate;
myTXT.OnWantCancel:=Form11.WantCancel;
myTXT.CreateFromCarrierFile(myCarrier);
usable:=myTXT.isUsable;
if usable='OK' then begin
Application.ProcessMessages;
space:=myTXT.GetAvailSize;
if space<(myData.GetSize) then MessageDlg(ml.GetCodeString('main32',97),mtError,[mbOK],250)
else begin
if Distribute then myData.Distribute(space)
else myData.PrependSize(myData.GetSize);
myTXT.Encode(myData);
myTXT.ExportToCarrierFile(myCarrier);
myCarrier.SaveToFile(Mout);
Form11.PercentUpdate(self,100);
Application.ProcessMessages;
MessageDlg(ml.GetCodeString('main32',98),mtInformation,[mbOK],0);
end;
end else MessageDlg(usable,mtError,[mbOK],250);
myTXT.Free;
end;
if FileType='PDF' then begin
myPDF:=TPDFInsert.Create;
myPDF.OnPercentChange:=Form11.PercentUpdate;
myPDF.OnActionChange:=Form11.ActionUpdate;
myPDF.OnWantCancel:=Form11.WantCancel;
myPDF.CreateFromCarrierFile(myCarrier);
usable:=myPDF.isUsable;
if usable='OK' then begin
Application.ProcessMessages;
space:=myPDF.GetAvailSize;
if space<(myData.GetSize) then MessageDlg(ml.GetCodeString('main32',97),mtError,[mbOK],250)
else begin
if Distribute then myData.Distribute(space)
else myData.PrependSize(myData.GetSize);
myPDF.Encode(myData);
myPDF.ExportToCarrierFile(myCarrier);
myCarrier.SaveToFile(Mout);
Application.ProcessMessages;
MessageDlg(ml.GetCodeString('main32',98),mtInformation,[mbOK],0);
end;
end else MessageDlg(usable,mtError,[mbOK],250);
myPDF.Free;
end;
if FileType='BMP' then begin
myBMP:=TBMPReplace.Create;
myBMP.OnPercentChange:=Form11.PercentUpdate;
myBMP.OnActionChange:=Form11.ActionUpdate;
myBMP.OnWantCancel:=Form11.WantCancel;
myBMP.CreateFromCarrierFile(myCarrier);
usable:=myBMP.isUsable;
if usable='OK' then begin
Application.ProcessMessages;
space:=myBMP.GetAvailSize;
if space<(myData.GetSize) then MessageDlg(ml.GetCodeString('main32',97),mtError,[mbOK],250)
else begin
if Distribute then myData.Distribute(space)
else myData.PrependSize(myData.GetSize);
myBMP.Encode(myData);
myBMP.ExportToCarrierFile(myCarrier);
myCarrier.SaveToFile(Mout);
Form11.PercentUpdate(self,100);
Application.ProcessMessages;
MessageDlg(ml.GetCodeString('main32',98),mtInformation,[mbOK],0);
end;
end else MessageDlg(usable,mtError,[mbOK],250);
myBMP.Free;
end;
Enabled:=True;
Form11.Hide;
end
else begin
myCarrier.LoadFromFile(Min);
myCarrier.SetFileType(FileType,0);
usable:='OK';
wrote:=False;
Form11.Show;
Enabled:=False;
if FileType='ASC' then begin
myASC:=TASCIIReplace.Create;
myASC.OnPercentChange:=Form11.PercentUpdate;
myASC.OnActionChange:=Form11.ActionUpdate;
myASC.OnWantCancel:=Form11.WantCancel;
myASC.CreateFromCarrierFile(myCarrier);
usable:=myASC.isUsable;
if usable='OK' then begin
Form11.PercentUpdate(self,100);
Application.ProcessMessages;
wrote:=myASC.Decode(myData);
if myData.IsDistributed(myASC.GetSize) then myData.Undistribute(myASC.GetAvailSize);
end else MessageDlg(usable,mtError,[mbOK],250);
myASC.Free;
end;
if FileType='TXT' then begin
myTXT:=TASCIIInsert.Create;
myTXT.OnPercentChange:=Form11.PercentUpdate;
myTXT.OnActionChange:=Form11.ActionUpdate;
myTXT.OnWantCancel:=Form11.WantCancel;
myTXT.CreateFromCarrierFile(myCarrier);
usable:=myTXT.isUsable;
if usable='OK' then begin
Application.ProcessMessages;
wrote:=myTXT.Decode(myData);
if myData.IsDistributed(myTXT.GetSize) then myData.Undistribute(myTXT.GetAvailSize);
end else MessageDlg(usable,mtError,[mbOK],250);
myTXT.Free;
end;
if FileType='PDF' then begin
myPDF:=TPDFInsert.Create;
myPDF.OnPercentChange:=Form11.PercentUpdate;
myPDF.OnActionChange:=Form11.ActionUpdate;
myPDF.OnWantCancel:=Form11.WantCancel;
myPDF.CreateFromCarrierFile(myCarrier);
usable:=myPDF.isUsable;
if usable='OK' then begin
Application.ProcessMessages;
wrote:=myPDF.Decode(myData);
if myData.IsDistributed(myPDF.GetSize) then myData.Undistribute(myPDF.GetAvailSize);
end else MessageDlg(usable,mtError,[mbOK],250);
myPDF.Free;
end;
if FileType='BMP' then begin
myBMP:=TBMPReplace.Create;
myBMP.OnPercentChange:=Form11.PercentUpdate;
myBMP.OnActionChange:=Form11.ActionUpdate;
myBMP.OnWantCancel:=Form11.WantCancel;
myBMP.CreateFromCarrierFile(myCarrier);
usable:=myBMP.isUsable;
if usable='OK' then begin
Form11.PercentUpdate(self,100);
Application.ProcessMessages;
wrote:=myBMP.Decode(myData);
if myData.IsDistributed(myBMP.GetSize) then myData.Undistribute(myBMP.GetAvailSize);
end else MessageDlg(usable,mtError,[mbOK],250);
myBMP.Free;
end;
if wrote then begin
pwdOK:=True;
if Pwd<>'' then begin
myEDF:=TEncryptedDataFile.Create;
myEDF.CreateFromDataFile(myData,True);
myEDF.SetPassword(Pwd);
myEDF.Decrypt;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -