1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
11 #include "base/base_export.h"
12 #include "base/basictypes.h"
13 #include "base/logging.h"
17 // WARNING: This hash function should not be used for any cryptographic purpose.
18 BASE_EXPORT uint32
SuperFastHash(const char* data
, int len
);
20 // Computes a hash of a memory buffer |data| of a given |length|.
21 // WARNING: This hash function should not be used for any cryptographic purpose.
22 inline uint32
Hash(const char* data
, size_t length
) {
23 if (length
> static_cast<size_t>(std::numeric_limits
<int>::max())) {
27 return SuperFastHash(data
, static_cast<int>(length
));
30 // Computes a hash of a string |str|.
31 // WARNING: This hash function should not be used for any cryptographic purpose.
32 inline uint32
Hash(const std::string
& str
) {
33 return Hash(str
.data(), str
.size());
38 #endif // BASE_HASH_H_