Well, really depends on what parameters you want to set for forming this hex code. There are many ways you could accomplish this.
To give a simple take on it, I've made the following:
$str_u = unpack("C*", "Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
$byte_output = [0x00, 0x00, 0x00];
$c = 0;
foreach($str_u as $b)
{
$byte_output[$c % count($byte_output)] ^= $b;
$c++;
}
var_dump($byte_output);
Basically going through every byte in the string and performing a XOR to each value in the $byte_output array, but each byte in the string only interacts with one byte in the output.
This will you give consistently the same results for different strings. It is just a simple parameter to take into account every character in the string and crunch it into a given number of bytes. That said, you could use just about any parameter you want, as long as you don't involve random functions in it.