Php crc32 calculates the 32-bit CRC (cyclic redundancy check) and crc32crc of the string.

Source: Internet
Author: User
Tags crc32

Php crc32 calculates the 32-bit CRC (cyclic redundancy check) and crc32crc of the string.

Note: This article reprinted http://www.manongjc.com/article/499.html

 

The php crc32 function is used to generate a 32-bit Cyclic Redundancy checkcode polynomial of a string. This is usually used to check whether the transmitted data is complete. This article introduces the basic syntax and examples of php crc32 functions. For more information about the coders, see.

Crc32 function compute the crc32 polynomial of a string

 

Basic crc32 function syntax

int crc32 ( string $str )

Generate the 32-bit Cyclic Redundancy checksum polynomial of str. This is usually used to check whether the transmitted data is complete.

Tip:To ensure that the correct string representation is obtained from the crc32 () function, you need to use the % u format character of the printf () or sprintf () function. If % u is not used, the result may be displayed as an incorrect number or a negative number.

 

Crc32 Parameters

Parameters Description
String Required. The data to be verified.

 

Crc32 Return Value

Returns the str crc32 verification integer.

 

Crc32 function instance:

The second line in the example demonstrates how to use the printf () function to convert the verification code:

<?php $checksum  =  crc32 ( "The quick brown fox jumped over the lazy dog." ); printf ( "%u\n" ,  $checksum );?> 

Online operation

Running result:

2191738434

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.