<?php $text = "php rocks!"; $encoded = preg_replace( "'(.)'e" ,"dechex(ord('\\1'))" ,$text ); echo "ENCODED: $encoded\n"; //ENCODED: 50485020726f636b7321 echo "DECODED: ".preg_replace( "'([\S,\d]{2})'e" ,"chr(hexdec('\\1'))" ,$encoded)."\n"; //DECODED: php rocks! ?>
Tuesday, January 4, 2011
PHP encode and decode hex
Category:
PHP,
SQL Injection,
XSS
— SkyHi @ Tuesday, January 04, 2011