CRC32() calculates a 32-bit unsigned checksum for a string. It is useful for lightweight comparisons, not secure hashing.
Run this SELECT query directly in MySQL or phpMyAdmin. It uses fixed inputs so you can verify the result without creating a table.
SELECT CRC32('MySQL') AS checksum_value;| checksum_value |
|---|
| 3259397556 |
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.
CRC32() is not cryptographic and collisions are possible. Do not use it for passwords or security-sensitive integrity checks.
Is CRC32() suitable for storing passwords?
No. Use a dedicated password-hashing algorithm in your application.
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.