1 /* hashkey.c -- definition of hash key type and helper functions
3 * Copyright (C) 2010,2011 Olaf Bergmann <bergmann@tzi.org>
5 * This file is part of the CoAP library libcoap. Please see
6 * README for terms of use.
11 /* Caution: When changing this, update COAP_DEFAULT_WKC_HASHKEY
12 * accordingly (see int coap_hash_path());
14 void coap_hash_impl(const unsigned char *s, unsigned int len, coap_key_t h)
20 j = sizeof(coap_key_t) - 1;
24 h[j] = ((h[j] << 7) | (h[j - 1] >> 1)) + h[j];
28 h[0] = (h[0] << 7) + h[0] + *s++;