5#include <BufferStream.h>
10 BufferStreamReadOnly reader{data.data(), data.size()};
15 reader.seek(
SIGNATURE.length() +
sizeof(uint8_t), std::ios::end);
17 auto bytes = reader.read<uint8_t>();
19 std::vector<std::byte> out;
20 out.resize(reader.size() -
SIGNATURE.length() - bytes);
22 reader.seek(-
static_cast<int>(bytes), std::ios::cur);
23 uint8_t magic =
MAGIC;
24 for (
int i = 0; i < bytes - 1; i++) {
25 magic ^= reader.read<uint8_t>() +
MAGIC;
29 for (
auto& outByte : out) {
30 auto byte = reader.read<uint8_t>();
31 outByte =
static_cast<std::byte
>(
byte ^ magic);
constexpr std::string_view SIGNATURE
std::vector< std::byte > decrypt(std::span< const std::byte > data)