IncludeCPP 2.3.2__tar.gz → 2.3.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {includecpp-2.3.2 → includecpp-2.3.3}/IncludeCPP.egg-info/PKG-INFO +2 -2
- {includecpp-2.3.2 → includecpp-2.3.3}/IncludeCPP.egg-info/SOURCES.txt +0 -30
- {includecpp-2.3.2 → includecpp-2.3.3}/PKG-INFO +2 -2
- {includecpp-2.3.2 → includecpp-2.3.3}/includecpp/__init__.py +1 -1
- {includecpp-2.3.2 → includecpp-2.3.3}/includecpp/core/build_manager.py +2 -1
- {includecpp-2.3.2 → includecpp-2.3.3}/pyproject.toml +2 -2
- {includecpp-2.3.2 → includecpp-2.3.3}/setup.py +1 -1
- includecpp-2.3.2/includecpp/inbuilds/crypto/crypto.cp +0 -18
- includecpp-2.3.2/includecpp/inbuilds/crypto/crypto.cpp +0 -230
- includecpp-2.3.2/includecpp/inbuilds/crypto/crypto.h +0 -36
- includecpp-2.3.2/includecpp/inbuilds/filesystem/filesystem.cp +0 -31
- includecpp-2.3.2/includecpp/inbuilds/filesystem/filesystem.cpp +0 -222
- includecpp-2.3.2/includecpp/inbuilds/filesystem/filesystem.h +0 -50
- includecpp-2.3.2/includecpp/inbuilds/json/json_parser.cp +0 -29
- includecpp-2.3.2/includecpp/inbuilds/json/json_parser.cpp +0 -336
- includecpp-2.3.2/includecpp/inbuilds/json/json_parser.h +0 -62
- includecpp-2.3.2/includecpp/inbuilds/networking/networking.cp +0 -55
- includecpp-2.3.2/includecpp/inbuilds/networking/networking.cpp +0 -768
- includecpp-2.3.2/includecpp/inbuilds/networking/networking.h +0 -118
- includecpp-2.3.2/includecpp/inbuilds/string_utils/string_utils.cp +0 -74
- includecpp-2.3.2/includecpp/inbuilds/string_utils/string_utils.cpp +0 -697
- includecpp-2.3.2/includecpp/inbuilds/string_utils/string_utils.h +0 -107
- {includecpp-2.3.2 → includecpp-2.3.3}/IncludeCPP.egg-info/dependency_links.txt +0 -0
- {includecpp-2.3.2 → includecpp-2.3.3}/IncludeCPP.egg-info/entry_points.txt +0 -0
- {includecpp-2.3.2 → includecpp-2.3.3}/IncludeCPP.egg-info/requires.txt +0 -0
- {includecpp-2.3.2 → includecpp-2.3.3}/IncludeCPP.egg-info/top_level.txt +0 -0
- {includecpp-2.3.2 → includecpp-2.3.3}/LICENSE +0 -0
- {includecpp-2.3.2 → includecpp-2.3.3}/MANIFEST.in +0 -0
- {includecpp-2.3.2 → includecpp-2.3.3}/README.md +0 -0
- {includecpp-2.3.2 → includecpp-2.3.3}/includecpp/__init__.pyi +0 -0
- {includecpp-2.3.2 → includecpp-2.3.3}/includecpp/__main__.py +0 -0
- {includecpp-2.3.2 → includecpp-2.3.3}/includecpp/cli/__init__.py +0 -0
- {includecpp-2.3.2 → includecpp-2.3.3}/includecpp/cli/commands.py +0 -0
- {includecpp-2.3.2 → includecpp-2.3.3}/includecpp/cli/config_parser.py +0 -0
- {includecpp-2.3.2 → includecpp-2.3.3}/includecpp/core/__init__.py +0 -0
- {includecpp-2.3.2 → includecpp-2.3.3}/includecpp/core/cpp_api.py +0 -0
- {includecpp-2.3.2 → includecpp-2.3.3}/includecpp/core/cpp_api.pyi +0 -0
- {includecpp-2.3.2 → includecpp-2.3.3}/includecpp/core/error_formatter.py +0 -0
- {includecpp-2.3.2 → includecpp-2.3.3}/includecpp/core/exceptions.py +0 -0
- {includecpp-2.3.2 → includecpp-2.3.3}/includecpp/generator/__init__.py +0 -0
- {includecpp-2.3.2 → includecpp-2.3.3}/includecpp/generator/parser.cpp +0 -0
- {includecpp-2.3.2 → includecpp-2.3.3}/includecpp/generator/parser.h +0 -0
- {includecpp-2.3.2 → includecpp-2.3.3}/includecpp/generator/type_resolver.cpp +0 -0
- {includecpp-2.3.2 → includecpp-2.3.3}/includecpp/generator/type_resolver.h +0 -0
- {includecpp-2.3.2 → includecpp-2.3.3}/includecpp/inbuilds/__init__.py +0 -0
- {includecpp-2.3.2 → includecpp-2.3.3}/includecpp/templates/cpp.proj.template +0 -0
- {includecpp-2.3.2 → includecpp-2.3.3}/requirements.txt +0 -0
- {includecpp-2.3.2 → includecpp-2.3.3}/setup.cfg +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: IncludeCPP
|
|
3
|
-
Version: 2.3.
|
|
4
|
-
Summary: Professional C++ Python bindings with type-generic templates and native threading
|
|
3
|
+
Version: 2.3.3
|
|
4
|
+
Summary: Professional C++ Python bindings with type-generic templates, pystubs and native threading
|
|
5
5
|
Home-page: https://github.com/includecpp/includecpp
|
|
6
6
|
Author: IncludeCPP Team
|
|
7
7
|
Author-email: IncludeCPP Team <contact@includecpp.dev>
|
|
@@ -21,21 +21,6 @@ setup.py
|
|
|
21
21
|
./includecpp/generator/parser.h
|
|
22
22
|
./includecpp/generator/type_resolver.cpp
|
|
23
23
|
./includecpp/generator/type_resolver.h
|
|
24
|
-
./includecpp/inbuilds/crypto/crypto.cp
|
|
25
|
-
./includecpp/inbuilds/crypto/crypto.cpp
|
|
26
|
-
./includecpp/inbuilds/crypto/crypto.h
|
|
27
|
-
./includecpp/inbuilds/filesystem/filesystem.cp
|
|
28
|
-
./includecpp/inbuilds/filesystem/filesystem.cpp
|
|
29
|
-
./includecpp/inbuilds/filesystem/filesystem.h
|
|
30
|
-
./includecpp/inbuilds/json/json_parser.cp
|
|
31
|
-
./includecpp/inbuilds/json/json_parser.cpp
|
|
32
|
-
./includecpp/inbuilds/json/json_parser.h
|
|
33
|
-
./includecpp/inbuilds/networking/networking.cp
|
|
34
|
-
./includecpp/inbuilds/networking/networking.cpp
|
|
35
|
-
./includecpp/inbuilds/networking/networking.h
|
|
36
|
-
./includecpp/inbuilds/string_utils/string_utils.cp
|
|
37
|
-
./includecpp/inbuilds/string_utils/string_utils.cpp
|
|
38
|
-
./includecpp/inbuilds/string_utils/string_utils.h
|
|
39
24
|
./includecpp/templates/cpp.proj.template
|
|
40
25
|
IncludeCPP.egg-info/PKG-INFO
|
|
41
26
|
IncludeCPP.egg-info/SOURCES.txt
|
|
@@ -61,19 +46,4 @@ includecpp/generator/parser.h
|
|
|
61
46
|
includecpp/generator/type_resolver.cpp
|
|
62
47
|
includecpp/generator/type_resolver.h
|
|
63
48
|
includecpp/inbuilds/__init__.py
|
|
64
|
-
includecpp/inbuilds/crypto/crypto.cp
|
|
65
|
-
includecpp/inbuilds/crypto/crypto.cpp
|
|
66
|
-
includecpp/inbuilds/crypto/crypto.h
|
|
67
|
-
includecpp/inbuilds/filesystem/filesystem.cp
|
|
68
|
-
includecpp/inbuilds/filesystem/filesystem.cpp
|
|
69
|
-
includecpp/inbuilds/filesystem/filesystem.h
|
|
70
|
-
includecpp/inbuilds/json/json_parser.cp
|
|
71
|
-
includecpp/inbuilds/json/json_parser.cpp
|
|
72
|
-
includecpp/inbuilds/json/json_parser.h
|
|
73
|
-
includecpp/inbuilds/networking/networking.cp
|
|
74
|
-
includecpp/inbuilds/networking/networking.cpp
|
|
75
|
-
includecpp/inbuilds/networking/networking.h
|
|
76
|
-
includecpp/inbuilds/string_utils/string_utils.cp
|
|
77
|
-
includecpp/inbuilds/string_utils/string_utils.cpp
|
|
78
|
-
includecpp/inbuilds/string_utils/string_utils.h
|
|
79
49
|
includecpp/templates/cpp.proj.template
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: IncludeCPP
|
|
3
|
-
Version: 2.3.
|
|
4
|
-
Summary: Professional C++ Python bindings with type-generic templates and native threading
|
|
3
|
+
Version: 2.3.3
|
|
4
|
+
Summary: Professional C++ Python bindings with type-generic templates, pystubs and native threading
|
|
5
5
|
Home-page: https://github.com/includecpp/includecpp
|
|
6
6
|
Author: IncludeCPP Team
|
|
7
7
|
Author-email: IncludeCPP Team <contact@includecpp.dev>
|
|
@@ -412,7 +412,7 @@ else()
|
|
|
412
412
|
target_compile_options(api PRIVATE -Wall -O3 -pthread)
|
|
413
413
|
# MinGW on Windows: static linking for MinGW runtime and pthread
|
|
414
414
|
if(WIN32)
|
|
415
|
-
target_link_options(api PRIVATE -static-libgcc -static-libstdc++ -Wl,-Bstatic -lpthread -Wl,-Bdynamic)
|
|
415
|
+
target_link_options(api PRIVATE -static-libgcc -static-libstdc++ -Wl,-Bstatic -lpthread -Wl,-Bdynamic -lws2_32)
|
|
416
416
|
endif()
|
|
417
417
|
endif()
|
|
418
418
|
'''
|
|
@@ -580,6 +580,7 @@ endif()
|
|
|
580
580
|
"-Wl,-Bstatic",
|
|
581
581
|
"-lpthread",
|
|
582
582
|
"-Wl,-Bdynamic",
|
|
583
|
+
"-lws2_32",
|
|
583
584
|
f"-L{python_libs_dir}",
|
|
584
585
|
f"-l{py_version}"
|
|
585
586
|
])
|
|
@@ -4,8 +4,8 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "IncludeCPP"
|
|
7
|
-
version = "2.3.
|
|
8
|
-
description = "Professional C++ Python bindings with type-generic templates and native threading"
|
|
7
|
+
version = "2.3.3"
|
|
8
|
+
description = "Professional C++ Python bindings with type-generic templates, pystubs and native threading"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.8"
|
|
11
11
|
license = {text = "MIT"}
|
|
@@ -6,7 +6,7 @@ long_description = (this_directory / "README.md").read_text(encoding="utf-8")
|
|
|
6
6
|
|
|
7
7
|
setup(
|
|
8
8
|
name="IncludeCPP",
|
|
9
|
-
version="2.3.
|
|
9
|
+
version="2.3.3",
|
|
10
10
|
author="IncludeCPP Team",
|
|
11
11
|
author_email="contact@includecpp.dev",
|
|
12
12
|
description="Professional C++ Python bindings with type-generic templates and native threading",
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
SOURCE(crypto.cpp) && HEADER(crypto.h) crypto
|
|
2
|
-
PUBLIC(
|
|
3
|
-
crypto CLASS(Crypto) {
|
|
4
|
-
METHOD(md5)
|
|
5
|
-
METHOD(sha256)
|
|
6
|
-
METHOD(sha1)
|
|
7
|
-
METHOD(base64_encode)
|
|
8
|
-
METHOD(base64_decode)
|
|
9
|
-
METHOD(hex_encode)
|
|
10
|
-
METHOD(hex_decode)
|
|
11
|
-
METHOD(random_bytes)
|
|
12
|
-
METHOD(random_hex)
|
|
13
|
-
METHOD(random_int)
|
|
14
|
-
METHOD(constant_time_compare)
|
|
15
|
-
}
|
|
16
|
-
crypto FUNC(hash_password)
|
|
17
|
-
crypto FUNC(verify_password)
|
|
18
|
-
)
|
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
#include "crypto.h"
|
|
2
|
-
#include <sstream>
|
|
3
|
-
#include <iomanip>
|
|
4
|
-
#include <random>
|
|
5
|
-
#include <cstring>
|
|
6
|
-
#include <algorithm>
|
|
7
|
-
|
|
8
|
-
namespace includecpp {
|
|
9
|
-
namespace inbuilds {
|
|
10
|
-
|
|
11
|
-
// ===== INTERNAL HELPERS =====
|
|
12
|
-
|
|
13
|
-
namespace {
|
|
14
|
-
// Simple MD5 implementation (basic, for demonstration)
|
|
15
|
-
std::string simple_md5(const std::string& data) {
|
|
16
|
-
// This is a placeholder - in production, use a proper crypto library
|
|
17
|
-
std::hash<std::string> hasher;
|
|
18
|
-
size_t hash = hasher(data);
|
|
19
|
-
std::ostringstream ss;
|
|
20
|
-
ss << std::hex << std::setw(32) << std::setfill('0') << hash;
|
|
21
|
-
return ss.str();
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// Simple SHA256 implementation (basic, for demonstration)
|
|
25
|
-
std::string simple_sha256(const std::string& data) {
|
|
26
|
-
// This is a placeholder - in production, use a proper crypto library
|
|
27
|
-
std::hash<std::string> hasher;
|
|
28
|
-
size_t hash = hasher(data + "sha256_salt");
|
|
29
|
-
std::ostringstream ss;
|
|
30
|
-
ss << std::hex << std::setw(64) << std::setfill('0') << hash;
|
|
31
|
-
return ss.str();
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// Simple SHA1 implementation (basic, for demonstration)
|
|
35
|
-
std::string simple_sha1(const std::string& data) {
|
|
36
|
-
std::hash<std::string> hasher;
|
|
37
|
-
size_t hash = hasher(data + "sha1_salt");
|
|
38
|
-
std::ostringstream ss;
|
|
39
|
-
ss << std::hex << std::setw(40) << std::setfill('0') << hash;
|
|
40
|
-
return ss.str();
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const std::string base64_chars =
|
|
44
|
-
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
|
45
|
-
"abcdefghijklmnopqrstuvwxyz"
|
|
46
|
-
"0123456789+/";
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// ===== HASHING =====
|
|
50
|
-
|
|
51
|
-
std::string Crypto::md5(const std::string& data) {
|
|
52
|
-
return simple_md5(data);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
std::string Crypto::sha256(const std::string& data) {
|
|
56
|
-
return simple_sha256(data);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
std::string Crypto::sha1(const std::string& data) {
|
|
60
|
-
return simple_sha1(data);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// ===== ENCODING/DECODING =====
|
|
64
|
-
|
|
65
|
-
std::string Crypto::base64_encode(const std::string& data) {
|
|
66
|
-
std::string ret;
|
|
67
|
-
int i = 0;
|
|
68
|
-
int j = 0;
|
|
69
|
-
unsigned char char_array_3[3];
|
|
70
|
-
unsigned char char_array_4[4];
|
|
71
|
-
size_t in_len = data.size();
|
|
72
|
-
const unsigned char* bytes_to_encode = reinterpret_cast<const unsigned char*>(data.c_str());
|
|
73
|
-
|
|
74
|
-
while (in_len--) {
|
|
75
|
-
char_array_3[i++] = *(bytes_to_encode++);
|
|
76
|
-
if (i == 3) {
|
|
77
|
-
char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
|
|
78
|
-
char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
|
|
79
|
-
char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
|
|
80
|
-
char_array_4[3] = char_array_3[2] & 0x3f;
|
|
81
|
-
|
|
82
|
-
for(i = 0; i < 4; i++)
|
|
83
|
-
ret += base64_chars[char_array_4[i]];
|
|
84
|
-
i = 0;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if (i) {
|
|
89
|
-
for(j = i; j < 3; j++)
|
|
90
|
-
char_array_3[j] = '\0';
|
|
91
|
-
|
|
92
|
-
char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
|
|
93
|
-
char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
|
|
94
|
-
char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
|
|
95
|
-
|
|
96
|
-
for (j = 0; j < i + 1; j++)
|
|
97
|
-
ret += base64_chars[char_array_4[j]];
|
|
98
|
-
|
|
99
|
-
while((i++ < 3))
|
|
100
|
-
ret += '=';
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
return ret;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
std::string Crypto::base64_decode(const std::string& encoded) {
|
|
107
|
-
size_t in_len = encoded.size();
|
|
108
|
-
int i = 0;
|
|
109
|
-
int j = 0;
|
|
110
|
-
int in_ = 0;
|
|
111
|
-
unsigned char char_array_4[4], char_array_3[3];
|
|
112
|
-
std::string ret;
|
|
113
|
-
|
|
114
|
-
while (in_len-- && encoded[in_] != '=') {
|
|
115
|
-
if (!isalnum(encoded[in_]) && encoded[in_] != '+' && encoded[in_] != '/') {
|
|
116
|
-
in_++;
|
|
117
|
-
continue;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
char_array_4[i++] = encoded[in_]; in_++;
|
|
121
|
-
if (i == 4) {
|
|
122
|
-
for (i = 0; i < 4; i++)
|
|
123
|
-
char_array_4[i] = static_cast<unsigned char>(base64_chars.find(char_array_4[i]));
|
|
124
|
-
|
|
125
|
-
char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
|
|
126
|
-
char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
|
|
127
|
-
char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
|
|
128
|
-
|
|
129
|
-
for (i = 0; i < 3; i++)
|
|
130
|
-
ret += char_array_3[i];
|
|
131
|
-
i = 0;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
if (i) {
|
|
136
|
-
for (j = 0; j < i; j++)
|
|
137
|
-
char_array_4[j] = static_cast<unsigned char>(base64_chars.find(char_array_4[j]));
|
|
138
|
-
|
|
139
|
-
char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
|
|
140
|
-
char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
|
|
141
|
-
|
|
142
|
-
for (j = 0; j < i - 1; j++) ret += char_array_3[j];
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
return ret;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
std::string Crypto::hex_encode(const std::string& data) {
|
|
149
|
-
std::ostringstream ss;
|
|
150
|
-
ss << std::hex << std::setfill('0');
|
|
151
|
-
for (unsigned char c : data) {
|
|
152
|
-
ss << std::setw(2) << static_cast<int>(c);
|
|
153
|
-
}
|
|
154
|
-
return ss.str();
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
std::string Crypto::hex_decode(const std::string& hex) {
|
|
158
|
-
std::string result;
|
|
159
|
-
for (size_t i = 0; i < hex.length(); i += 2) {
|
|
160
|
-
std::string byte = hex.substr(i, 2);
|
|
161
|
-
char chr = static_cast<char>(strtol(byte.c_str(), nullptr, 16));
|
|
162
|
-
result.push_back(chr);
|
|
163
|
-
}
|
|
164
|
-
return result;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
// ===== RANDOM =====
|
|
168
|
-
|
|
169
|
-
std::string Crypto::random_bytes(int length) {
|
|
170
|
-
static std::random_device rd;
|
|
171
|
-
static std::mt19937 gen(rd());
|
|
172
|
-
static std::uniform_int_distribution<> dis(0, 255);
|
|
173
|
-
|
|
174
|
-
std::string result;
|
|
175
|
-
result.reserve(length);
|
|
176
|
-
for (int i = 0; i < length; ++i) {
|
|
177
|
-
result += static_cast<char>(dis(gen));
|
|
178
|
-
}
|
|
179
|
-
return result;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
std::string Crypto::random_hex(int length) {
|
|
183
|
-
return hex_encode(random_bytes(length));
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
int Crypto::random_int(int min, int max) {
|
|
187
|
-
static std::random_device rd;
|
|
188
|
-
static std::mt19937 gen(rd());
|
|
189
|
-
std::uniform_int_distribution<> dis(min, max);
|
|
190
|
-
return dis(gen);
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
// ===== UTILITY =====
|
|
194
|
-
|
|
195
|
-
bool Crypto::constant_time_compare(const std::string& a, const std::string& b) {
|
|
196
|
-
if (a.length() != b.length()) {
|
|
197
|
-
return false;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
volatile unsigned char result = 0;
|
|
201
|
-
for (size_t i = 0; i < a.length(); ++i) {
|
|
202
|
-
result |= a[i] ^ b[i];
|
|
203
|
-
}
|
|
204
|
-
return result == 0;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
// ===== FREE FUNCTIONS =====
|
|
208
|
-
|
|
209
|
-
std::string hash_password(const std::string& password) {
|
|
210
|
-
// Simple password hashing (use proper library in production!)
|
|
211
|
-
std::string salt = Crypto::random_hex(16);
|
|
212
|
-
std::string hash = Crypto::sha256(password + salt);
|
|
213
|
-
return salt + ":" + hash;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
bool verify_password(const std::string& password, const std::string& hash) {
|
|
217
|
-
size_t colon_pos = hash.find(':');
|
|
218
|
-
if (colon_pos == std::string::npos) {
|
|
219
|
-
return false;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
std::string salt = hash.substr(0, colon_pos);
|
|
223
|
-
std::string stored_hash = hash.substr(colon_pos + 1);
|
|
224
|
-
std::string computed_hash = Crypto::sha256(password + salt);
|
|
225
|
-
|
|
226
|
-
return Crypto::constant_time_compare(computed_hash, stored_hash);
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
} // namespace inbuilds
|
|
230
|
-
} // namespace includecpp
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
#include <string>
|
|
3
|
-
#include <vector>
|
|
4
|
-
#include <cstdint>
|
|
5
|
-
|
|
6
|
-
namespace includecpp {
|
|
7
|
-
namespace inbuilds {
|
|
8
|
-
|
|
9
|
-
class Crypto {
|
|
10
|
-
public:
|
|
11
|
-
// Hashing
|
|
12
|
-
static std::string md5(const std::string& data);
|
|
13
|
-
static std::string sha256(const std::string& data);
|
|
14
|
-
static std::string sha1(const std::string& data);
|
|
15
|
-
|
|
16
|
-
// Encoding/Decoding
|
|
17
|
-
static std::string base64_encode(const std::string& data);
|
|
18
|
-
static std::string base64_decode(const std::string& encoded);
|
|
19
|
-
static std::string hex_encode(const std::string& data);
|
|
20
|
-
static std::string hex_decode(const std::string& hex);
|
|
21
|
-
|
|
22
|
-
// Random
|
|
23
|
-
static std::string random_bytes(int length);
|
|
24
|
-
static std::string random_hex(int length);
|
|
25
|
-
static int random_int(int min, int max);
|
|
26
|
-
|
|
27
|
-
// Utility
|
|
28
|
-
static bool constant_time_compare(const std::string& a, const std::string& b);
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
// Free functions
|
|
32
|
-
std::string hash_password(const std::string& password);
|
|
33
|
-
bool verify_password(const std::string& password, const std::string& hash);
|
|
34
|
-
|
|
35
|
-
} // namespace inbuilds
|
|
36
|
-
} // namespace includecpp
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
SOURCE(filesystem.cpp) && HEADER(filesystem.h) filesystem
|
|
2
|
-
PUBLIC(
|
|
3
|
-
filesystem CLASS(FileSystem) {
|
|
4
|
-
METHOD(exists)
|
|
5
|
-
METHOD(is_file)
|
|
6
|
-
METHOD(is_directory)
|
|
7
|
-
METHOD(read_file)
|
|
8
|
-
METHOD(write_file)
|
|
9
|
-
METHOD(append_file)
|
|
10
|
-
METHOD(delete_file)
|
|
11
|
-
METHOD(copy_file)
|
|
12
|
-
METHOD(move_file)
|
|
13
|
-
METHOD(file_size)
|
|
14
|
-
METHOD(create_directory)
|
|
15
|
-
METHOD(remove_directory)
|
|
16
|
-
METHOD(list_directory)
|
|
17
|
-
METHOD(list_files)
|
|
18
|
-
METHOD(list_subdirectories)
|
|
19
|
-
METHOD(get_absolute_path)
|
|
20
|
-
METHOD(get_filename)
|
|
21
|
-
METHOD(get_extension)
|
|
22
|
-
METHOD(get_parent_path)
|
|
23
|
-
METHOD(join_paths)
|
|
24
|
-
METHOD(get_current_directory)
|
|
25
|
-
METHOD(set_current_directory)
|
|
26
|
-
}
|
|
27
|
-
filesystem FUNC(read_text)
|
|
28
|
-
filesystem FUNC(write_text)
|
|
29
|
-
filesystem FUNC(read_lines)
|
|
30
|
-
filesystem FUNC(write_lines)
|
|
31
|
-
)
|
|
@@ -1,222 +0,0 @@
|
|
|
1
|
-
#include "filesystem.h"
|
|
2
|
-
#include <iostream>
|
|
3
|
-
#include <sstream>
|
|
4
|
-
|
|
5
|
-
namespace fs = std::filesystem;
|
|
6
|
-
|
|
7
|
-
namespace includecpp {
|
|
8
|
-
namespace inbuilds {
|
|
9
|
-
|
|
10
|
-
// ===== FILE OPERATIONS =====
|
|
11
|
-
|
|
12
|
-
bool FileSystem::exists(const std::string& path) {
|
|
13
|
-
return fs::exists(path);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
bool FileSystem::is_file(const std::string& path) {
|
|
17
|
-
return fs::is_regular_file(path);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
bool FileSystem::is_directory(const std::string& path) {
|
|
21
|
-
return fs::is_directory(path);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
std::string FileSystem::read_file(const std::string& path) {
|
|
25
|
-
std::ifstream file(path, std::ios::binary);
|
|
26
|
-
if (!file.is_open()) {
|
|
27
|
-
throw std::runtime_error("Cannot open file: " + path);
|
|
28
|
-
}
|
|
29
|
-
std::ostringstream ss;
|
|
30
|
-
ss << file.rdbuf();
|
|
31
|
-
return ss.str();
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
bool FileSystem::write_file(const std::string& path, const std::string& content) {
|
|
35
|
-
std::ofstream file(path, std::ios::binary);
|
|
36
|
-
if (!file.is_open()) {
|
|
37
|
-
return false;
|
|
38
|
-
}
|
|
39
|
-
file << content;
|
|
40
|
-
return file.good();
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
bool FileSystem::append_file(const std::string& path, const std::string& content) {
|
|
44
|
-
std::ofstream file(path, std::ios::binary | std::ios::app);
|
|
45
|
-
if (!file.is_open()) {
|
|
46
|
-
return false;
|
|
47
|
-
}
|
|
48
|
-
file << content;
|
|
49
|
-
return file.good();
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
bool FileSystem::delete_file(const std::string& path) {
|
|
53
|
-
try {
|
|
54
|
-
return fs::remove(path);
|
|
55
|
-
} catch (...) {
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
bool FileSystem::copy_file(const std::string& src, const std::string& dst) {
|
|
61
|
-
try {
|
|
62
|
-
fs::copy_file(src, dst, fs::copy_options::overwrite_existing);
|
|
63
|
-
return true;
|
|
64
|
-
} catch (...) {
|
|
65
|
-
return false;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
bool FileSystem::move_file(const std::string& src, const std::string& dst) {
|
|
70
|
-
try {
|
|
71
|
-
fs::rename(src, dst);
|
|
72
|
-
return true;
|
|
73
|
-
} catch (...) {
|
|
74
|
-
return false;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
long long FileSystem::file_size(const std::string& path) {
|
|
79
|
-
try {
|
|
80
|
-
return static_cast<long long>(fs::file_size(path));
|
|
81
|
-
} catch (...) {
|
|
82
|
-
return -1;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// ===== DIRECTORY OPERATIONS =====
|
|
87
|
-
|
|
88
|
-
bool FileSystem::create_directory(const std::string& path) {
|
|
89
|
-
try {
|
|
90
|
-
return fs::create_directories(path);
|
|
91
|
-
} catch (...) {
|
|
92
|
-
return false;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
bool FileSystem::remove_directory(const std::string& path) {
|
|
97
|
-
try {
|
|
98
|
-
return fs::remove_all(path) > 0;
|
|
99
|
-
} catch (...) {
|
|
100
|
-
return false;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
std::vector<std::string> FileSystem::list_directory(const std::string& path) {
|
|
105
|
-
std::vector<std::string> result;
|
|
106
|
-
try {
|
|
107
|
-
for (const auto& entry : fs::directory_iterator(path)) {
|
|
108
|
-
result.push_back(entry.path().filename().string());
|
|
109
|
-
}
|
|
110
|
-
} catch (...) {
|
|
111
|
-
// Return empty vector on error
|
|
112
|
-
}
|
|
113
|
-
return result;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
std::vector<std::string> FileSystem::list_files(const std::string& path, const std::string& extension) {
|
|
117
|
-
std::vector<std::string> result;
|
|
118
|
-
try {
|
|
119
|
-
for (const auto& entry : fs::directory_iterator(path)) {
|
|
120
|
-
if (entry.is_regular_file()) {
|
|
121
|
-
if (extension.empty() || entry.path().extension() == extension) {
|
|
122
|
-
result.push_back(entry.path().filename().string());
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
} catch (...) {
|
|
127
|
-
// Return empty vector on error
|
|
128
|
-
}
|
|
129
|
-
return result;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
std::vector<std::string> FileSystem::list_subdirectories(const std::string& path) {
|
|
133
|
-
std::vector<std::string> result;
|
|
134
|
-
try {
|
|
135
|
-
for (const auto& entry : fs::directory_iterator(path)) {
|
|
136
|
-
if (entry.is_directory()) {
|
|
137
|
-
result.push_back(entry.path().filename().string());
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
} catch (...) {
|
|
141
|
-
// Return empty vector on error
|
|
142
|
-
}
|
|
143
|
-
return result;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
// ===== PATH OPERATIONS =====
|
|
147
|
-
|
|
148
|
-
std::string FileSystem::get_absolute_path(const std::string& path) {
|
|
149
|
-
try {
|
|
150
|
-
return fs::absolute(path).string();
|
|
151
|
-
} catch (...) {
|
|
152
|
-
return path;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
std::string FileSystem::get_filename(const std::string& path) {
|
|
157
|
-
return fs::path(path).filename().string();
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
std::string FileSystem::get_extension(const std::string& path) {
|
|
161
|
-
return fs::path(path).extension().string();
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
std::string FileSystem::get_parent_path(const std::string& path) {
|
|
165
|
-
return fs::path(path).parent_path().string();
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
std::string FileSystem::join_paths(const std::string& p1, const std::string& p2) {
|
|
169
|
-
return (fs::path(p1) / p2).string();
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
// ===== FILE INFO =====
|
|
173
|
-
|
|
174
|
-
std::string FileSystem::get_current_directory() {
|
|
175
|
-
return fs::current_path().string();
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
bool FileSystem::set_current_directory(const std::string& path) {
|
|
179
|
-
try {
|
|
180
|
-
fs::current_path(path);
|
|
181
|
-
return true;
|
|
182
|
-
} catch (...) {
|
|
183
|
-
return false;
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
// ===== FREE FUNCTIONS =====
|
|
188
|
-
|
|
189
|
-
std::string read_text(const std::string& path) {
|
|
190
|
-
return FileSystem::read_file(path);
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
bool write_text(const std::string& path, const std::string& content) {
|
|
194
|
-
return FileSystem::write_file(path, content);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
std::vector<std::string> read_lines(const std::string& path) {
|
|
198
|
-
std::vector<std::string> lines;
|
|
199
|
-
std::ifstream file(path);
|
|
200
|
-
if (!file.is_open()) {
|
|
201
|
-
throw std::runtime_error("Cannot open file: " + path);
|
|
202
|
-
}
|
|
203
|
-
std::string line;
|
|
204
|
-
while (std::getline(file, line)) {
|
|
205
|
-
lines.push_back(line);
|
|
206
|
-
}
|
|
207
|
-
return lines;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
bool write_lines(const std::string& path, const std::vector<std::string>& lines) {
|
|
211
|
-
std::ofstream file(path);
|
|
212
|
-
if (!file.is_open()) {
|
|
213
|
-
return false;
|
|
214
|
-
}
|
|
215
|
-
for (const auto& line : lines) {
|
|
216
|
-
file << line << '\n';
|
|
217
|
-
}
|
|
218
|
-
return file.good();
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
} // namespace inbuilds
|
|
222
|
-
} // namespace includecpp
|