version 1.1, 2000/09/22 20:19:46
|
version 1.2, 2000/10/17 22:29:21
|
Line 1
|
Line 1
|
/* $OpenLDAP$ */ |
/* $OpenLDAP: pkg/ldap/libraries/liblutil/hash.c,v 1.1 2000/09/22 20:19:46 kurt Exp $ */ |
/* This implements the Fowler / Noll / Vo (FNV-1) hash algorithm. |
/* This implements the Fowler / Noll / Vo (FNV-1) hash algorithm. |
* A summary of the algorithm can be found at: |
* A summary of the algorithm can be found at: |
* http://www.isthe.com/chongo/tech/comp/fnv/index.html |
* http://www.isthe.com/chongo/tech/comp/fnv/index.html |
*/ |
*/ |
|
|
#include "portable.h" |
#include "portable.h" |
#include <ac/string.h> |
|
|
|
/* include socket.h to get sys/types.h and/or winsock2.h */ |
|
#include <ac/socket.h> |
|
|
|
#include <lutil_hash.h> |
#include <lutil_hash.h> |
|
|
/* offset and prime for 32-bit FNV-1 */ |
/* offset and prime for 32-bit FNV-1 */ |
#define HASH_OFFSET 0x811c9dc5 |
#define HASH_OFFSET 0x811c9dc5U |
#define HASH_PRIME 16777619 |
#define HASH_PRIME 16777619 |
|
|
|
|
Line 60 lutil_HASHFinal( unsigned char *digest,
|
Line 56 lutil_HASHFinal( unsigned char *digest,
|
{ |
{ |
ber_uint_t h = ctx->hash; |
ber_uint_t h = ctx->hash; |
|
|
digest[0] = h & 0xff; |
digest[0] = h & 0xffU; |
digest[1] = (h>>8) & 0xff; |
digest[1] = (h>>8) & 0xffU; |
digest[2] = (h>>16) & 0xff; |
digest[2] = (h>>16) & 0xffU; |
digest[3] = (h>>24) & 0xff; |
digest[3] = (h>>24) & 0xffU; |
} |
} |