server/tools/gethash.c

25 lines
546 B
C
Raw Normal View History

2010-08-08 10:06:34 +02:00
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
2011-03-07 08:02:35 +01:00
int main(int argc, char **argv)
2010-08-08 10:06:34 +02:00
{
char key[4];
char code[4];
char result[4];
int a, i, rot;
2011-03-07 08:02:35 +01:00
for (a = 1; a < argc; ++a) {
const char *str = argv[a];
2010-08-08 10:06:34 +02:00
size_t len = strlen(str);
2011-03-07 08:02:35 +01:00
str = str + len - 6;
2010-08-08 10:06:34 +02:00
memcpy(key, str, 3);
2011-03-07 08:02:35 +01:00
memcpy(code, str + 3, 3);
2010-08-08 10:06:34 +02:00
result[3] = key[3] = code[3] = 0;
2011-03-07 08:02:35 +01:00
rot = atoi(key);
for (i = 0; i != 3; ++i)
result[(i + rot) % 3] = ((code[i] + 10 - key[i]) % 10) + '0';
2010-08-08 10:06:34 +02:00
printf("%s %s\n", argv[a], result);
}
return 0;
}