cdw1p

[PHP] Hex Encode String

Apr 21st, 2019
338
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.21 KB | None | 0 0
  1. <?php
  2.     function strToHex($string)
  3.     {
  4.         $text = bin2hex($string);
  5.         $text = chunk_split($text,2,"\x");
  6.         $text = "\x" . substr($text,0,-2);
  7.         return $text;
  8.     }
  9.    
  10. $encode = "{text}";
  11.  
  12. echo strToHex($encode);
  13. ?>
Advertisement
Add Comment
Please, Sign In to add comment