473,765 Members | 1,955 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Looking for a PHP PIN Number generator


I am looking for a script that generates PIN Numbers.

Is there one available somewhere out there? I don't mind algorithms if
they will be easy to implement in PHP.

Regards

Aug 1 '05 #1
7 11758

<my********@yah oo.co.uk> wrote in message
news:11******** **************@ g44g2000cwa.goo glegroups.com.. .

I am looking for a script that generates PIN Numbers.

Is there one available somewhere out there? I don't mind algorithms if
they will be easy to implement in PHP.

Regards


Trivial! If you want, say, a four digit PIN number, then you can say:

$pin = rand(1000, 9999);

Shelly

Go to: www.php.net
Aug 1 '05 #2
On 2005-08-01 15-56-28 Shelly <Shelly <sh************ @asap-consult.com>>
wrote:
<my********@yah oo.co.uk> wrote in message
news:11******** **************@ g44g2000cwa.goo glegroups.com.. .

I am looking for a script that generates PIN Numbers.

Is there one available somewhere out there? I don't mind algorithms if
they will be easy to implement in PHP.

Regards


Trivial! If you want, say, a four digit PIN number, then you can say:

$pin = rand(1000, 9999);

Shelly

Go to: www.php.net


If you want to have the area below 1000, too, the easiest way is:
substr(mt_rand( 10000,19999),1) ;

HTH,
Simon
--
Simon Stienen <http://slashlife.org/>
"What you do in this world is a matter of no consequence,
The question is, what can you make people believe that you have done."
/Sherlock Holmes in A Study in Scarlet by Sir Arthur Conan Doyle/
Aug 1 '05 #3
Shelly wrote:
<my********@yah oo.co.uk> wrote in message
news:11******** **************@ g44g2000cwa.goo glegroups.com.. .
I am looking for a script that generates PIN Numbers.

Is there one available somewhere out there? I don't mind algorithms if
they will be easy to implement in PHP.

Regards

Trivial! If you want, say, a four digit PIN number, then you can say:

$pin = rand(1000, 9999);

Shelly

Go to: www.php.net


Pins can also start with 0, i.e. 0123. A more correct response would be:

$pin=substr('00 00' . rand(1, 9999), -4);

It prepends '0000' to a random number between 1 and 9999 then takes the last
four characters.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Aug 1 '05 #4
Looking around the web I see all sorts of theories for generation
random numbers, some of which sound pretty complicated.

Does PHP's simple command, generate something truly random?

If I generate a range of 16 digit numbers, what chances are there for a
repetition over the whole 10^16 range?

I think my demands are over the top here, I don't know if my computer
can generate that number I just want to have the warm feeling that it
won't be possible in my lifetime.

Aug 2 '05 #5
my********@yaho o.co.uk wrote:
Looking around the web I see all sorts of theories for generation
random numbers, some of which sound pretty complicated.

Does PHP's simple command, generate something truly random?

If I generate a range of 16 digit numbers, what chances are there for a
repetition over the whole 10^16 range?

I think my demands are over the top here, I don't know if my computer
can generate that number I just want to have the warm feeling that it
won't be possible in my lifetime.


It's pretty random, especially if you are generating these at different times
and seed the generator based on the current time. Then you can use general
statistics functions. I wrote a quick program to check, and it showed you would
have to generate 117,741,003 random numbers to have a 50% chance of getting a
duplicate.

Now - if you're trying to generate them all at the same time based on one seed,
the probability might be somewhat less, but shouldn't be that much.

BTW - who cares if there are duplicates? For instance - my bank assigns a 4
digit PIN for my ATM card. And I KNOW they have more than 10,000 users out
there. There are a lot of duplicates.

PINs don't need to be unique - just long enough that they can't be guessed
easily. And I don't think someone's going to guess a 16 digit PIN in any
reasonable time, even if it is computer generated. And you could always lock
them out after 1,000,000 consecutive failures :-).

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Aug 2 '05 #6
I noticed that Message-ID:
<11************ *********@g14g2 000cwa.googlegr oups.com> from
my********@yaho o.co.uk contained the following:
random numbers, some of which sound pretty complicated.

Does PHP's simple command, generate something truly random?

If I generate a range of 16 digit numbers, what chances are there for a
repetition over the whole 10^16 range?


There is always a chance of repetition if you pick a random number.
Either assign the numbers incrementally, or check no duplicate exists.
Also consider using a combination or letters and numbers.

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Aug 2 '05 #7
"Jerry Stuckle" <js*******@attg lobal.net> wrote in message
news:1e******** ************@co mcast.com...
my********@yaho o.co.uk wrote: BTW - who cares if there are duplicates? For instance - my bank assigns a
4 digit PIN for my ATM card. And I KNOW they have more than 10,000 users
out there. There are a lot of duplicates.

PINs don't need to be unique - just long enough that they can't be guessed
easily. And I don't think someone's going to guess a 16 digit PIN in any
reasonable time, even if it is computer generated. And you could always
lock them out after 1,000,000 consecutive failures :-).


.....and who is even going to remember his OWN 16 digit pin?

Shelly
Aug 2 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
2909
by: Sonoman | last post by:
Hi all: I am trying to write a simple program that simulates asking several persons their birth day and it counts how many persons are asked until two have the same birth day. The problem that I have is that the first loop I get a sequence of random numbers untuil I get a match, BUT then on the following loops I get the SAME random(?) sequence. I am using rand(). I do not want to get too fancy with the random number generator, but is there...
4
2404
by: Wahoo | last post by:
Another question,my teacher gave me a code for generate a random number from 1 - range, but I can't made it work, where is the problem? Thanks!!
3
7380
by: Joe | last post by:
Hi, I have been working on some code that requires a high use of random numbers within. Mostly I either have to either: 1) flip a coin i.e. 0 or 1, or 2) generate a double between 0 and 1. I have utilised the following random number source code http://www.agner.org/random/ What I have found is that there is a problem with seeding. The code generates a seed based on time(0). I have found that I need to increment
70
6275
by: Ben Pfaff | last post by:
One issue that comes up fairly often around here is the poor quality of the pseudo-random number generators supplied with many C implementations. As a result, we have to recommend things like using the high-order bits returned by rand() instead of the low-order bits, avoiding using rand() for anything that wants decently random numbers, not using rand() if you want more than approx. UINT_MAX total different sequences, and so on. So I...
11
1839
by: Mark Rae | last post by:
Hi, My R&D department has asked me to look at threading in a Web Service written in C#, so I came up with the following code: using System; using System.ComponentModel; using System.Threading; using System.Web.Services;
5
3353
by: Peteroid | last post by:
I know how to use rand() to generate random POSITIVE-INTEGER numbers. But, I'd like to generate a random DOUBLE number in the range of 0.0 to 1.0 with resolution of a double (i.e., every possible double value in the range could come up with equal probability). I'd also like to be able to seed this generator (e.g., via the clock) so that the same sequence of random values don't come up every time. Anybody have an easy and fast...
73
3218
by: cesco | last post by:
I have to generate a list of N random numbers (integer) whose sum is equal to M. If, for example, I have to generate 5 random numbers whose sum is 50 a possible solution could be . Is there a simple pattern or function in Python to accomplish that? Thanks and regards Francesco
20
5134
by: A | last post by:
Hi all. Is this a bug or what??? here is a simple code: <?php mt_srand(1); echo mt_rand(0, 255)."<br />"; echo mt_rand(0, 255)."<br />";
8
4730
by: remlostime | last post by:
i use g++ to generater rand number, now i find that the RAND_MAX is 32367 in my computer, how can i make a bigger rand number( the number is wihin in the integer(2^32-1))
0
9568
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10160
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10007
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9832
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8831
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7378
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3924
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3531
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.