I'm told that %081X in C means: "hex format 8 chars wide with 0 fill, upper case"
I need to do the same thing to a string in PHP, so far I've got:
$output = strtoupper(bin2hex($my_string));
How do I do "8 chars wide with 0 fill"?
Regards, Brent
dmorison
2:52 pm on Apr 24, 2003 (gmt 0)
Hi, bcolflesh
The following PHP code prints out the number held in $x as an 8 character zero padded hexadecimal string..
$x = 1234;
$s = sprintf("%08X",$x);
echo $s;
Is this what you're looking for?
Cheers.
bcolflesh
3:33 pm on Apr 24, 2003 (gmt 0)
Dear Dmorison, Thanks for the reply - it always returns 00000000 for me, probably because my "$x" is not a number - it is a Blowfish encrypted string, ex:
I think I know what you are trying to do... One way is to do a preg_replace on your string, converting each character to hex using a Bin2hex() call in the replacement string part of the preg_replace. Note that %081X in C means hex format 81 chars wide... Also note that you would have the same problem in C. The C code would have needed to convert the string to an integer first.