PHP CRC32 computes a 32-bit CRC of a string (cyclic redundancy check)

Source: Internet
Author: User
Tags crc32 crc32 checksum
Note: This article reprinted http://www.manongjc.com/article/499.html

The PHP crc32 function is used to generate a string of 32-bit cyclic redundancy check code polynomial. This is typically used to check the integrity of the data being transmitted. This article introduces you to the basic syntax of PHP CRC32 functions and the use of examples. Need to the code farmers can refer to.

CRC32 function computes a crc32 polynomial of a string

Basic syntax for CRC32 functions

CRC32 string $str )

Generates a 32-bit cyclic redundancy check code polynomial for str. This is typically used to check the integrity of the data being transmitted.

Tip: To ensure that the correct string representation is obtained from the CRC32 () function, you need to use the%u format of the printf () or sprintf () function. If you do not use the%u format, the results may appear as incorrect numbers or negative values.

CRC32 parameter Introduction

Parameters Description
String Necessary. The data to validate.

CRC32 return value

Returns the integer of the str crc32 checksum.

CRC32 Function Example:

The second line in the example shows how to use the printf () function to convert a checksum:

 
  $checksum  =  crc32 ("The quick brown fox jumped over the the lazy Dog.")  printf ("%u\n",  $checksum  );

Run online

Operation Result:

2191738434

The above describes the PHP Crc32 computing string 32-bit CRC (cyclic redundancy check), including the aspects of the content, I hope to be interested in PHP tutorial friends helpful.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.