I am having trouble implementing the follow scenario:
I want to take two or more sha2() derived hashes (512 bit) and bitwise OR them.
Then I want to grab arbitrary number of bits from the resulting hash and use them as needed. I moded the code to be self contained as best I can:
Example (With 8 bits)
$alpha = hash("sha512","uid1"."name1"),TRUE);
$beta = hash("sha512","uid2"."name2"),TRUE);
$deltaHash = $alpha | $beta;
$format="<td>User Hash: %512b <br> Alpha Hash: %512b <br> Beta Hash : %512b <br> Delta Hash: %512b</td>";
printf($format,$userHash,$alpha,$beta,$deltaHash);
Is what I've coded so far.
A: I can't get it to print the binary value of the hashes for diagnostic purposes but then I need some way to extract the bits. If I can get the binary output to work to give me a sequence of 0s and 1s then I can use regular substring tools to grab what I need.
In Perl it is easier to do using bit vectors, but I haven't been successful using php at all. Any ideas?