in reply to Generating random 6 digit numbers

What are you going to use them for? 999,999 combinations is really not ver expansive, there may be better ways to do what you are trying to do if we had more information about what it is you are trying to do. for instance if you are looking for unique way to generate urls to give a one time download or something like that 999,999 combinations would be a simple task to brute force.. toss us a lil more info

-Waswas

Replies are listed 'Best First'.
Re: Re: Generating random 6 digit numbers
by Anonymous Monk on Aug 26, 2002 at 01:53 UTC
    I'm going to be processing text files of new customers. Each customer in the file needs to have a random (yet unique) id generated. The requirements state that the id needs to be 6 digits. No word on how many customers I'll get, certainly no more than 999,999 (so I'm told anyway).
      Ok, I have to ask. What kind of application are you using where using pseudo random numbers for customer ids isn't good enough? I'm already amazed that sequential numbers can't be used, but not even PRNs?

      Well, even if you have 900,001 customers, you have a problem, unless ids are allowed to have leading 0s. Of course, even if you have 100,000 customers, using 6 digits for the id in combination with being truely random and unique doesn't make much sense.

      Abigail

      Why does the ID need to be random? Simply counting the customers would make them all unique.

      If it must be random I'd count the customers and change the leading zeros to a generated pseudo random number.

      Hope that helps
      Chris

      Lobster Aliens Are attacking the world!
      I've done something like that.

      Instead of using digits, I used 6 (or howevermany) random characters. I used only letters and numbers that didn't look like other characters, so it could be safe from human transcription.

      But, after generating the random file name, it's trivial to test if it's a duplicate because the directory itself is a record! You don't have to maintain your own hash. Just see if the candidate file name already exists.

      —John

      I'm a little worried that the randomness might be for security reasons. If your objective is to make a valid customer ID number hard to guess, you need to say so now and let the Monks help prevent you from making a terrible mistake.
        Sounds suspiciously like he was trying to figure out lottery numbers to use. :)