Solved

Can crc32() ever return a 5 digit number?

Posted on 2008-06-19
3
369 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 300 total points
Comment Utility
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 200 total points
Comment Utility

<?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
Comment Utility
Note that a CRC32 value is usually shown in hexadecimal.

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

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

#SSL #TLS #Citrix #HTTPS #PKI #Compliance #Certificate #Encryption #StoreFront #Web Interface #Citrix XenApp
SSL stands for “Secure Sockets Layer” and an SSL certificate is a critical component to keeping your website safe, secured, and compliant. Any ecommerce website must have an SSL certificate to ensure the safe handling of sensitive information like…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

772 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now