Solved

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

Posted on 2008-06-18
5
1,189 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
This article discusses how to implement server side field validation and display customized error messages to the client.
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 look for a specific file type in a local or remote server directory using PHP.

623 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