首先我们要加密的明文是:
1 2 3 | $ test =<<< 'EVE' echo '<script>alert("nihao")</script>' ;die; EVE; |
字符串转16进制,16进制还原的方法
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | function String2Hex( $string ){ $hex = '' ; for ( $i =0; $i < strlen ( $string ); $i ++){ $hex .= dechex (ord( $string [ $i ])); } return $hex ; } function Hex2String( $hex ){ $string = '' ; for ( $i =0; $i < strlen ( $hex )-1; $i +=2){ $string .= chr (hexdec( $hex [ $i ]. $hex [ $i +1])); } return $string ; } |
加密:
$test1= gzdeflate($test); #压缩
$test1=base64_encode($test1); #转码
$adam=String2Hex(str_rot13($test1)); #rot13+16进制转换
加密后的字符串:
1 | 463033426c537144676c794259666266585953596d527867586753446c66695a465a6b4b30654745756a64654a367178637962514e4e3d3d |
解密:
1 2 | $ev = str_rot13 (pack( "H*" , $adam )); $decoded =gzinflate( base64_decode ( $ev )); |
本文为Adamin90原创文章,转载无需和我联系,但请注明来自http://www.lixiaopeng.top