>The code is something like: > >if (ord($a[0]) & 0x80) $a = "\x00" . $a; > >in a perl-like language. Don't bother converting to hex. The shared secret is the result of gmp_powm() which returns a resource. How do you go from resource->binary MAC without converting to a numeric string somewhere along the line?