diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-07-04 16:46:24 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-07-04 16:46:24 -0400 |
| commit | 78960b1461a8fb184de4ffddf2d2ec4df729fb05 (patch) | |
| tree | f62f39c9d6b420c304bffba8143a41789980e68a /builtins/array.c | |
| parent | dfb7bb1984b555519851d084ac8b5f8e760c55ce (diff) | |
Randomize hash key on startup and rename to TOMO_HASH_KEY.
Diffstat (limited to 'builtins/array.c')
| -rw-r--r-- | builtins/array.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/builtins/array.c b/builtins/array.c index 1b928635..69d5cff1 100644 --- a/builtins/array.c +++ b/builtins/array.c @@ -426,7 +426,7 @@ public uint32_t Array$hash(const array_t *arr, const TypeInfo *type) for (int64_t i = 0; i < arr->length; i++) { if (p >= end) { uint32_t chunk_hash; - halfsiphash(&hash_batch, sizeof(hash_batch), TOMO_HASH_VECTOR, (uint8_t*)&chunk_hash, sizeof(chunk_hash)); + halfsiphash(&hash_batch, sizeof(hash_batch), TOMO_HASH_KEY, (uint8_t*)&chunk_hash, sizeof(chunk_hash)); p = hash_batch; *(uint32_t*)p = chunk_hash; p += sizeof(uint32_t); @@ -434,7 +434,7 @@ public uint32_t Array$hash(const array_t *arr, const TypeInfo *type) memcpy((p += item_size), arr->data + i*arr->stride, item_size); } uint32_t hash; - halfsiphash(&hash_batch, ((int64_t)p) - ((int64_t)hash_batch), TOMO_HASH_VECTOR, (uint8_t*)&hash, sizeof(hash)); + halfsiphash(&hash_batch, ((int64_t)p) - ((int64_t)hash_batch), TOMO_HASH_KEY, (uint8_t*)&hash, sizeof(hash)); return hash; } else { uint32_t hash_batch[16] = {(uint32_t)arr->length}; @@ -442,14 +442,14 @@ public uint32_t Array$hash(const array_t *arr, const TypeInfo *type) for (int64_t i = 0; i < arr->length; i++) { if (p >= end) { uint64_t chunk_hash; - halfsiphash(&hash_batch, sizeof(hash_batch), TOMO_HASH_VECTOR, (uint8_t*)&chunk_hash, sizeof(chunk_hash)); + halfsiphash(&hash_batch, sizeof(hash_batch), TOMO_HASH_KEY, (uint8_t*)&chunk_hash, sizeof(chunk_hash)); p = hash_batch; *(p++) = chunk_hash; } *(p++) = generic_hash(arr->data + i*arr->stride, item); } uint32_t hash; - halfsiphash(&hash_batch, ((int64_t)p) - ((int64_t)hash_batch), TOMO_HASH_VECTOR, (uint8_t*)&hash, sizeof(hash)); + halfsiphash(&hash_batch, ((int64_t)p) - ((int64_t)hash_batch), TOMO_HASH_KEY, (uint8_t*)&hash, sizeof(hash)); return hash; } } |
