implement zrif2rif

This commit is contained in:
IllusionMan1212 2021-04-18 07:26:13 +03:00 committed by Watchful
parent 5843816ed7
commit 66f9f70661
3 changed files with 28 additions and 0 deletions

View File

@ -46,6 +46,7 @@ FILE (GLOB HEADER_FILES "../FilesDbParser.h"
"../PfsFilesystem.h"
"../PfsFile.h"
"../rif2zrif.h"
"../zrif2rif.h"
)
source_group ("Header Files" FILES ${HEADER_FILES})
@ -74,6 +75,7 @@ FILE (GLOB SOURCE_FILES "../FilesDbParser.cpp"
"../PfsFilesystem.cpp"
"../PfsFile.cpp"
"../rif2zrif.cpp"
"../zrif2rif.cpp"
)
source_group ("Source Files" FILES ${SOURCE_FILES})

22
zrif2rif.cpp Normal file
View File

@ -0,0 +1,22 @@
#include <b64/cdecode.h>
#include <zRIF/keyflate.h>
#include <cstdint>
#include <cstring>
#include <fstream>
#include <iostream>
#include <string>
void zrif2rif(const std::string &zrif, std::ofstream &outfile) {
constexpr auto MAX_KEY_SIZE = 2048;
constexpr auto MIN_KEY_SIZE = 512;
unsigned char out[MIN_KEY_SIZE];
unsigned char license_data[MIN_KEY_SIZE];
base64_decodestate state;
base64_init_decodestate(&state);
base64_decode_block(zrif.c_str(), zrif.size(), (char *)out, &state);
inflateKey(out, MIN_KEY_SIZE, license_data, MIN_KEY_SIZE);
outfile.write((char *)license_data, sizeof(license_data));
outfile.close();
}

4
zrif2rif.h Normal file
View File

@ -0,0 +1,4 @@
#include <fstream>
#include <string>
void zrif2rif(const std::string &zrif, std::ofstream &outfile);