Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Can crc32() ever return a 5 digit number?

Posted on 2008-06-19
3
Medium Priority
?
404 Views
Last Modified: 2008-06-19
From all my tests crc32 always generates a 9 digit number that is either positive or negative.

         <?php
         echo crc32("Hello"); //// Returns  -137262718
         ?>

But could crc32 ever return a 5 or 10 digit number, or a number that began with 0 like 007262718 ?
0
Comment
Question by:hankknight
  • 2
3 Comments
 
LVL 53

Accepted Solution

by:
Infinity08 earned 1200 total points
ID: 21822977
It can return any value that can be represented by a 32 bit value.

Which value you get depends on how you interpret the value. You interpret it as a signed integer, so the values you can get are any value between -2147483648 and 2147483647
0
 
LVL 2

Assisted Solution

by:kszurek
kszurek earned 800 total points
ID: 21822990

<?PHP
function x($a)
{
	$b = abs(crc32($a));
	$strlen = 10-strlen($b);
	$b = str_repeat(0, $strlen).$b;
	return $b;
}
echo x("Hello");
?>

Open in new window

0
 
LVL 53

Expert Comment

by:Infinity08
ID: 21823004
Note that a CRC32 value is usually shown in hexadecimal.

So, instead of -137262718 for example, you'd show :  F7D18982
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Worried about if Apple can protect your documents, photos, and everything else that gets stored in iCloud? Read on to find out what Apple really uses to make things secure.
Will you be ready when the clock on GDPR compliance runs out? Is GDPR even something you need to worry about? Find out more about the upcoming regulation changes and download our comprehensive GDPR checklist today !
The viewer will learn how to dynamically set the form action using jQuery.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Suggested Courses
Course of the Month12 days, 1 hour left to enroll

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question