PHP SHA3 功能
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17368899/
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
PHP SHA3 functionality
提问by VetterHyman
Is there a framework or function that allows me to use SHA3-512? I don't want a extension like Strawbrary
是否有允许我使用 SHA3-512 的框架或函数?我不想要像Strawbrary这样的扩展
采纳答案by nord-stream
It's possible.
这是可能的。
Maybe too late, but I've worked on a pure-PHP
implementation here:
也许为时已晚,但我已经在这里进行了pure-PHP
实现:
- SHA3-224/256/384/512
- SHAKE128/256 (arbitrary output size)
LGPL 3+
- Works in
PHP 5.2+
(considerably slower on olderPHP
) - No extensions required.
- Moderately well tested.
- Based on the (public domain) reference implementation in
C
. - Arbitrary input size.
- SHA3-224/256/384/512
- SHAKE128/256(任意输出尺寸)
LGPL 3+
- 适用于
PHP 5.2+
(在较旧的情况下相当慢PHP
) - 不需要扩展。
- 经过中等程度的测试。
- 基于
C
. - 任意输入大小。
It is a simple and fast implementation in PHP
(which means far slower than C). Since this is purely "CPU-bound", PHP 7.0
runs 4x faster than PHP 5.6
. (55kB/s here)
它是一个简单而快速的实现PHP
(这意味着比 C 慢得多)。由于这纯粹是“受 CPU 限制”,因此PHP 7.0
运行速度比PHP 5.6
. (此处为 55kB/s)
Fine with a small input. Correctly handles a huge input, just hogs CPU
for minutes.
输入很小就可以了。正确处理大量输入,只需CPU
几分钟。
I hope it helps.
我希望它有帮助。
回答by Mohammad Istanboli
Yes sure simply you can use hash function in php
是的,您可以在 php 中使用哈希函数
<?php
echo hash('sha3-512' , 'String you want to hash');
回答by manno
For those coming to this later (after this post) PHP 7.1.0 has support for SHA3-512.
对于那些稍后(在这篇文章之后)进行讨论的人,PHP 7.1.0 支持 SHA3-512。
Per the PHP Manual (http://php.net/manual/en/function.hash-algos.php) the hash_algos()function will output your system's available hash algorithms. The following code will output your system's available hash algorithms:
根据 PHP 手册 ( http://php.net/manual/en/function.hash-algos.php) hash_algos()函数将输出系统可用的哈希算法。以下代码将输出系统可用的哈希算法:
<?php
echo "<pre>";
print_r (hash_algos());
echo "</pre>";
?>
My output looks something like this:
我的输出看起来像这样:
Array
(
[0] => md2
[1] => md4
[2] => md5
...
)
回答by Lionel Morrison
PHP 5.3.2 added SHA-256 and SHA-512 to the crypt() function. This might be somewhat similar to what your looking for
PHP 5.3.2 向 crypt() 函数添加了 SHA-256 和 SHA-512。这可能与您要查找的内容有些相似