Skip to content

Commit

Permalink
ObfusString: Fix consteval failure for excessively large strings
Browse files Browse the repository at this point in the history
  • Loading branch information
Sainan committed Jan 16, 2025
1 parent add575b commit 59f84dd
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions soup/ObfusString.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,18 @@ NAMESPACE_SOUP
// flip bits
for (size_t i = 0; i != Len; ++i)
{
m_data[i] ^= rng.generateByte();
const auto m = i % 8;
m_data[i] ^= rng.state >> (m * 8);
if (m == 7)
{
rng.skip();
}
}

// mirror
if (Len < 30000)
for (size_t i = 0, j = Len - 1; i != Len / 2; ++i, --j)
{
for (size_t i = 0, j = Len - 1; i != Len / 2; ++i, --j)
{
std::swap(m_data[i], m_data[j]);
}
std::swap(m_data[i], m_data[j]);
}
}

Expand All @@ -75,18 +77,20 @@ NAMESPACE_SOUP
seed = 0;

// mirror
if (Len < 30000)
for (size_t i = 0, j = Len - 1; i != Len / 2; ++i, --j)
{
for (size_t i = 0, j = Len - 1; i != Len / 2; ++i, --j)
{
std::swap(m_data[i], m_data[j]);
}
std::swap(m_data[i], m_data[j]);
}

// flip bits
for (size_t i = 0; i != Len; ++i)
{
m_data[i] ^= rng.generateByte();
const auto m = i % 8;
m_data[i] ^= rng.state >> (m * 8);
if (m == 7)
{
rng.skip();
}
}

// rot13
Expand Down

0 comments on commit 59f84dd

Please sign in to comment.