1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-08 03:28:20 +02:00

Made string hashing more robust

We need to ensure that mixing in "AB" and then "C" is distinct from "A" and then "BC" - so we mix in the length ahead
This commit is contained in:
Brian Fiete 2019-11-02 06:14:38 -07:00
parent 558f8678e1
commit a26427392f

View file

@ -1406,17 +1406,22 @@ void HashContext::Mixin(const void* data, int size)
void HashContext::MixinHashContext(HashContext& ctx)
{
Mixin(ctx.mBufSize);
Mixin(ctx.mBuf, ctx.mBufSize);
}
void HashContext::MixinStr(const char* str)
{
Mixin(str, (int)strlen(str));
int len = (int)strlen(str);
Mixin(len);
Mixin(str, len);
}
void HashContext::MixinStr(const StringImpl& str)
{
Mixin(str.c_str(), (int)str.length());
int len = (int)str.length();
Mixin(len);
Mixin(str.c_str(), len);
}
Val128 HashContext::Finish128()