PHP-AES-File-Encryption icon indicating copy to clipboard operation
PHP-AES-File-Encryption copied to clipboard

hex2bin unknown method

Open havet opened this issue 9 years ago • 2 comments

Hi, I cannot run 'example_usage.php' Fatal error: Call to undefined method AESCryptFileLib::hex2bin() in .... /AESCryptFileLib.php on line 573

I'm running PHP v. 5.6.7

havet avatar Jan 31 '16 18:01 havet

Use this changes: https://github.com/philios33/PHP-AES-File-Encryption/pull/2

jonathangoncalves avatar Apr 18 '16 13:04 jonathangoncalves

Hi,

I modified the function as follows: // hex2bin wasn't introduced until PHP 5.4.0. If not present, use an alternative // written by chaos79: http://php.net/manual/fr/function.bin2hex.php#86123 public static function hex2bin($string) { if (function_exists('hex2bin')) { return hex2bin($string); } else { $sbin = ""; $len = strlen( $string ); for ( $i = 0; $i < $len; $i += 2 ) { $sbin .= chr( hexdec( $string{$i}.$string{( $i+1 )} ) ); } return $sbin; } }

Now it's work fine.

nbatteur avatar Jun 22 '16 09:06 nbatteur