/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // Spooky Hash // A 128-bit noncryptographic hash, for checksums and table lookup // By Bob Jenkins. Public domain. // Oct 31 2010: published framework, disclaimer ShortHash isn't right // Nov 7 2010: disabled ShortHash // Oct 31 2011: replace End, ShortMix, ShortEnd, enable ShortHash again // April 10 2012: buffer overflow on platforms without unaligned reads // July 12 2012: was passing out variables in final to in/out in short // July 30 2012: I reintroduced the buffer overflow // August 5 2012: SpookyV2: d = should be d += in short hash, and remove // extra mix from long hash #include <folly/hash/SpookyHashV2.h> #include <cstring> #include <folly/CppAttributes.h> #include <folly/Portability.h> namespace folly { namespace hash { // clang-format off // // short hash ... it could be used on any message, // but it's used by Spooky just for short messages. // void SpookyHashV2::Short( const void *message, size_t length, uint64_t *hash1, uint64_t *hash2) { … } // do the whole hash in one call void SpookyHashV2::Hash128( const void *message, size_t length, uint64_t *hash1, uint64_t *hash2) { … } // init spooky state void SpookyHashV2::Init(uint64_t seed1, uint64_t seed2) { … } // add a message fragment to the state void SpookyHashV2::Update(const void *message, size_t length) { … } // report the hash for the concatenation of all message fragments so far void SpookyHashV2::Final(uint64_t *hash1, uint64_t *hash2) const { … } // clang-format on } // namespace hash } // namespace folly