(I know this is programming related, but it's more of a concept then a direct programming question, so it didn't seem to fit anywhere else nicely....)


I'd like to create a couple of my own custom hashes, basically just for the sheer fun/learning proccess of it....

I don't need anything fancy like MD5, just a simple function that will take a string of characters and spit out a value between 0 and 255 (it needs to be only 1 byte big)....

what's the proccess that I'd have to go through for this? basically all I'm doing is creating a value, in the end, from which the input string is uncalcuable, right? would something simple like below suffice?

Code:
unsigned char hash1(char pwd[])
{
   int idx,total=0;
   for (idx=0; idx < strlen(pwd); idx++)
         total += pwd[idx] + (42 - idx);
   return(total % 256);
}
but with that you can kinda make loose guesses as to what the input string was because each character's value directly influences the resulting value.... so would something like below be a bit more, er, "random"?
Code:
unsigned char hash2(char pwd[])
{
   unsigned int idx,total=1;
   for (idx=0; idx < strlen(pwd); idx++)
      total += (pwd[idx] >> (idx+1)) * (pwd[idx] << (idx+1));
   for (idx=0; idx < strlen(pwd); idx++)
      total *= pwd[idx] % (pwd[idx] >> (idx+1));
   return(total % 256);
}
am I running down the right road here, or just a complete, hopeless moron?

any input or tutorials are the subject would be appreciated.....