From 07f25198da701b9ef6a0e1e60ef335c40fdbb47c Mon Sep 17 00:00:00 2001 From: yanczi Date: Sat, 1 Nov 2025 23:53:25 +0100 Subject: [PATCH] =?UTF-8?q?Przywr=C3=B3cono=20xxHash?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CreateCargo.cpp | 12 +----------- CreateCargo.h | 3 +-- DataStruct.h | 2 +- ExtractCargo.cpp | 14 ++------------ ExtractCargo.h | 8 ++------ license/crc/LICENSE_1_0.txt | 23 ----------------------- 6 files changed, 7 insertions(+), 55 deletions(-) delete mode 100644 license/crc/LICENSE_1_0.txt diff --git a/CreateCargo.cpp b/CreateCargo.cpp index 622f0c5..40cfbe6 100644 --- a/CreateCargo.cpp +++ b/CreateCargo.cpp @@ -224,7 +224,7 @@ std::vector CreateCargo::ComputingHeadFiles() f.close(); //Tworzenie hashu CRC - uint32_t crc = crc32(buffor); + uint64_t crc = XXH64(buffor.data(), buffor.size(), VERSION); //Kompresjia std::vector zip; @@ -331,16 +331,6 @@ 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 ddf0967..3f020f4 100644 --- a/CreateCargo.h +++ b/CreateCargo.h @@ -30,11 +30,10 @@ #include #include #include -#include +#include #include "DataStruct.h" #include "Txtpp.h" -#include "xxhash.h" #include "CompressingManager.h" diff --git a/DataStruct.h b/DataStruct.h index c5c9556..2579c79 100644 --- a/DataStruct.h +++ b/DataStruct.h @@ -62,6 +62,6 @@ struct FilesTable uint64_t hashName; uint64_t offset; uint32_t size; - uint32_t crc; + uint64_t crc; uint8_t isZip; }; \ No newline at end of file diff --git a/ExtractCargo.cpp b/ExtractCargo.cpp index 6cdf136..bf5e028 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 uint32_t& crc) +bool ExtractCargo::HashValid(const std::vector& data, const uint64_t& crc) { - uint32_t actualCrc = crc32(data); + uint64_t actualCrc = XXH64(data.data(), data.size(), VERSION); if (actualCrc != crc) { @@ -126,16 +126,6 @@ bool ExtractCargo::HashValid(const std::vector& data, const uint32_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 411d160..e7d89b3 100644 --- a/ExtractCargo.h +++ b/ExtractCargo.h @@ -28,10 +28,9 @@ #include #include #include -#include +#include #include "DataStruct.h" -#include "xxhash.h" #include "CompressingManager.h" class ExtractCargo { @@ -69,10 +68,7 @@ private: void LoadFilesTable(); // Sprawdzanie sumy kontrolnej - bool HashValid(const std::vector&, const uint32_t&); - - // CRC - uint32_t crc32(const std::vector&); + bool HashValid(const std::vector&, const uint64_t&); // Utwórz katalog void CreateDirections(std::filesystem::path); diff --git a/license/crc/LICENSE_1_0.txt b/license/crc/LICENSE_1_0.txt deleted file mode 100644 index 36b7cd9..0000000 --- a/license/crc/LICENSE_1_0.txt +++ /dev/null @@ -1,23 +0,0 @@ -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.