Zend - The PHP Company




Algorithms

Add Code


hex2bin  

Type: code fragment
Added by: dziadek
Entered: 04/01/2001
Last modified: 01/12/2000
Rating: - (fewer than 3 votes)
Views: 6360
easy function to convert hexdata to bindata. It's very good to use decode mcrypt hexdata.


<?php
function hex2bin($source)
  {
  
$strlen strlen($source);
  for (
$i=0;$i<strlen($source);$i=$i+2)
    {
    
$bin .= chr(hexdec(substr ($source$i,2)));
    }
  return 
$bin;
  }
?>


Usage Example


$hexdata="FFF0A025ef";
$bindata = hex2bin($hexdata);


Rate This Script





Search



This Category All Categories