Welcome Guest, Not a member yet? Register   Sign In
hash_hmac() undefined function error on new install
#1

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
Reply
#2

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
Reply
#3

(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
Reply
#4

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.
Reply
#5

(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
Reply
#6

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.
Reply
#7

(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
Reply
#8

(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.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB