Код: Выделить всё
openssl rand -hex 32 > aes256.key
Код: Выделить всё
std::vector readBytesFromFile(const std::string &file_path) {
// First, try reading as text to check if it's hex
std::ifstream text_file(file_path);
if (!text_file) {
throw std::runtime_error("Failed to open file " + file_path);
}
std::string content((std::istreambuf_iterator(text_file)),
std::istreambuf_iterator());
text_file.close();
// Remove whitespace/newlines to get clean hex string
std::string cleaned;
for (char c : content) {
if (!std::isspace(static_cast(c))) {
cleaned += c;
}
}
std::cout
Подробнее здесь: [url]https://stackoverflow.com/questions/79815776/cpp-auto-detect-the-file-to-read-hex-values-and-raw-binary-content[/url]
Мобильная версия