Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hex2bin unknown method #3

Open
havet opened this issue Jan 31, 2016 · 2 comments
Open

hex2bin unknown method #3

havet opened this issue Jan 31, 2016 · 2 comments

Comments

@havet
Copy link

havet commented Jan 31, 2016

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

@jonathangoncalves
Copy link

Use this changes:
#2

@nbatteur
Copy link

nbatteur commented Jun 22, 2016

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants