libcoap
4.3.5-develop-19cef11
coap_hashkey.c
Go to the documentation of this file.
1
/* coap_hashkey.c -- definition of hash key type and helper functions
2
*
3
* Copyright (C) 2010-2024 Olaf Bergmann <bergmann@tzi.org>
4
*
5
* SPDX-License-Identifier: BSD-2-Clause
6
*
7
* This file is part of the CoAP library libcoap. Please see
8
* README for terms of use.
9
*/
10
16
#include "
coap3/coap_libcoap_build.h
"
17
18
void
19
coap_hash_impl
(
const
unsigned
char
*s,
size_t
len,
coap_key_t
h) {
20
size_t
j;
21
22
while
(len--) {
23
j =
sizeof
(
coap_key_t
)-1;
24
25
while
(j) {
26
h[j] = ((h[j] << 7) | (h[j-1] >> 1)) + h[j];
27
--j;
28
}
29
30
h[0] = (h[0] << 7) + h[0] + *s++;
31
}
32
}
coap_hash_impl
void coap_hash_impl(const unsigned char *s, size_t len, coap_key_t h)
Calculates a fast hash over the given string s of length len and stores the result into h.
Definition:
coap_hashkey.c:19
coap_key_t
unsigned char coap_key_t[4]
Definition:
coap_hashkey_internal.h:24
coap_libcoap_build.h
Library specific build wrapper for coap_internal.h.
libcoap
src
coap_hashkey.c
Generated on Tue Nov 12 2024 02:06:02 for libcoap by
1.9.4