FilterASCIIHexDecode

Class FilterASCIIHexDecode.

Defined (1)

The class is defined in the following location(s).

/vendor/setasign/fpdi/filters/FilterASCIIHexDecode.php  
  1. class FilterASCIIHexDecode 
  2. /** 
  3. * Converts an ASCII hexadecimal encoded string into it's binary representation. 
  4. * @param string $data The input string 
  5. * @return string 
  6. */ 
  7. public function decode($data) 
  8. $data = preg_replace('/[^0-9A-Fa-f]/', '', rtrim($data, '>')); 
  9. if ((strlen($data) % 2) == 1) { 
  10. $data .= '0'; 
  11.  
  12. return pack('H*', $data); 
  13.  
  14. /** 
  15. * Converts a string into ASCII hexadecimal representation. 
  16. * @param string $data The input string 
  17. * @param boolean $leaveEOD 
  18. * @return string 
  19. */ 
  20. public function encode($data, $leaveEOD = false) 
  21. return current(unpack('H*', $data)) . ($leaveEOD ? '' : '>');