Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's minimum standard of quality and will not be displayed.

Replies are listed 'Best First'.
Re: Prepaid Cards
by Cody Pendant (Prior) on Mar 27, 2007 at 09:00 UTC
    I'm guessing he/she means "coming up with numbers which can't be hacked"?

    That is, if I buy a phone card with the number 123-456-789-1, I shouldn't be able to guess that 123-456-789-2 is also valid and get some free credits.

    If so, that's an interesting question, though not a Perl question as such.



    ($_='kkvvttuu bbooppuuiiffss qqffssmm iibbddllffss')
    =~y~b-v~a-z~s; print
      I doubt there is such a thing as "numbers which cannot be hacked", unless you go the cryptographic route.

      You start with a UUID and a checksumm over it and then code both with a secure cryptographic method of which only you know the key.

      It would be next to impossible to change a few numbers and end up with a valid UUID and checksum.

      If you combine that with a maximum number of tries before your log-in is locked-out and you have a pretty secure way of providing such "cards".

      CountZero

      "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

Re: Prepaid Cards
by MonkE (Hermit) on Mar 27, 2007 at 14:13 UTC

    I find it troubling that you don't have any specification at all. I would have presumed that, if you were doing this for an employer or business partner, that they would have provided a specification on exactly how the cards are to be generated, etc.

    My advice to you, if your aim is indeed legitimate, is not to use perl to generate these numbers yourself, but instead seek the services of a professional gift card company. There are quite a few of them out there. Google for terms such as "stored value cards". This is money we're talking about. Don't screw around with it by trying to do an amateur hack job. There are too many caveats with stored value systems for a beginner to implement a system like this without putting their money and their reputation at risk.

Re: Prepaid Cards
by hangon (Deacon) on Mar 27, 2007 at 09:24 UTC

    Its not clear exactly what you're looking for. Is there some specification for the codes you need? If you just want to generate a batch of unique random id codes you can do something like this:

    # use hash keys to hold unique id codes my %id_codes; # number of codes to generate my $batch_qty = 100; # length of id code my $length = 24; while (scalar keys(%id_codes) < $batch_qty){ my $id; for (1..$length){ $id .= ('A'..'Z', 'a'..'z', '0'..'9')[rand(62)]; } $id_codes{$id} = 1; }

    If you don't want to keep track of all the id codes generated, you should probably look at some form of public & private key encryption.

Re: Prepaid Cards
by CountZero (Bishop) on Mar 27, 2007 at 06:45 UTC
    I gather you would need some special hardware to make such cards. And the software to produce the cards probably comes with the hardware.

    Or do you mean the type of cards which come with a "secret" code you have to enter in your mobile phone, ... and then gives you some credits to use?

    CountZero

    "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

      Yes ... i mean cards which have hidden field(s) when you scratch it you'll get ( 2 codes )

      Then you can use those codes to get value added service

      And I'm planing to use them online for purchasing accounts in games site

      any idea / articles / code examples ?

      using 2 codes would lower the chance of getting right numbers as i think