File: httphash.c

package info (click to toggle)
libgadu 1:1.9.0-2+squeeze2
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 2,828 kB
  • ctags: 735
  • sloc: ansic: 10,507; sh: 10,195; perl: 320; makefile: 161
file content (71 lines) | stat: -rw-r--r-- 1,429 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "libgadu.h"

int main(int argc, char **argv)
{
	char buf[100];
	int i;

	if (argc > 2 && !strcmp(argv[1], "-b")) {
		int count = argc - 3;
		uint32_t val = atoi(argv[2]);

		for (i = 0; i < (1 << count); i++) {
			char *args[7] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL };
			uint32_t res;
			int c = 0, j;

			if (i & 1)
				args[c++] = argv[3];
			if (i & 2)
				args[c++] = argv[4];
			if (i & 4)
				args[c++] = argv[5];
			if (i & 8)
				args[c++] = argv[6];
			if (i & 16)
				args[c++] = argv[7];
			if (i & 32)
				args[c++] = argv[8];
			if (i & 64)
				args[c++] = argv[9];
			if (i & 128)
				args[c++] = argv[10];
				
			strcpy(buf, "");
		
			for (j = 0; j < c; j++)
				strcat(buf, "s");

			res = gg_http_hash(buf, args[0], args[1], args[2], args[3], args[4], args[5], args[6], NULL);

			printf("%s %s %s %s %s %s %s %s", buf, args[0], args[1], args[2], args[3], args[4], args[5], args[6]);

			if (res == val)
				printf(" MATCH!\n");
			else
				printf("\n");
		}

		return 0;
	}

	if (argc < 2 || argc > 10) {
		fprintf(stderr, "u┼╝ycie: %s <kolejne> [wyrazy] [do] [hasha]\n", argv[0]);
		return 1;
	}

	strcpy(buf, "");
	
	for (i = 1; i < argc; i++)
		strcat(buf, "s");

	printf("%s\n", buf);
	
	printf("%u\n", gg_http_hash(buf, argv[1], argv[2], argv[3], argv[4], argv[5], argv[6], argv[7], argv[8], argv[9], argv[10]));

	return 0;
}