mirror of
https://github.com/kwsch/pkNX.git
synced 2026-09-13 13:05:17 -05:00
Add prefix support
This commit is contained in:
@@ -16,7 +16,7 @@ std::string FnvHashDecoder::BuildString(const size_t length) const
|
||||
return { chars.begin(), chars.end() };
|
||||
}
|
||||
|
||||
std::unordered_map<uint64_t, std::string> FnvHashDecoder::StartDecoding(const int length, const int startChar)
|
||||
std::unordered_map<uint64_t, std::string> FnvHashDecoder::StartDecoding(const int length, const int startChar, const std::string_view prefix)
|
||||
{
|
||||
std::unordered_map<uint64_t, std::string> foundKeys;
|
||||
|
||||
@@ -24,8 +24,16 @@ std::unordered_map<uint64_t, std::string> FnvHashDecoder::StartDecoding(const in
|
||||
0xC75DDBE25402B11C,
|
||||
};
|
||||
|
||||
const size_t startIndex = prefix.length();
|
||||
|
||||
// Reset all chars to starting point
|
||||
charIndex[0] = (uint32_t)startChar;
|
||||
for (int i = 0; i < prefix.length(); ++i)
|
||||
{
|
||||
const auto& ch = prefix[i];
|
||||
charIndex[i] = AllowedChars.find_first_of(ch);
|
||||
}
|
||||
|
||||
charIndex[startIndex] = (uint32_t)startChar;
|
||||
|
||||
// Build the hash of all chars except the last one
|
||||
hashBases[0] = kOffsetBasis_64;
|
||||
@@ -39,7 +47,7 @@ std::unordered_map<uint64_t, std::string> FnvHashDecoder::StartDecoding(const in
|
||||
}
|
||||
|
||||
//LoopTimer timer{};
|
||||
while (charIndex[0] == startChar)
|
||||
while (charIndex[startIndex] == startChar)
|
||||
{
|
||||
// Loop through all AllowedChars
|
||||
const uint64_t hashBase = hashBases[length - 1];
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace pkNXHashDecoder {
|
||||
class __declspec(align(64)) FnvHashDecoder
|
||||
{
|
||||
public:
|
||||
std::unordered_map<uint64_t, std::string> StartDecoding(int length, int startChar);
|
||||
std::unordered_map<uint64_t, std::string> StartDecoding(int length, int startChar, std::string_view prefix);
|
||||
|
||||
constexpr static int MAX_LENGTH = 128;
|
||||
constexpr static std::string_view AllowedChars = "etaoinshrdlcumw_0123456789fgypbvkjxqz/."; // Sorted by most common first
|
||||
|
||||
Reference in New Issue
Block a user