Solved

php decimal hash wanted: like md5() but should only return numbers

Posted on 2008-06-18
5
1,127 Views
Last Modified: 2008-06-19
Hello,

I want a PHP function to return a 10 digit hash that only contains numbers.  I cannot use MD5 because it returns the letters a through d as well as numbers.
0
Comment
Question by:hankknight
  • 2
  • 2
5 Comments
 
LVL 5

Accepted Solution

by:
Alex-w474 earned 500 total points
ID: 21818435
You can use crc32: http://php.net/manual/en/function.crc32.php
printf('%u', crc32($text));

Open in new window

0
 
LVL 49

Expert Comment

by:Roonaan
ID: 21820159
have you tried:

$hash = rand(1000000000,9999999999);
0
 
LVL 5

Expert Comment

by:Alex-w474
ID: 21820363
>have you tried:
>$hash = rand(1000000000,9999999999);

It is not a hash as per it is.
0
 
LVL 49

Expert Comment

by:Roonaan
ID: 21820386
Yeah, sorry. That's just a random number.
0
 
LVL 16

Author Comment

by:hankknight
ID: 21822702
Alex-w474.

crc32 meets my needs perfectly.
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

832 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