Ejemplo n.º 1
0
Archivo: st.c Proyecto: sho-h/ruby
static inline st_index_t
find_packed_index_from(st_table *table, st_index_t hash_val, st_data_t key, st_index_t i)
{
    while (i < table->real_entries &&
	   (PHASH(table, i) != hash_val || !EQUAL(table, key, PKEY(table, i)))) {
	i++;
    }
    return i;
}
Ejemplo n.º 2
0
int main () {
  PHASH ("SHA1", "AHOJ");
  PHASH ("SHA1a", "AHOJ");  /* Unknown algorithm -> empty string */
  PHASH ("SHA256", "AHOJ");
  PHASH ("SHA512", "AHOJ");
  PHASH ("RIPEMD160", "AHOJ");
  PHASH ("MD5", "AHOJ");

  PHMAC ("SHA1", "AHOJ", "SECRET");
  PHMAC ("SHA1a", "AHOJ", "SECRET");  // Unknown algorithm -> empty string
  PHMAC ("SHA256", "AHOJ", "SECRET");
  PHMAC ("SHA512", "AHOJ", "SECRET");
  PHMAC ("RIPEMD160", "AHOJ", "SECRET");
  PHMAC ("MD5", "AHOJ", "SECRET");

  return 0;
}
Ejemplo n.º 3
0
//This function is not fast.  It should be used to generate an initial hashcode for a new position.  If modifying an existing position, the board's hashcode should be modified on the fly.
u64 hashPosition(Position *pos) {
	u64 hash = 0ull;
	int sq;
	for (sq = 0; sq < 64; sq++) {
		if (pos->squares[sq] != EMPTY) {
			hash ^= PHASH(pos->squares[sq], sq);
		}
	}
	//en passant
	hash ^= EPHASH(pos);
	//castling
	int castle;
	for (castle = 8; castle; castle >>= 1) {
		if (castle & pos->castle) {
			hash ^= CASTLEHASH(castle);
		}
	}
	//ply
	if (pos->ply%2 == 0) {
		hash ^= WHITETURNHASH;
	}
	return hash;
}
Ejemplo n.º 4
0
void outlist(char *code0, char *key)
{
  ub4 hash;
  hash = PHASH(key, strlen(key));  
  printf("/* %4d */ 0x%s%04X, /* %-25s */\n", hash, code0, shash(key), key);
}