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)
$s = "239ab9cb282daf66231dc5a4df6bfbae00000001";
echo sha1(pack('H*', $s));
Output:
ab94fcedf2664edfb9b291f85d7f77f27f2f4a9d
精彩评论