CodeIgniter Forums
hash_hmac() undefined function error on new install - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Installation & Setup (https://forum.codeigniter.com/forumdisplay.php?fid=9)
+--- Thread: hash_hmac() undefined function error on new install (/showthread.php?tid=1372)



hash_hmac() undefined function error on new install - SailorJohn99 - 03-04-2015

This is a completely new install, and I'm getting:

Fatal error: Call to undefined function hash_hmac() in Session.php on line 677.

I even downloaded Codeigniter and unzipped it again, just to be sure.  I got the Welcome page, and made these changes:

1.  Added a Constructor to the Welcome page, with the $this->load->library('session') included:

public function __construct()
 {
     
parent::__construct();
           
$this->load->library('session');
     
}

2.  Added an encryption key in config.php:

$config['encryption_key'] = 'asdfasfd';

That's it!  Generates the error.

mcrypt is enables per phpinfo.

No doubt I'm missing something, but I can't spot it.  

Any suggestions?

TIA

John


RE: hash_hmac() undefined function error on new install - silentium - 03-04-2015

What version of PHP are you using?

hash_hmac() is in included in the PHP core since version 5.1.2. If you have a version before that you might need to install it as a PECL Module

Source: http://us2.php.net/manual/en/hash.installation.php


RE: hash_hmac() undefined function error on new install - SailorJohn99 - 03-04-2015

(03-04-2015, 05:12 PM)silentium Wrote: What version of PHP are you using?

hash_hmac() is in included in the PHP core since version 5.1.2. If you have a version before that you might need to install it as a PECL Module

Source: http://us2.php.net/manual/en/hash.installation.php

Thanks for the reply.

I'm using PHP Version 5.3.15.  
BTW, this is Codeigniter 2.2.1


RE: hash_hmac() undefined function error on new install - Narf - 03-05-2015

I guess your PHP was compiled with the --disable-hash option, which makes it unusable in practice ... I can't imagine an application that doesn't use ext/hash.


RE: hash_hmac() undefined function error on new install - SailorJohn99 - 03-05-2015

(03-05-2015, 03:05 AM)Narf Wrote: I guess your PHP was compiled with the --disable-hash option, which makes it unusable in practice ... I can't imagine an application that doesn't use ext/hash.

I looked at it closely, and I guess you're right.  No hash.

I found a replacement here: http://php.net/manual/en/function.hash-hmac.php from about 5 years ago.

I added it as a helper, and I'm good to go!

Thanks Silentium and Narf for your help.

John


RE: hash_hmac() undefined function error on new install - Narf - 03-06-2015

Seriously, you should just recompile PHP with ext/hash enabled. Or scream at the person who didn't do it, or change the hosting provider if you're using one ...

Not having the Hash extension will get you in all kinds of trouble, and if you don't have it, chances are there will be a lot more things messed up in your setup. Don't just copy a user-space function for hash_hmac() to work around the problem, it's not worth it.


RE: hash_hmac() undefined function error on new install - abaij - 01-21-2018

(03-06-2015, 04:09 AM)Narf Wrote: Seriously, you should just recompile PHP with ext/hash enabled. Or scream at the person who didn't do it, or change the hosting provider if you're using one ...

Not having the Hash extension will get you in all kinds of trouble, and if you don't have it, chances are there will be a lot more things messed up in your setup. Don't just copy a user-space function for hash_hmac() to work around the problem, it's not worth it.

How to recompile PHP to enable ext/hash? I've googled for it but found nothing


RE: hash_hmac() undefined function error on new install - Narf - 01-21-2018

(01-21-2018, 05:44 PM)abaij Wrote:
(03-06-2015, 04:09 AM)Narf Wrote: Seriously, you should just recompile PHP with ext/hash enabled. Or scream at the person who didn't do it, or change the hosting provider if you're using one ...

Not having the Hash extension will get you in all kinds of trouble, and if you don't have it, chances are there will be a lot more things messed up in your setup. Don't just copy a user-space function for hash_hmac() to work around the problem, it's not worth it.

How to recompile PHP to enable ext/hash? I've googled for it but found nothing

It's enabled by default, just don't disable it.