mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 19:48: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:
parent
558f8678e1
commit
a26427392f
1 changed files with 7 additions and 2 deletions
|
@ -1406,17 +1406,22 @@ void HashContext::Mixin(const void* data, int size)
|
||||||
|
|
||||||
void HashContext::MixinHashContext(HashContext& ctx)
|
void HashContext::MixinHashContext(HashContext& ctx)
|
||||||
{
|
{
|
||||||
|
Mixin(ctx.mBufSize);
|
||||||
Mixin(ctx.mBuf, ctx.mBufSize);
|
Mixin(ctx.mBuf, ctx.mBufSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HashContext::MixinStr(const char* str)
|
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)
|
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()
|
Val128 HashContext::Finish128()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue