diff --git a/CreateCargo.cpp b/CreateCargo.cpp index 40cfbe6..622f0c5 100644 --- a/CreateCargo.cpp +++ b/CreateCargo.cpp @@ -224,7 +224,7 @@ std::vector CreateCargo::ComputingHeadFiles() f.close(); //Tworzenie hashu CRC - uint64_t crc = XXH64(buffor.data(), buffor.size(), VERSION); + uint32_t crc = crc32(buffor); //Kompresjia std::vector zip; @@ -331,6 +331,16 @@ uint64_t CreateCargo::fnv64(const std::string& data) return hash; } +//----------------------------------------------------------------------------- +// Wygenerój CRC32 HASH integralności +//----------------------------------------------------------------------------- +uint32_t CreateCargo::crc32(const std::vector& buffer) +{ + boost::crc_32_type crc; + crc.process_bytes(buffer.data(), buffer.size()); + return crc.checksum(); +} + //----------------------------------------------------------------------------- // Sprawdzanie czy plik znajduje się na liście //----------------------------------------------------------------------------- diff --git a/CreateCargo.h b/CreateCargo.h index 7a94dfc..ddf0967 100644 --- a/CreateCargo.h +++ b/CreateCargo.h @@ -30,6 +30,7 @@ #include #include #include +#include #include "DataStruct.h" #include "Txtpp.h" @@ -122,6 +123,9 @@ private: // Wygenerój FNV-1a HASH uint64_t fnv64(const std::string& data); + // CRC + uint32_t crc32(const std::vector&); + // Rozdzielanie paternu od ścieżki void ExtPatternAndPathDetection(const std::vector&, std::vector&, std::vector&); diff --git a/DataStruct.h b/DataStruct.h index 650c6a8..fcfce81 100644 --- a/DataStruct.h +++ b/DataStruct.h @@ -21,7 +21,7 @@ #include #include - +#include #define EXTENSION "pak" @@ -62,6 +62,6 @@ struct FilesTable uint64_t hashName; uint64_t offset; uint32_t size; - uint64_t crc; + uint32_t crc; uint8_t isZip; }; \ No newline at end of file diff --git a/ExtractCargo.cpp b/ExtractCargo.cpp index bf5e028..6cdf136 100644 --- a/ExtractCargo.cpp +++ b/ExtractCargo.cpp @@ -114,9 +114,9 @@ bool ExtractCargo::CheckCargoFile() //----------------------------------------------------------------------------- // Sprawdzanie sumy kontrolnej //----------------------------------------------------------------------------- -bool ExtractCargo::HashValid(const std::vector& data, const uint64_t& crc) +bool ExtractCargo::HashValid(const std::vector& data, const uint32_t& crc) { - uint64_t actualCrc = XXH64(data.data(), data.size(), VERSION); + uint32_t actualCrc = crc32(data); if (actualCrc != crc) { @@ -126,6 +126,16 @@ bool ExtractCargo::HashValid(const std::vector& data, const uint64_t& crc) return true; } +//----------------------------------------------------------------------------- +// Wygenerój CRC32 HASH integralności +//----------------------------------------------------------------------------- +uint32_t ExtractCargo::crc32(const std::vector& buffer) +{ + boost::crc_32_type crc; + crc.process_bytes(buffer.data(), buffer.size()); + return crc.checksum(); +} + //----------------------------------------------------------------------------- // Pobieranie nagłówków plików //----------------------------------------------------------------------------- diff --git a/ExtractCargo.h b/ExtractCargo.h index 0659a4a..411d160 100644 --- a/ExtractCargo.h +++ b/ExtractCargo.h @@ -28,6 +28,7 @@ #include #include #include +#include #include "DataStruct.h" #include "xxhash.h" @@ -68,7 +69,10 @@ private: void LoadFilesTable(); // Sprawdzanie sumy kontrolnej - bool HashValid(const std::vector&, const uint64_t&); + bool HashValid(const std::vector&, const uint32_t&); + + // CRC + uint32_t crc32(const std::vector&); // Utwórz katalog void CreateDirections(std::filesystem::path); diff --git a/license/crc/LICENSE_1_0.txt b/license/crc/LICENSE_1_0.txt new file mode 100644 index 0000000..36b7cd9 --- /dev/null +++ b/license/crc/LICENSE_1_0.txt @@ -0,0 +1,23 @@ +Boost Software License - Version 1.0 - August 17th, 2003 + +Permission is hereby granted, free of charge, to any person or organization +obtaining a copy of the software and accompanying documentation covered by +this license (the "Software") to use, reproduce, display, distribute, +execute, and transmit the Software, and to prepare derivative works of the +Software, and to permit third-parties to whom the Software is furnished to +do so, all subject to the following: + +The copyright notices in the Software and this entire statement, including +the above license grant, this restriction and the following disclaimer, +must be included in all copies of the Software, in whole or in part, and +all derivative works of the Software, unless such copies or derivative +works are solely in the form of machine-executable object code generated by +a source language processor. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/license/lz4/LICENSE.txt b/license/lz4/LICENSE.txt new file mode 100644 index 0000000..972594f --- /dev/null +++ b/license/lz4/LICENSE.txt @@ -0,0 +1,12 @@ +This repository uses 2 different licenses : +- all files in the `lib` directory use a BSD 2-Clause license +- all other files use a GPL-2.0-or-later license, unless explicitly stated otherwise + +Relevant license is reminded at the top of each source file, +and with presence of COPYING or LICENSE file in associated directories. + +This model is selected to emphasize that +files in the `lib` directory are designed to be included into 3rd party applications, +while all other files, in `programs`, `tests` or `examples`, +are intended to be used "as is", as part of their intended scenarios, +with no intention to support 3rd party integration use cases. \ No newline at end of file diff --git a/voidcmd.vcxproj b/voidcmd.vcxproj index 42deb59..35415ae 100644 --- a/voidcmd.vcxproj +++ b/voidcmd.vcxproj @@ -104,7 +104,7 @@ _DEBUG;_CONSOLE;%(PreprocessorDefinitions) true stdcpp17 - 3rd\ftxui\include;3rd\lz4\include + 3rd\crc\include;3rd\ftxui\include;3rd\lz4\include Console @@ -122,7 +122,7 @@ NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true stdcpp17 - 3rd\ftxui\include;3rd\lz4\include + 3rd\crc\include;3rd\ftxui\include;3rd\lz4\include Console @@ -138,7 +138,6 @@ - @@ -148,7 +147,6 @@ -