我需要使用PHP获取文件的CRC64校验和.
有了这段代码
file_put_contents('example.txt', 'just an example');
echo hash_file('crc32', 'example.txt');
Run Code Online (Sandbox Code Playgroud)
我得到CRC32校验和"c8c429fe";
但我需要使用CRC64算法得到校验和(
)
我从这里拿到了它:http://en.wikipedia.org/wiki/Cyclic_redundancy_check
如何在PHP中实现此散列算法?
hash_file 只是一个包装器,它将 file_get_contents($file) 的结果传递给包装器,因此您可以使用任何函数来代替“crc32”。
必须使用crc64吗?如果您只想对文件进行哈希处理,则可以使用 md5 和 sha,它们的使用方式就像
$hash = hash_file("sha1", $file);
Run Code Online (Sandbox Code Playgroud)
否则,只需制作自己的 CRC64 实现并
function crc64($string){
// your code here
}
$hash = hash_file("crc64", $file);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5131 次 |
| 最近记录: |