oddělení, čištění, kontrola ELC1
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
#include <openssl/ssl.h> /* core library */
|
||||
#include "utils.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
const std::string base64_chars =
|
||||
@@ -26,7 +25,7 @@ void getCharsFromString(string &source, char *charArray, size_t length)
|
||||
|
||||
void getCharsFromString(string source, char *charArray)
|
||||
{
|
||||
size_t length = source.length();
|
||||
size_t length = source.length();
|
||||
for (size_t i = 0; i < length; i++)
|
||||
{
|
||||
charArray[i] = source[i];
|
||||
@@ -117,8 +116,8 @@ int encrypt(const unsigned char *plaintext, int plaintext_len, unsigned char *ke
|
||||
int ciphertext_len;
|
||||
|
||||
/* Create and initialise the context */
|
||||
if (!(ctx = EVP_CIPHER_CTX_new())) return -1;
|
||||
|
||||
if (!(ctx = EVP_CIPHER_CTX_new()))
|
||||
return -1;
|
||||
|
||||
/*
|
||||
* Initialise the encryption operation. IMPORTANT - ensure you use a key
|
||||
@@ -180,7 +179,7 @@ int decrypt(const unsigned char *ciphertext, int ciphertext_len, unsigned char *
|
||||
* EVP_DecryptUpdate can be called multiple times if necessary.
|
||||
*/
|
||||
if (1 != EVP_DecryptUpdate(ctx, plaintext, &len, ciphertext, ciphertext_len))
|
||||
return -1;
|
||||
return -1;
|
||||
plaintext_len = len;
|
||||
|
||||
/*
|
||||
@@ -188,7 +187,7 @@ int decrypt(const unsigned char *ciphertext, int ciphertext_len, unsigned char *
|
||||
* this stage.
|
||||
*/
|
||||
if (1 != EVP_DecryptFinal_ex(ctx, plaintext + len, &len))
|
||||
return -1;
|
||||
return -1;
|
||||
|
||||
plaintext_len += len;
|
||||
|
||||
@@ -316,17 +315,17 @@ string getCompletePath(string fileName)
|
||||
#ifdef WINDOWS
|
||||
return fileName;
|
||||
#else
|
||||
//warning TODO filesystem
|
||||
char path[PATH_MAX+1] = {};
|
||||
ssize_t length = readlink("/proc/self/exe", path, PATH_MAX);
|
||||
path[length] = '\0';
|
||||
string result = string(dirname(path)) + "/" + fileName;
|
||||
return result;
|
||||
//return std::string( result, (count > 0) ? count : 0 );
|
||||
// std::filesystem::path exePath = std::filesystem::canonical("/proc/self/exe"); // / std::filesystem::path(argv[0]));
|
||||
// std::filesystem::path fullPathOther = exePath.parent_path() / fileName;
|
||||
// std::string fullPathStrOther = fullPathOther.string();
|
||||
// return fullPathStrOther;
|
||||
|
||||
char path[PATH_MAX + 1] = {};
|
||||
ssize_t length = readlink("/proc/self/exe", path, PATH_MAX);
|
||||
path[length] = '\0';
|
||||
string result = string(dirname(path)) + "/" + fileName;
|
||||
return result;
|
||||
// return std::string( result, (count > 0) ? count : 0 );
|
||||
// std::filesystem::path exePath = std::filesystem::canonical("/proc/self/exe"); // / std::filesystem::path(argv[0]));
|
||||
// std::filesystem::path fullPathOther = exePath.parent_path() / fileName;
|
||||
// std::string fullPathStrOther = fullPathOther.string();
|
||||
// return fullPathStrOther;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -390,7 +389,7 @@ std::vector<unsigned char> joinVectors(const std::vector<unsigned char> &vector1
|
||||
bool readFile(string fileName, vector<char> &output)
|
||||
{
|
||||
std::ifstream file(fileName, std::ios::in | std::ios::binary);
|
||||
|
||||
|
||||
if (file.is_open() != 1)
|
||||
{
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user