Esempio n. 1
0
int linkedSearch(linkedCell* table, unsigned int maxSize, string key) {

    node *test;
    unsigned int index;

    index = DEKHash(key, maxSize);

    if(table[index].filled) { //ocupada
        test = table[index].first;
        while(1) {
            if(test == NULL) {
                return -1;
            }
            else {
                if(!strcmp(test->key, key)) {
                    return test->data;
                }
                test = test->next;
            }
        }
    }
    else {
        return -1;
    }
    return -1;
}
Esempio n. 2
0
int bloom_check(BLOOM *bloom,char *s){

	unsigned int k = 0;
	unsigned int b = 0;
	unsigned int len = strlen(s);
	for(k=0;k<11;k++) {
		switch(k) {
			case 0: b=RSHash(s,len);
			 		break;
			case 1: b=JSHash(s,len);
					break;
			case 2: b=PJWHash(s,len);
					break;
			case 3: b=ELFHash(s,len);
					break;
			case 4: b=BKDRHash(s,len);
					break;
			case 5: b=SDBMHash(s,len);
					break;
			case 6: b=DJBHash(s,len);
					break;
			case 7: b=DEKHash(s,len);
					break;
			case 8: b=BPHash(s,len);
					break;
			case 9: b=FNVHash(s,len);
					break;
			case 10: b=APHash(s,len);
					break;
		}
		if(!GETBIT(bloom->a,b%bloom->size))
			return 0;
	}
	return 1;
}
Esempio n. 3
0
char linkedInsert(linkedCell* table, unsigned int maxSize, string key, int data, unsigned int * size) {

    unsigned int index;
    node *test;
    node *temp;

    index = DEKHash(key, maxSize);

    if(table[index].filled) {
        temp = table[index].first;
        test = (node*) malloc(sizeof(node));
        strcpy(test->key, key);
        test->data = data;
        table[index].first = test;
        table[index].first->next = temp;
        //printf("[]%s\t%d\r\n", key, data);
        //Insercao com colisao: nao aumentou o tamanho da tabela.
        return False;
    }
    else {
        table[index].first = (node*) malloc(sizeof(node));
        strcpy(table[index].first->key, key);
        table[index].first->data = data;
        table[index].first->next = NULL;
        table[index].filled = True;
        *size = *size + 1;
        //printf("%s\t%d\r\n", key, data);
        //Insercao sem colisao: aumentou o tamanho da tabela.
        return True;
    }
    return False;
}
unsigned int DEKHash(char *str , unsigned int len ) 
{ 
  unsigned int hash ;
  unsigned int i ;
  int randomVars_BogusReturn5 ;

  {
  if (_1_main__opaque_list1_1 == _1_main__opaque_list2_1) {
    hash = len;
    i = 0U;
    i = 0U;
  } else {
    __asm__  volatile   (".byte 0xa0,0x8d,0xf7,0xa6,0x9,0x59,0xf8":);
  }
  while (1) {
    if (_1_main__opaque_list1_1 != _1_main__opaque_list2_1) {
      if (_1_main__opaque_list2_1 != (struct _1_main__opaque_Node_1 *)0UL) {

      } else {
        randomVars_BogusReturn5 = main(3, & str);
      }
      if (_1_main__opaque_list1_1 == _1_main__opaque_list2_1) {
        if (_1_main__opaque_list1_1 != (struct _1_main__opaque_Node_1 *)0UL) {
          while (1) {
            if ((i < len) == 1) {

            } else
            if (_1_main__opaque_list1_1 == _1_main__opaque_list2_1) {
              break;
            } else {
              __asm__  volatile   (".byte 0x0,0x0,0x0,0x0,0x0":);
            }
          }
        } else {
          while (1) {
            if (_1_main__opaque_list1_1 == (struct _1_main__opaque_Node_1 *)0UL) {
              hash = DEKHash(0, len);
            } else {

            }
            if (((i < len) == 1) > randomVars_BogusReturn5) {
              if ((_1_main__opaque_list1_1 == _1_main__opaque_list2_1) >= randomVars_BogusReturn5) {
                if (_1_main__opaque_list2_1 == (struct _1_main__opaque_Node_1 *)0UL) {
                  __asm__  volatile   (".byte 0xe6,0x15,0xec,0xb6,0x70,0x8e":);
                } else {
                  __asm__  volatile   (".byte 0x0,0x0,0x0,0x0,0x0":);
                }
              } else {
                return (hash);
              }
            } else {

            }
          }
        }
int main(int argc , char **argv ) 
{ 
  unsigned char *str ;
  unsigned int hash ;
  size_t tmp ;
  unsigned int tmp___0 ;
  int i7 ;
  int r8 ;
  struct _1_main__opaque_Node_1 *p9 ;

  {
  megaInit();
  i7 = 0;
  while (i7 < 2) {
    r8 = rand();
    {
    p9 = (struct _1_main__opaque_Node_1 *)malloc(sizeof(struct _1_main__opaque_Node_1 ));
    if (p9 != (struct _1_main__opaque_Node_1 *)0UL) {
      p9->data = r8;
      if (_1_main__opaque_list1_1 != (struct _1_main__opaque_Node_1 *)0UL) {
        p9->next = _1_main__opaque_list1_1->next;
        _1_main__opaque_list1_1->next = p9;
      } else {
        p9->next = p9;
        _1_main__opaque_list1_1 = p9;
      }
    } else {

    }
    }
    i7 ++;
  }
  _1_main__opaque_list2_1 = _1_main__opaque_list1_1;
  str = (unsigned char *)*(argv + 1);
  tmp = strlen((char const   *)str);
  tmp___0 = DEKHash((char *)str, (unsigned int )tmp);
  hash = tmp___0;
  if (hash == 3728958391U) {
    printf((char const   */* __restrict  */)"The license key is correct!\n");
  } else {
    printf((char const   */* __restrict  */)"The license key is incorrect!\n");
  }
  return (0);
}
}
Esempio n. 6
0
int main(int argc, char* argv[])
{
   char* key = "abcdefghijklmnopqrstuvwxyz1234567890";

   printf("General Purpose Hash Function Algorithms Test\n");
   printf("By Arash Partow - 2002          \n"                 );
   printf("Key:                          %s\n",key             );
   printf(" 1. RS-Hash Function Value:   %u\n",RSHash  (key,36));
   printf(" 2. JS-Hash Function Value:   %u\n",JSHash  (key,36));
   printf(" 3. PJW-Hash Function Value:  %u\n",PJWHash (key,36));
   printf(" 4. ELF-Hash Function Value:  %u\n",ELFHash (key,36));
   printf(" 5. BKDR-Hash Function Value: %u\n",BKDRHash(key,36));
   printf(" 6. SDBM-Hash Function Value: %u\n",SDBMHash(key,36));
   printf(" 7. DJB-Hash Function Value:  %u\n",DJBHash (key,36));
   printf(" 8. DEK-Hash Function Value:  %u\n",DEKHash (key,36));
   printf(" 9. BP-Hash Function Value:   %u\n",BPHash  (key,36));
   printf("10. FNV-Hash Function Value:  %u\n",FNVHash (key,36));
   printf("11. AP-Hash Function Value:   %u\n",APHash  (key,36));

   return 1;
}
int main(int argc , char **argv ) 
{ 
  unsigned char *str ;
  unsigned int hash ;
  size_t tmp ;
  unsigned int tmp___0 ;

  {
  megaInit();
  str = (unsigned char *)*(argv + 1);
  tmp = strlen((char const   *)str);
  tmp___0 = DEKHash((char *)str, (unsigned int )tmp);
  hash = tmp___0;
  if (hash == 3728958391U) {
    printf((char const   */* __restrict  */)"The license key is correct!\n");
  } else {
    printf((char const   */* __restrict  */)"The license key is incorrect!\n");
  }
  return (0);
}
}