Solved

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

Posted on 2008-06-18
5
1,071 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

707 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

11 Experts available now in Live!

Get 1:1 Help Now