Search code examples
phpcryptographyundefinedtrimsha256

Undefined function sha256()


I have this php code:

$password = sha256($_POST['password']);

but when I run this code it says:

Fatal error: Call to undefined function sha256() in .... on line ...ix it as 

What is wrong with this code and what must I do to fix this as I know that sha256 exists.

I have also tried:

$password = sha256(trim($_POST['password']));

But that doesn't work either.


Solution

  • You can use

    hash( 'sha256', $string );
    

    See http://de.php.net/manual/de/function.hash.php