1/*	$NetBSD: hash.h,v 1.1 2024/02/18 20:57:52 christos Exp $	*/
2
3/*
4 * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
5 *
6 * SPDX-License-Identifier: MPL-2.0
7 *
8 * This Source Code Form is subject to the terms of the Mozilla Public
9 * License, v. 2.0. If a copy of the MPL was not distributed with this
10 * file, you can obtain one at https://mozilla.org/MPL/2.0/.
11 *
12 * See the COPYRIGHT file distributed with this work for additional
13 * information regarding copyright ownership.
14 */
15
16#ifndef ISC_HASH_H
17#define ISC_HASH_H 1
18
19#include <inttypes.h>
20#include <stdbool.h>
21
22#include "isc/lang.h"
23#include "isc/types.h"
24
25/***
26 *** Functions
27 ***/
28ISC_LANG_BEGINDECLS
29
30const void *
31isc_hash_get_initializer(void);
32
33void
34isc_hash_set_initializer(const void *initializer);
35
36#define isc_hash_function isc_hash64
37
38uint32_t
39isc_hash32(const void *data, const size_t length, const bool case_sensitive);
40uint64_t
41isc_hash64(const void *data, const size_t length, const bool case_sensitive);
42/*!<
43 * \brief Calculate a hash over data.
44 *
45 * This hash function is useful for hashtables. The hash function is
46 * opaque and not important to the caller. The returned hash values are
47 * non-deterministic and will have different mapping every time a
48 * process using this library is run, but will have uniform
49 * distribution.
50 *
51 * isc_hash_32/64() calculates the hash from start to end over the
52 * input data.
53 *
54 * 'data' is the data to be hashed.
55 *
56 * 'length' is the size of the data to be hashed.
57 *
58 * 'case_sensitive' specifies whether the hash key should be treated as
59 * case_sensitive values.  It should typically be false if the hash key
60 * is a DNS name.
61 *
62 * Returns:
63 * \li 32 or 64-bit hash value
64 */
65
66ISC_LANG_ENDDECLS
67
68#endif /* ISC_HASH_H */
69