Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Errors in generating hash

Reply
Thread Tools

Errors in generating hash

 
 
tdopsdarock tdopsdarock is offline
Junior Member
Join Date: Mar 2008
Posts: 1
 
      03-03-2008
Hello all,

I am newbie to C but i am trying to edit an existing code that generates hash values. this works quite well but after 20 values the hash values are repeated and no longer unique. What can i do to make sure that the hash values are unique for at least 1000 values? Please find below the code..

Quote:
static
void hash_function(url_t *url, unsigned char *buf, void *user_data)
{
unsigned char ans;
const char *ptr;

for (ans = 0, ptr = url->url_host; *ptr != '\0'; ptr++)
ans += *ptr;
if (url->url_user)
for (ptr = url->url_user; *ptr != '\0'; ptr++)
ans += *ptr;
if (url->url_port)
for (ptr = url->url_port; *ptr != '\0'; ptr++)
ans += *ptr;

buf[0] = ans;
}

thanks for your help
 

Last edited by tdopsdarock; 03-03-2008 at 01:34 AM..
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
hash of hash of hash of hash in c++ rp C++ 1 11-10-2011 04:45 PM
how to sort a hash list without generating a new object? smith jack Python 0 08-02-2011 06:02 PM
Hash#select returns an array but Hash#reject returns a hash... Srijayanth Sridhar Ruby 19 07-02-2008 12:49 PM
Errors, errors, errors Mark Goldin ASP .Net 2 01-17-2004 08:05 PM
Generating hash value Eliyahu Goldin ASP .Net Security 3 12-29-2003 02:10 PM



Advertisments