#include #include #include #include void replaceHTML(char* str){ printf("Replaceing:%s\n",str); char* nstr = malloc((sizeof(char)*strlen(str)) + 1); if(nstr == NULL){ printf("Failed to allocate memory!\n"); } int strp = 0; int nstrp = 0; while(str[strp] != '\0'){ printf("Strp=%d nstrp=%d\n",strp,nstrp); if(str[strp] == '+'){ nstr[nstrp] = ' '; strp++; nstrp++; }else if(str[strp] == '%'){ printf("Hit encodeing!\n"); int hex; sscanf(str+strp,"%%%x",&hex); printf("Was:%c\n",(char)hex); nstr[nstrp] = (char)hex; nstrp++; strp+=3; }else{ nstr[nstrp] = str[strp]; nstrp++; strp++; } } nstr[nstrp] = '\0'; printf("Done, str is now:%s\n",nstr); } char* useridhash(char* str){ char* hash = malloc(sizeof(char)*20); int i = (int)str[0]; int len = strlen(str); int tloop = i*20; unsigned int hashp = 0; unsigned int strp = 0; i = 0; while(i < tloop){ //printf("i:%d hashp:%u strp:%u tloop:%d\n",i,hashp,strp,tloop); char tchar = str[strp%len]; hash[hashp%20] += str[strp%len]; hashp+=(int)tchar; strp+=(int)(hashp*hashp); i++; } i = 0; //printf("Before characterizeing the hash, it was: %s\n",hash); while(i < 20){ //printf("Normalizeing %c(%u) as %c(%u)\n",hash[i],(unsigned int)hash[i],(hash[i] % 92) + 32,(hash[i] % 92) + 32); unsigned int hashnum = hash[i]; unsigned int modedhashnum = hashnum % 92; //printf("hashnum was %u, after mod it is:%u\n",hashnum,modedhashnum); hash[i] = modedhashnum + 32; i++; } //printf("Resulting hash was:%s\n",hash); return hash; } int main(){ char teststring[] = "This+is+a+test"; useridhash(teststring); char teststring2[] = "This+is+a+tost"; useridhash(teststring2); return 0; }