CRC32(expr) computes a cyclic redundancy check and returns a 32-bit unsigned value. The result is NULL when the argument is NULL.
SELECT CRC32('string');
SELECT CRC32('plus2net'); -- Output: 930124482
SELECT CRC32(NULL); -- Output: NULL
If you store CRC32 output in MySQL, use an unsigned integer type capable of holding the full 32-bit unsigned range.
PHP also provides crc32(). The following example calculates the checksum of the same string.
<?php
echo crc32('plus2net');
?>
On common 64-bit PHP builds the output for this example is 930124482.
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.