bits codeword(char *attr_value, int m, int k)
{
int nbits = 0; // count of set bits
bits cword = 0; // assuming m <= 32 bits
srandom(hash(attr_value));
while (nbits < k) {
int i = random() % m;
if (((1 << i) & cword) == 0) {
cword |= (1 << i);
nbits++;
}
}
return cword; // m-bits with k 1-bits and m-k 0-bits
}