#include <stdio.h> #include <string.h> #include <math.h> unsigned create_sign32_const(const char* str_src) { unsigned times, i; unsigned sign, tint; times = strlen(str_src)/4; sign=0; for (i=0; i<times; i++){ sign += *( (unsigned int *) (str_src + i*4) ); } times = times%32; sign = (sign<<times)|(sign>>(32-times)); tint=0; strcpy( (char*)(&tint), str_src+i*4); sign += tint; return sign; } int main(int argc, char** argv) { if (argc != 2) { printf("usage: str2id string\n"); return 0; } char *str = argv[1]; unsigned id = create_sign32_const(str); printf("%u\n", (unsigned)fmod(id,64)); return 0; }