PHP How to create real hex values from a string

Posted by Piet on Stack Overflow See other posts from Stack Overflow or by Piet
Published on 2010-03-31T12:43:03Z Indexed on 2010/04/17 7:33 UTC
Read the original article Hit count: 387

Filed under:
|
|
|

Hi,

I have a string with hexvalues that I use with sha1()

echo sha1("\x23\x9A\xB9\xCB\x28\x2D\xAF\x66\x23\x1D\xC5\xA4\xDF\x6B\xFB\xAE\x00\x00\x00\x01");

ab94fcedf2664edfb9b291f85d7f77f27f2f4a9d

now I have another string with the same value only not hex.

$string2=strtoupper("239ab9cb282daf66231dc5a4df6bfbae00000001");

I want to convert this string so that it is read as above and that the sha1-value is the same as above.

echo sha1(do_something($string2));

ab94fcedf2664edfb9b291f85d7f77f27f2f4a9d

Does anybody know how to convert a string to real hexvalues?

I've tried with pack, sprinft, hexdec, but nothing worked (couldn't find typecasting in hex)

Thanks

© Stack Overflow or respective owner

Related posts about php5

Related posts about hexadecimal