MathGroup Archive 1999

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: looking for implementation of hash function

  • To: mathgroup at smc.vnet.net
  • Subject: [mg17635] Re: [mg17582] looking for implementation of hash function
  • From: Brian Boonstra <boonstb at cmg.FCNBD.COM>
  • Date: Fri, 21 May 1999 03:37:30 -0400
  • References: <199905170614.CAA15924@smc.vnet.net.>
  • Sender: owner-wri-mathgroup at wolfram.com

On Mon, 26 Apr 1999, jb wrote:

> hello all,
>
> does anybody know where i can find an implementation of a hash algorithm
> ? i need to "digest" or hash a long string of characters into a shorter
> string.


Here's a C function I found for hashing strings.  I think it's pretty standard:

unsigned int hash_string (hash_cache_ptr cache, const void *key)
{
  unsigned int acc	= 0;
  unsigned int i	= 0;
  const char *this_char	= (const char *)key;


  while (*this_char != NULL) {
    acc ^= *(this_char++) << i;
    i = (i + 1) % sizeof (void *);
  }

  return acc & (cache->size - 1);
}



		- Brian


  • Prev by Date: Re: MASH: Mathematica Scripting Hack
  • Next by Date: Re: Rotated Text within a Table
  • Previous by thread: Re: looking for implementation of hash function
  • Next by thread: Re: stem and leaf plots