Стартовый пул
This commit is contained in:
135
fwzip/Demos/Extract ZIP 2/ExctractZIPDemo2.dpr
Normal file
135
fwzip/Demos/Extract ZIP 2/ExctractZIPDemo2.dpr
Normal file
@@ -0,0 +1,135 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// ****************************************************************************
|
||||
// * Project : FWZip
|
||||
// * Unit Name : ExctractZIPDemo2
|
||||
// * Purpose : Демонстрация распаковки зашифрованного архива.
|
||||
// * Author : Александр (Rouse_) Багель
|
||||
// * Copyright : © Fangorn Wizards Lab 1998 - 2023.
|
||||
// * Version : 2.0.0
|
||||
// * Home Page : http://rouse.drkb.ru
|
||||
// * Home Blog : http://alexander-bagel.blogspot.ru
|
||||
// ****************************************************************************
|
||||
// * Stable Release : http://rouse.drkb.ru/components.php#fwzip
|
||||
// * Latest Source : https://github.com/AlexanderBagel/FWZip
|
||||
// ****************************************************************************
|
||||
//
|
||||
// Используемые источники:
|
||||
// ftp://ftp.info-zip.org/pub/infozip/doc/appnote-iz-latest.zip
|
||||
// https://zlib.net/zlib-1.2.13.tar.gz
|
||||
// http://www.base2ti.com/
|
||||
//
|
||||
|
||||
// Данный пример показывает создание и распаковку зашифрованного архива.
|
||||
// Для демонстрации работы со списком паролей мы создадим архив,
|
||||
// в котором каждому элементу назначим произвольный пароль из списка.
|
||||
// При чем код излечения данных не будет знать какому файлу
|
||||
// какой из паролей соответствует и есть ли пароль вообще.
|
||||
|
||||
program ExctractZIPDemo2;
|
||||
|
||||
{$IFDEF FPC}
|
||||
{$MODE Delphi}
|
||||
{$H+}
|
||||
{$ELSE}
|
||||
{$APPTYPE CONSOLE}
|
||||
{$ENDIF}
|
||||
|
||||
uses
|
||||
SysUtils,
|
||||
FWZipWriter,
|
||||
FWZipReader,
|
||||
FWZipConsts;
|
||||
|
||||
const
|
||||
PasswordList: array [0..3] of string = (
|
||||
'', 'password1', 'password2', 'password3');
|
||||
|
||||
procedure OnPassword(Self, Sender: TObject; const FileName: string;
|
||||
var Password: string; var CancelExtract: Boolean);
|
||||
begin
|
||||
{$IFDEF FPC}
|
||||
// FPC ворнинги прописывает, просто чтобы не орала.
|
||||
if (Self <> nil) and (FileName <> '') then
|
||||
CancelExtract := False;
|
||||
{$ENDIF}
|
||||
Password := PasswordList[3];
|
||||
end;
|
||||
|
||||
var
|
||||
Writer: TFWZipWriter;
|
||||
Reader: TFWZipReader;
|
||||
Item: TFWZipWriterItem;
|
||||
I: Integer;
|
||||
ExtractResult: TExtractResult;
|
||||
Method: TMethod;
|
||||
begin
|
||||
SetCurrentDir(ExtractFilePath(ParamStr(0)));
|
||||
try
|
||||
Writer := TFWZipWriter.Create;
|
||||
try
|
||||
|
||||
// Для начала добавим в корень архива файлы из корневой директории
|
||||
Writer.AddFolder('..\..\', False);
|
||||
|
||||
// Теперь назначим им пароли случайным образом
|
||||
Randomize;
|
||||
|
||||
// У первого элемента пароль всегда будет присутствовать (для демонстрации)
|
||||
Item := Writer[0];
|
||||
Item.Password := PasswordList[Random(3) + 1];
|
||||
Item.NeedDescriptor := True;
|
||||
|
||||
for I := 1 to Writer.Count - 1 do
|
||||
begin
|
||||
Item := Writer[I];
|
||||
// Если используется шифрование желательно включать дескриптор файла
|
||||
// см. Readme.txt
|
||||
Item.NeedDescriptor := True;
|
||||
Item.Password := PasswordList[Random(4)];
|
||||
end;
|
||||
|
||||
// Сохраняем результат
|
||||
Writer.BuildZip('..\DemoResults\ExctractZIPDemo2.zip');
|
||||
finally
|
||||
Writer.Free;
|
||||
end;
|
||||
|
||||
Reader := TFWZipReader.Create;
|
||||
try
|
||||
Reader.LoadFromFile('..\DemoResults\ExctractZIPDemo2.zip');
|
||||
|
||||
// Теперь наша задача извлечь данные из архива
|
||||
// В ручном режиме распаковки придется перебирать пароли самостоятельно
|
||||
// Например вот так:
|
||||
I := 0;
|
||||
repeat
|
||||
ExtractResult := Reader[0].Extract(
|
||||
'..\DemoResults\ExctractZIPDemo2\ManualExtract\', PasswordList[I]);
|
||||
Inc(I);
|
||||
until ExtractResult <> erNeedPassword;
|
||||
|
||||
// Если предполагается использовать режим автоматической распаковки,
|
||||
// то указать пароли можно двумя способами
|
||||
|
||||
// 1. через список паролей
|
||||
Reader.PasswordList.Add(PasswordList[1]);
|
||||
Reader.PasswordList.Add(PasswordList[2]);
|
||||
|
||||
// 2. через обработчик
|
||||
Method.Code := @OnPassword;
|
||||
Method.Data := Reader;
|
||||
Reader.OnPassword := TZipNeedPasswordEvent(Method);
|
||||
|
||||
// для демонстрации в список паролей добавлены только два пароля
|
||||
// третий будет передан через обработчик события OnPassword
|
||||
|
||||
Reader.ExtractAll('..\DemoResults\ExctractZIPDemo2\');
|
||||
finally
|
||||
Reader.Free;
|
||||
end;
|
||||
except
|
||||
on E: Exception do
|
||||
Writeln(E.ClassName, ': ', E.Message);
|
||||
end;
|
||||
end.
|
152
fwzip/Demos/Extract ZIP 2/ExctractZIPDemo2.dproj
Normal file
152
fwzip/Demos/Extract ZIP 2/ExctractZIPDemo2.dproj
Normal file
@@ -0,0 +1,152 @@
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<ProjectGuid>{307D5F68-F671-4EF6-85EA-CF49C71350C7}</ProjectGuid>
|
||||
<MainSource>ExctractZIPDemo2.dpr</MainSource>
|
||||
<Base>True</Base>
|
||||
<Config Condition="'$(Config)'==''">Debug</Config>
|
||||
<TargetedPlatforms>1</TargetedPlatforms>
|
||||
<AppType>Console</AppType>
|
||||
<FrameworkType>None</FrameworkType>
|
||||
<ProjectVersion>19.2</ProjectVersion>
|
||||
<Platform Condition="'$(Platform)'==''">Win32</Platform>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''">
|
||||
<Base>true</Base>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="('$(Platform)'=='Win32' and '$(Base)'=='true') or '$(Base_Win32)'!=''">
|
||||
<Base_Win32>true</Base_Win32>
|
||||
<CfgParent>Base</CfgParent>
|
||||
<Base>true</Base>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Config)'=='Release' or '$(Cfg_1)'!=''">
|
||||
<Cfg_1>true</Cfg_1>
|
||||
<CfgParent>Base</CfgParent>
|
||||
<Base>true</Base>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Config)'=='Debug' or '$(Cfg_2)'!=''">
|
||||
<Cfg_2>true</Cfg_2>
|
||||
<CfgParent>Base</CfgParent>
|
||||
<Base>true</Base>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="('$(Platform)'=='Win32' and '$(Cfg_2)'=='true') or '$(Cfg_2_Win32)'!=''">
|
||||
<Cfg_2_Win32>true</Cfg_2_Win32>
|
||||
<CfgParent>Cfg_2</CfgParent>
|
||||
<Cfg_2>true</Cfg_2>
|
||||
<Base>true</Base>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Base)'!=''">
|
||||
<DCC_S>false</DCC_S>
|
||||
<DCC_K>false</DCC_K>
|
||||
<DCC_E>false</DCC_E>
|
||||
<DCC_N>false</DCC_N>
|
||||
<VerInfo_Keys>CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=;CFBundleName=;CFBundleDisplayName=;UIDeviceFamily=;CFBundleIdentifier=;CFBundleVersion=;CFBundlePackageType=;CFBundleSignature=;CFBundleAllowMixedLocalizations=;UISupportedInterfaceOrientations=;CFBundleExecutable=;CFBundleResourceSpecification=;LSRequiresIPhoneOS=;CFBundleInfoDictionaryVersion=;CFBundleDevelopmentRegion=</VerInfo_Keys>
|
||||
<DCC_F>false</DCC_F>
|
||||
<VerInfo_Locale>1049</VerInfo_Locale>
|
||||
<DCC_Namespace>System;Xml;Data;Datasnap;Web;Soap;$(DCC_Namespace)</DCC_Namespace>
|
||||
<DCC_ImageBase>00400000</DCC_ImageBase>
|
||||
<SanitizedProjectName>ExctractZIPDemo2</SanitizedProjectName>
|
||||
<Icon_MainIcon>$(BDS)\bin\delphi_PROJECTICON.ico</Icon_MainIcon>
|
||||
<Icns_MainIcns>$(BDS)\bin\delphi_PROJECTICNS.icns</Icns_MainIcns>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Base_Win32)'!=''">
|
||||
<VerInfo_Keys>CompanyName=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductVersion=1.0.0.0;Comments=;ProgramID=com.embarcadero.$(MSBuildProjectName);FileDescription=$(MSBuildProjectName);ProductName=$(MSBuildProjectName)</VerInfo_Keys>
|
||||
<DCC_Namespace>Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace)</DCC_Namespace>
|
||||
<VerInfo_Locale>1033</VerInfo_Locale>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Cfg_1)'!=''">
|
||||
<DCC_DebugInformation>0</DCC_DebugInformation>
|
||||
<DCC_LocalDebugSymbols>false</DCC_LocalDebugSymbols>
|
||||
<DCC_SymbolReferenceInfo>0</DCC_SymbolReferenceInfo>
|
||||
<DCC_Define>RELEASE;$(DCC_Define)</DCC_Define>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Cfg_2)'!=''">
|
||||
<DCC_Define>DEBUG;$(DCC_Define)</DCC_Define>
|
||||
<DCC_Optimize>false</DCC_Optimize>
|
||||
<DCC_GenerateStackFrames>true</DCC_GenerateStackFrames>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Cfg_2_Win32)'!=''">
|
||||
<DCC_UnitSearchPath>../../;$(DCC_UnitSearchPath)</DCC_UnitSearchPath>
|
||||
<VerInfo_Locale>1033</VerInfo_Locale>
|
||||
<VerInfo_Keys>CompanyName=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductVersion=1.0.0.0;Comments=;ProgramID=com.embarcadero.$(MSBuildProjectName);FileDescription=$(MSBuildProjectName);ProductName=$(MSBuildProjectName)</VerInfo_Keys>
|
||||
<Manifest_File>(None)</Manifest_File>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<DelphiCompile Include="$(MainSource)">
|
||||
<MainSource>MainSource</MainSource>
|
||||
</DelphiCompile>
|
||||
<BuildConfiguration Include="Debug">
|
||||
<Key>Cfg_2</Key>
|
||||
<CfgParent>Base</CfgParent>
|
||||
</BuildConfiguration>
|
||||
<BuildConfiguration Include="Base">
|
||||
<Key>Base</Key>
|
||||
</BuildConfiguration>
|
||||
<BuildConfiguration Include="Release">
|
||||
<Key>Cfg_1</Key>
|
||||
<CfgParent>Base</CfgParent>
|
||||
</BuildConfiguration>
|
||||
</ItemGroup>
|
||||
<ProjectExtensions>
|
||||
<Borland.Personality>Delphi.Personality.12</Borland.Personality>
|
||||
<Borland.ProjectType/>
|
||||
<BorlandProject>
|
||||
<Delphi.Personality>
|
||||
<Source>
|
||||
<Source Name="MainSource">ExctractZIPDemo2.dpr</Source>
|
||||
</Source>
|
||||
<VersionInfo>
|
||||
<VersionInfo Name="IncludeVerInfo">False</VersionInfo>
|
||||
<VersionInfo Name="AutoIncBuild">False</VersionInfo>
|
||||
<VersionInfo Name="MajorVer">1</VersionInfo>
|
||||
<VersionInfo Name="MinorVer">0</VersionInfo>
|
||||
<VersionInfo Name="Release">0</VersionInfo>
|
||||
<VersionInfo Name="Build">0</VersionInfo>
|
||||
<VersionInfo Name="Debug">False</VersionInfo>
|
||||
<VersionInfo Name="PreRelease">False</VersionInfo>
|
||||
<VersionInfo Name="Special">False</VersionInfo>
|
||||
<VersionInfo Name="Private">False</VersionInfo>
|
||||
<VersionInfo Name="DLL">False</VersionInfo>
|
||||
<VersionInfo Name="Locale">1049</VersionInfo>
|
||||
<VersionInfo Name="CodePage">1251</VersionInfo>
|
||||
</VersionInfo>
|
||||
<VersionInfoKeys>
|
||||
<VersionInfoKeys Name="CompanyName"/>
|
||||
<VersionInfoKeys Name="FileDescription"/>
|
||||
<VersionInfoKeys Name="FileVersion">1.0.0.0</VersionInfoKeys>
|
||||
<VersionInfoKeys Name="InternalName"/>
|
||||
<VersionInfoKeys Name="LegalCopyright"/>
|
||||
<VersionInfoKeys Name="LegalTrademarks"/>
|
||||
<VersionInfoKeys Name="OriginalFilename"/>
|
||||
<VersionInfoKeys Name="ProductName"/>
|
||||
<VersionInfoKeys Name="ProductVersion">1.0.0.0</VersionInfoKeys>
|
||||
<VersionInfoKeys Name="Comments"/>
|
||||
<VersionInfoKeys Name="CFBundleName"/>
|
||||
<VersionInfoKeys Name="CFBundleDisplayName"/>
|
||||
<VersionInfoKeys Name="UIDeviceFamily"/>
|
||||
<VersionInfoKeys Name="CFBundleIdentifier"/>
|
||||
<VersionInfoKeys Name="CFBundleVersion"/>
|
||||
<VersionInfoKeys Name="CFBundlePackageType"/>
|
||||
<VersionInfoKeys Name="CFBundleSignature"/>
|
||||
<VersionInfoKeys Name="CFBundleAllowMixedLocalizations"/>
|
||||
<VersionInfoKeys Name="UISupportedInterfaceOrientations"/>
|
||||
<VersionInfoKeys Name="CFBundleExecutable"/>
|
||||
<VersionInfoKeys Name="CFBundleResourceSpecification"/>
|
||||
<VersionInfoKeys Name="LSRequiresIPhoneOS"/>
|
||||
<VersionInfoKeys Name="CFBundleInfoDictionaryVersion"/>
|
||||
<VersionInfoKeys Name="CFBundleDevelopmentRegion"/>
|
||||
</VersionInfoKeys>
|
||||
<Excluded_Packages>
|
||||
<Excluded_Packages Name="$(BDSBIN)\dcloffice2k270.bpl">Microsoft Office 2000 Sample Automation Server Wrapper Components</Excluded_Packages>
|
||||
<Excluded_Packages Name="$(BDSBIN)\dclofficexp270.bpl">Microsoft Office XP Sample Automation Server Wrapper Components</Excluded_Packages>
|
||||
</Excluded_Packages>
|
||||
</Delphi.Personality>
|
||||
<Platforms>
|
||||
<Platform value="Win32">True</Platform>
|
||||
<Platform value="Win64">False</Platform>
|
||||
</Platforms>
|
||||
</BorlandProject>
|
||||
<ProjectFileVersion>12</ProjectFileVersion>
|
||||
</ProjectExtensions>
|
||||
<Import Project="$(BDS)\Bin\CodeGear.Delphi.Targets" Condition="Exists('$(BDS)\Bin\CodeGear.Delphi.Targets')"/>
|
||||
<Import Project="$(APPDATA)\Embarcadero\$(BDSAPPDATABASEDIR)\$(PRODUCTVERSION)\UserTools.proj" Condition="Exists('$(APPDATA)\Embarcadero\$(BDSAPPDATABASEDIR)\$(PRODUCTVERSION)\UserTools.proj')"/>
|
||||
</Project>
|
74
fwzip/Demos/Extract ZIP 2/ExctractZIPDemo2.lpi
Normal file
74
fwzip/Demos/Extract ZIP 2/ExctractZIPDemo2.lpi
Normal file
@@ -0,0 +1,74 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<Version Value="12"/>
|
||||
<General>
|
||||
<Flags>
|
||||
<MainUnitHasUsesSectionForAllUnits Value="False"/>
|
||||
<MainUnitHasCreateFormStatements Value="False"/>
|
||||
<MainUnitHasTitleStatement Value="False"/>
|
||||
<MainUnitHasScaledStatement Value="False"/>
|
||||
</Flags>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<Title Value="ExctractZIPDemo2"/>
|
||||
<UseAppBundle Value="False"/>
|
||||
<ResourceType Value="res"/>
|
||||
</General>
|
||||
<BuildModes>
|
||||
<Item Name="Default" Default="True"/>
|
||||
</BuildModes>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
<UseFileFilters Value="True"/>
|
||||
</PublishOptions>
|
||||
<RunParams>
|
||||
<FormatVersion Value="2"/>
|
||||
</RunParams>
|
||||
<RequiredPackages>
|
||||
<Item>
|
||||
<PackageName Value="LCL"/>
|
||||
</Item>
|
||||
</RequiredPackages>
|
||||
<Units>
|
||||
<Unit>
|
||||
<Filename Value="ExctractZIPDemo2.dpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="../..;$(ProjOutDir)"/>
|
||||
<Libraries Value="../../fpc_lib"/>
|
||||
<OtherUnitFiles Value="../.."/>
|
||||
<UnitOutputDirectory Value="."/>
|
||||
</SearchPaths>
|
||||
<Parsing>
|
||||
<SyntaxOptions>
|
||||
<SyntaxMode Value="Delphi"/>
|
||||
</SyntaxOptions>
|
||||
</Parsing>
|
||||
<Linking>
|
||||
<Debugging>
|
||||
<DebugInfoType Value="dsDwarf2Set"/>
|
||||
</Debugging>
|
||||
</Linking>
|
||||
<Other>
|
||||
<CustomOptions Value="-dBorland -dVer150 -dDelphi7 -dCompiler6_Up -dPUREPASCAL"/>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
<Debugging>
|
||||
<Exceptions>
|
||||
<Item>
|
||||
<Name Value="EAbort"/>
|
||||
</Item>
|
||||
<Item>
|
||||
<Name Value="ECodetoolError"/>
|
||||
</Item>
|
||||
<Item>
|
||||
<Name Value="EFOpenError"/>
|
||||
</Item>
|
||||
</Exceptions>
|
||||
</Debugging>
|
||||
</CONFIG>
|
24
fwzip/Demos/Extract ZIP 2/clear.bat
Normal file
24
fwzip/Demos/Extract ZIP 2/clear.bat
Normal file
@@ -0,0 +1,24 @@
|
||||
rd /S /Q "%cd%\backup\"
|
||||
rd /S /Q "%cd%\ConverterBackup\"
|
||||
rd /S /Q "%cd%\lib\"
|
||||
rd /S /Q "%cd%\__history\"
|
||||
rd /S /Q "%cd%\__recovery\"
|
||||
del "%cd%\*.o"
|
||||
del "%cd%\*.a"
|
||||
del "%cd%\*.or"
|
||||
del "%cd%\*.lps"
|
||||
del "%cd%\*.obj"
|
||||
del "%cd%\*.exe"
|
||||
del "%cd%\*.ppu"
|
||||
del "%cd%\*.dcu"
|
||||
del "%cd%\*.log"
|
||||
del "%cd%\*.compiled"
|
||||
del "%cd%\*.cfg"
|
||||
del "%cd%\*.dof"
|
||||
del "%cd%\*.dproj.local"
|
||||
del "%cd%\*.identcache"
|
||||
del "%cd%\*.dsk"
|
||||
del "%cd%\*.skincfg"
|
||||
del "%cd%\*.bak"
|
||||
del "%cd%\*.rsm"
|
||||
del "%cd%\*.~*"
|
Reference in New Issue
Block a user