string hash_file ( string $algo , string $filename [, bool $raw_output = FALSE ] )

参数

algo

要使用的哈希算法的名称,例如:"md5","sha256","haval160,4" 等。

filename

要进行哈希运算的文件路径。支持 fopen 封装器。

raw_output

设置为 TRUE,输出格式为原始的二进制数据。 设置为 FALSE,输出小写的 16 进制字符串。

返回值

如果 raw_output 设置为 TRUE, 则返回原始二进制数据表示的信息摘要, 否则返回 16 进制小写字符串格式表示的信息摘要。

范例

Example #1 使用 hash_file()

<?php
/* 创建一个要计算哈希值的文件 */
file_put_contents('example.txt', 'The quick brown fox jumped over the lazy dog.'); echo hash_file('md5', 'example.txt');
?>

windows 生成文件哈希值命令 certutil -hashfile 12.945 SHA256(md5)

用于文件验证文件完整性,防止文件被篡改

php hash_file的更多相关文章

  1. PHP 做文件校验,MD5,CRC32,SHA等

    函数 hash_file(): 使用给定文件的内容生成哈希值 说明 string hash_file ( string $algo , string $filename [, bool $raw_ou ...

  2. PHP7函数大全(4553个函数)

    转载来自: http://www.infocool.net/kb/PHP/201607/168683.html a 函数 说明 abs 绝对值 acos 反余弦 acosh 反双曲余弦 addcsla ...

  3. install phpexcel using composer in thinkPHP

    Environment Window 10.1 XAMPP 7.0.9 (PHP 7.0.9) thinkPHP 5.0.1 Steps # visit https://getcomposer.org ...

  4. composer 使用详解

    1,安装 php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" php -r &quo ...

  5. php常用代码

    $total_count = mysql_num_rows($rslt);//返回记录条数 date("ymdHis");//130618104741 注:年份没有前两位 PHP手 ...

  6. Laravel 安装predis 扩展

    在安装predis扩展之前先安装composer,安装教程在https://getcomposer.org/download/: php -r "copy('https://getcompo ...

  7. Drupal如何更新注册表?

    Drupal的注册表是指registry和registry_file两个数据表.前一个表保存所有可用的类和接口以及它们所对应的文件,后一个表保存每个文件的hash码. 1. 将所有需要更新的文件都汇总 ...

  8. php5函数库

    * APC缓存 apc_add — 缓存一个变量到数据存储 * DateTime DateTime::addDateTime::diffDateTime::formatDateTime::modify ...

  9. SaltStack管理从这里开始

    Modules 1:查看所有module列表: salt 'jcfx-4' sys.list_modules jcfx-4: - acl - aliases - alternatives - apac ...

随机推荐

  1. MongoDB基本语法

    建立连接 client = pymongo.MongoClient() 新建数据库 db = client["db_name"] 新建表 tble=db["table_n ...

  2. 二十三、Interpreter 解释器模式

    设计: 代码清单: Node public abstract class Node { public abstract void parse(Context context) throws Parse ...

  3. 985. Sum of Even Numbers After Queries

    We have an array A of integers, and an array queries of queries. For the i-th query val = queries[i] ...

  4. composer的安装以及具体使用

    1. 简介 Composer 是 PHP5.3以上 的一个依赖管理工具.它允许你声明项目所依赖的代码库,它会在你的项目中为你安装他们.Composer 不是一个包管理器.是的,它涉及 "pa ...

  5. 18. 4Sum (JAVA)

    Given an array nums of n integers and an integer target, are there elements a, b, c, and d in nums s ...

  6. 独立安装CentOS7.4全记录

    大学用了四年的笔记本快用废了,闲来想着用来装个centos,当个服务器也行,于是装上了CentOS6.9系统,由于最小化安装,而且在安装时没有安装wpa_supplicant包,笔记本本身网卡接口又坏 ...

  7. byte -> int

    传送门 传送门2 以下copy: int i = 0;   i += ((b[0] & 0xff) << 24);   i += ((b[1] & 0xff) <&l ...

  8. CentOS7+CDH5.14.0安装全流程记录,图文详解全程实测-总目录

    CentOS7+CDH5.14.0安装全流程记录,图文详解全程实测-总目录: 0.Windows 10本机下载Xshell,以方便往Linux主机上上传大文件 1.CentOS7+CDH5.14.0安 ...

  9. Day3 -4.9!受到毕设的突然袭击,一脸蒙蔽,学习暂时停止,明晚继续

    PS:啊啊啊啊,慌张的不行,不详的预感终于爆发了,第二次毕设评图好突然,没办法了,竹径和学习突然搁置,明晚健身/建模/补更Day3,感到崩溃 ————————————————————————————— ...

  10. spring Mongodb查询索引报错 java.lang.NumberFormatException: empty String

    最近事情比较多,本篇文章算是把遇到的问题杂糅到一起了. 背景:笔者最近在写一个mongo查询小程序,由于建立索引时字段名用大写,而查询的时候用小写. 代码如下: db.getCollection(&q ...