php 未定义的函数 sha256()
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8533530/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Undefined function sha256()
提问by H Bellamy
I have this php code:
我有这个 php 代码:
$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.
这段代码有什么问题,我必须做些什么来解决这个问题,因为我知道它sha256
存在。
I have also tried:
我也试过:
$password = sha256(trim($_POST['password']));
But that doesn't work either.
但这也行不通。
回答by DarkDevine
回答by Goran Miskovic
回答by Wieszos
There is no such function in php standard library. Use hash
function instead.
http://php.net/manual/en/function.hash.phplike :
php标准库中没有这样的功能。改用hash
函数。
http://php.net/manual/en/function.hash.php像:
$pass = hash('sha256', $_POST['password']);
回答by Berry Langerak
ehrm. That function doesn't exist. If you want to use the SHA256 algorithm, use hashinstead.