Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the incremental Hash function of php

2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

Most people do not understand the knowledge points of this article "how to use php's incremental Hash function", so the editor summarizes the following contents, detailed contents, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "php's incremental Hash function how to use" article.

Usage

1. Use hash_init () to get an incremental Hash operation handle and specify the encryption algorithm.

2. Use hash_update () to add strings, hash_update_file () to add file content, and hash_update_stream () to increase stream content.

3. Use hash_final () to end the handle operation for Hash calculation and return the result value. The resulting value is the result of Hash containing strings, files, and stream contents.

Example

/ / incremental HASH $fp = tmpfile (); fwrite ($fp, 'initialize a stream file'); rewind ($fp); $H1 = hash_init ('md5'); / / start incremental Hashhash_update ($H1,' test increment'); / / normal string hash_update_file ($H1,'. / create-phar.php'); / / File hash_update_stream ($H1, $fp); / / Stream $v1 = hash_final ($H1) / / end Hash returns the result echo $v1, PHP_EOL;// 373df6cc50a1d7cd53608208e91be1e7 $H2 = hash_init ('md5', HASH_HMAC,' secret'); / / incremental HASHhash_update using HMAC algorithm ($H2, 'test increment'); hash_update_file ($H2,'. / create-phar.php'); hash_update_stream ($H2, $fp); $v2 = hash_final ($H2); echo $v2, PHP_EOL / / the above is the content of the article "how to use the incremental Hash function of php". I believe everyone has some understanding. I hope the content shared by the editor will be helpful to you. If you want to learn more about the relevant knowledge, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report