Skasowanie części makr
This commit is contained in:
parent
f9ea960cf0
commit
bfc6c1811d
6 changed files with 13 additions and 45 deletions
|
|
@ -22,7 +22,6 @@
|
|||
CreateCargo::CreateCargo()
|
||||
: signature(fl::sigpak)
|
||||
, extension(fl::extpak)
|
||||
, version(VERSION)
|
||||
, methodFlags(0)
|
||||
, xxhState(XXH64_createState())
|
||||
, offset(0)
|
||||
|
|
@ -133,11 +132,11 @@ bool CreateCargo::GetFileList(const std::string& path)
|
|||
{
|
||||
if (FindOnTheList(zipList, fileRef) || CheckFileExtension(fileRef, zipList))
|
||||
{
|
||||
pc.parameter = FindOnTheList(encList, fileRef) || CheckFileExtension(fileRef, encList) ? FILE_FLAG_ZIPENC : FILE_FLAG_COMPRESS;
|
||||
pc.parameter = FindOnTheList(encList, fileRef) || CheckFileExtension(fileRef, encList) ? flag::ezd : flag::zip;
|
||||
}
|
||||
else
|
||||
{
|
||||
pc.parameter = FindOnTheList(encList, fileRef) || CheckFileExtension(fileRef, encList) ? FILE_FLAG_ENCRYPT : FILE_FLAG_RAW;
|
||||
pc.parameter = FindOnTheList(encList, fileRef) || CheckFileExtension(fileRef, encList) ? flag::enc : flag::raw;
|
||||
}
|
||||
pc.path = PathToUnixLike(tmpPath);
|
||||
std::cout << pc.path << " - " << pc.parameter << std::endl;
|
||||
|
|
|
|||
|
|
@ -72,7 +72,6 @@ public:
|
|||
private:
|
||||
const std::string signature;
|
||||
const std::string extension;
|
||||
const signed char version;
|
||||
|
||||
uint8_t methodFlags;
|
||||
|
||||
|
|
|
|||
22
DataStruct.h
22
DataStruct.h
|
|
@ -22,28 +22,6 @@
|
|||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
#define EXTENSION "pak"
|
||||
#define SIGNATURE "XPAK"
|
||||
|
||||
#define SIGNATURE_KEY_FILE "XKEY"
|
||||
|
||||
#define VERSION 0x03
|
||||
|
||||
// WielkoϾ pojedynczego bloku strumienia
|
||||
#define CHUNK_STREAM_512KB 524288 // 512KB
|
||||
#define CHUNK_STREAM_16MB 16777216 // 16MB
|
||||
#define CHUNK_STREAM_256MB 268435456 // 256MB
|
||||
|
||||
// Rozmiar pojedynczego bloku
|
||||
#define CHUNK_BLOCK_SIZE 131072 // 128KB
|
||||
|
||||
#define FILE_FLAG_RAW 0x00
|
||||
#define FILE_FLAG_COMPRESS 0x0F
|
||||
#define FILE_FLAG_ENCRYPT 0xF0
|
||||
#define FILE_FLAG_ZIPENC 0xFF
|
||||
|
||||
#define FILE_FLAG_FILTERING 0xAB
|
||||
|
||||
//Prgoram title
|
||||
#define PROGRAM_TITLE "eXtendet PAK"
|
||||
#define PROGRAM_VERSION "v0.5"
|
||||
|
|
|
|||
|
|
@ -67,9 +67,6 @@ void EncryptionManager::generateKeys()
|
|||
|
||||
void EncryptionManager::saveKey(const std::string& path, bool hpp)
|
||||
{
|
||||
const std::string sig = SIGNATURE_KEY_FILE;
|
||||
const int8_t ver = VERSION;
|
||||
|
||||
// Wygeneruj time stamp
|
||||
std::time_t now = std::time(nullptr);
|
||||
const int time = static_cast<int>(now);
|
||||
|
|
@ -78,14 +75,13 @@ void EncryptionManager::saveKey(const std::string& path, bool hpp)
|
|||
std::vector<char> keyVec(reinterpret_cast<const char*>(key.data()),
|
||||
reinterpret_cast<const char*>(key.data()) + key.size());
|
||||
|
||||
const uint64_t crcKey = XXH64(keyVec.data(), keyVec.size(), VERSION);
|
||||
const uint64_t crcKey = XXH64(keyVec.data(), keyVec.size(), 0);
|
||||
|
||||
// Zapisz ten œmietnik do pliku KEY
|
||||
std::ofstream file(path + ".key", std::ios::binary);
|
||||
if (!file) { std::cout << "Failed to save encryption key to file" << std::endl; }
|
||||
|
||||
file.write(sig.data(), sig.length());
|
||||
file.write(reinterpret_cast<const char*>(&ver), sizeof(ver));
|
||||
file.write(fl::sigkey.data(), fl::sigkey.length());
|
||||
file.write(reinterpret_cast<const char*>(&time), sizeof(time));
|
||||
file.write(reinterpret_cast<const char*>(keyVec.data()), keyVec.size());
|
||||
file.write(reinterpret_cast<const char*>(&crcKey), sizeof(crcKey));
|
||||
|
|
@ -137,18 +133,15 @@ std::string EncryptionManager::toHex(const unsigned char* data, size_t len)
|
|||
void EncryptionManager::loadKey(const std::string& path)
|
||||
{
|
||||
std::ifstream file(path + ".key", std::ios::binary);
|
||||
|
||||
const std::string signature = SIGNATURE_KEY_FILE;
|
||||
std::vector<char> sig(signature.size());
|
||||
std::vector<char> sig(fl::sigkey.size());
|
||||
int8_t ver;
|
||||
int time;
|
||||
|
||||
// Wczytaj
|
||||
file.read(sig.data(), sig.size());
|
||||
file.read(reinterpret_cast<char*>(&ver), sizeof(ver));
|
||||
|
||||
// SprawdŸ czy plik klucza jest poprawny
|
||||
if (std::string(sig.begin(), sig.end()) != signature || ver != VERSION)
|
||||
if (std::string(sig.begin(), sig.end()) != fl::sigkey)
|
||||
{
|
||||
throw std::runtime_error("Invalid key file!");
|
||||
}
|
||||
|
|
@ -161,7 +154,7 @@ void EncryptionManager::loadKey(const std::string& path)
|
|||
file.read(reinterpret_cast<char*>(&crcKey), sizeof(crcKey));
|
||||
|
||||
// SprawdŸ integralnoœæ klucza
|
||||
if (XXH64(keyVec.data(), keyVec.size(), VERSION) != crcKey)
|
||||
if (XXH64(keyVec.data(), keyVec.size(), 0) != crcKey)
|
||||
{
|
||||
throw std::runtime_error("Key integrity error!");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ ExtractCargo::ExtractCargo()
|
|||
:filesLen(0)
|
||||
, tablePosition(0)
|
||||
, xxhState(XXH64_createState())
|
||||
, signature(SIGNATURE)
|
||||
, signature(fl::sigpak)
|
||||
{
|
||||
// TODO Auto-generated constructor stub
|
||||
XXH64_reset(xxhState, 0);
|
||||
|
|
|
|||
|
|
@ -59,8 +59,7 @@ bool ViewCargo::ViewFiles(const std::string& path)
|
|||
uint64_t tabPos = 0;
|
||||
uint32_t tabSize = 0;
|
||||
|
||||
const std::string signature = SIGNATURE;
|
||||
std::vector<char> magic(signature.length());
|
||||
std::vector<char> magic(fl::sigpak.length());
|
||||
int8_t cargoVer = 0;
|
||||
|
||||
std::ifstream cargo(path, std::ios::binary);
|
||||
|
|
@ -82,7 +81,7 @@ bool ViewCargo::ViewFiles(const std::string& path)
|
|||
cargo.read(reinterpret_cast<char*>(&tabSize), sizeof(tabSize));
|
||||
|
||||
//SprawdŸ czy kontener ma poprawn¹ sygnature
|
||||
if (std::string(magic.begin(), magic.end()) != signature)
|
||||
if (std::string(magic.begin(), magic.end()) != fl::sigpak)
|
||||
{
|
||||
std::cerr << "Error: Corrupted Cargo" << std::endl;
|
||||
cargo.close();
|
||||
|
|
@ -129,15 +128,15 @@ void ViewCargo::ShowFile(const std::string& file, const uint8_t& flag)
|
|||
// Ustawianie checkboxów
|
||||
switch (flag)
|
||||
{
|
||||
case FILE_FLAG_COMPRESS:
|
||||
case flag::zip:
|
||||
compresedCheck = "[x]";
|
||||
break;
|
||||
|
||||
case FILE_FLAG_ENCRYPT:
|
||||
case flag::enc:
|
||||
encryptedCheck = "[x]";
|
||||
break;
|
||||
|
||||
case FILE_FLAG_ZIPENC:
|
||||
case flag::ezd:
|
||||
compresedCheck = "[x]";
|
||||
encryptedCheck = "[x]";
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue