Encodera

Thanks for reading!

Donate to the site — we work hard for you.

PHP reference

crc32

Calculates the CRC32 checksum of a string.

Syntax

crc32(string $string): int

Parameters

ParameterTypeDescription
$stringstringThe input string.

Return value

intAn integer checksum.

Examples

The number and its hexadecimal form:

<?php
 
echo crc32('hello'), "\n";
echo hash('crc32b', 'hello');

Output:

907060870
3610a686

Notes

The checksum is fast but short: different strings collide often, and it is not suitable for protecting data. On 32-bit systems the result may be negative — the hash('crc32b', …) form does not depend on that.

See also

  • md5 — Returns the MD5 hash of a string.
  • hash — Returns the hash of a string using a chosen algorithm.
  • sha1 — Calculates the SHA-1 hash of a string.

In the tutorial

  • Strings — Working with strings in PHP — quotes, concatenation, length, searching, replacing and multibyte functions.

Thanks for reading!

Donate to the site — we work hard for you.