Um, credit card genorator problem...

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Sinuvoid
Veteran
Posts: 155
Joined: Wed Jul 25, 2007 8:20 am

Um, credit card genorator problem...

Post by Sinuvoid »

IM trying to make a credit card genorator with qbasic for my bank program and its not working AT ALL. I ahve no idea what to do anymore. Heres my code and the site for details. http://www.thetaoofmakingmoney.com/2007/04/12/324.html

Code: Select all

CLS
RANDOMIZE TIMER


issuer1 = 4

issuer2 = INT(RND * 9 + 1) * 2
i2$ = STR$(issuer2)
is2$ = LEFT$(i2$,1) + LEFT$(i2$,2)

issuer3 = INT(RND * 9 + 1) * 2
i3$ = STR$(issuer3)
is3$ = LEFT$(i3$,1) + LEFT$(i3$,2)

issuer4 = INT(RND * 9 + 1) * 2
i4$ = STR$(issuer4)
is4$ = LEFT$(i4$,1) + LEFT$(i4$,2)

issuer5 = INT(RND * 9 + 1) * 2
i5$ = STR$(issuer5)
is5$ = LEFT$(i5$,1) + LEFT$(i5$,2)

issuer6 = INT(RND * 9 + 1) * 2
i6$ = STR$(issuer6)
is6$ = LEFT$(i6$,1) + LEFT$(i6$,2)

accountnum1 = INT(RND * 9 + 1) * 2
acntnm1$ = STR$(accountnum1)
at1$ = LEFT$(acntnm1$,1) + LEFT$(acntnm1$,2)

accountnum2 = INT(RND * 9 + 1) * 2
acntnm2$ = STR$(accountnum2)
at2$ = LEFT$(acntnm2$,1) + LEFT$(acntnm2$,2)

accountnum3 = INT(RND * 9 + 1) * 2
acntnm3$ = STR$(accountnum3)
at3$ = LEFT$(acntnm3$,1) + LEFT$(acntnm3$,2)

accountnum4 = INT(RND * 9 + 1) * 2
acntnm4$ = STR$(accountnum4)
at4$ = LEFT$(acntnm4$,1) + LEFT$(acntnm4$,2)

accountnum5 = INT(RND * 9 + 1) * 2
acntnm5$ = STR$(accountnum5)
at5$ = LEFT$(acntnm5$,1) + LEFT$(acntnm5$,2)

accountnum6 = INT(RND * 9 + 1) * 2
acntnm6$ = STR$(accountnum6)
at6$ = LEFT$(acntnm6$,1) + LEFT$(acntnm6$,2)

accountnum7 = INT(RND * 9 + 1) * 2
acntnm7$ = STR$(accountnum7)
at7$ = LEFT$(acntnm7$,1) + LEFT$(acntnm7$,2)

accountnum8 = INT(RND * 9 + 1) * 2
acntnm8$ = STR$(accountnum8)
at8$ = LEFT$(acntnm8$,1) + LEFT$(acntnm8$,2)

accountnum9 = INT(RND * 9 + 1) * 2
acntnm9$ = STR$(accountnum9)
at9$ = LEFT$(acntnm9$,1) + LEFT$(acntnm9$,2)


verifacationnum$ = is2$ + is3$ + is4$ + is5$ + is6$ + at1$ + at2$ + at3$ + at4$ + at5$ + at6% + at7$ + at8$ + at9$


OPEN "results.txt" FOR APPEND AS #1
PRINT #1,is1$; is2$; is3$; is4$; is5$; is6$; at1$;at2$;at3$;at4$;at5$;at6$;at7$;at8$;at9$;verifacationnum$
CLOSE #1

SHELL "cmd /c start notepad results.txt"

END
Yes I know, complicated :)
User avatar
burger2227
Veteran
Posts: 2466
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

?????????????

Post by burger2227 »

What does not work? You could at least explain that!

Where exactly is the file you are opening? Try a path.

Please do not just post code without explaining the problem first.

Ted
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
bungytheworm
Veteran
Posts: 288
Joined: Sat Feb 18, 2006 4:02 pm

Post by bungytheworm »

I agree with hamburger here. Hard to find the problem if you dont give more details.
Lee, expect us to spend as much time for your problems as you spend to tell us about them.
sid6.7
Veteran
Posts: 318
Joined: Tue Jun 21, 2005 8:51 am
Location: west USA
Contact:

Post by sid6.7 »

off hand i see one error here:

Code: Select all

verifacationnum$ = is2$ + is3$ + is4$ + is5$ + is6$ + at1$ + at2$ + at3$ + at4$ + at5$ + at6% + at7$ + at8$ + at9$ 
the at6% should be at6$ ?
Sinuvoid
Veteran
Posts: 155
Joined: Wed Jul 25, 2007 8:20 am

Post by Sinuvoid »

Yeah sid :P

Ok, the ONLY way to understand what Im trying to do is to read the web page i put up. what its doing is taking 14 digits and randomizing them. then multiplying them by 2 and if any come out as a double digit then I tell it to split them and add them together. then i tell it to add all the numbers together to get 1 value. then it rights the 16 digit number in the file. nad no burger the path part is not my problem :)
User avatar
burger2227
Veteran
Posts: 2466
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

illogical

Post by burger2227 »

JIM: SPOCK Put us in warp drive until the warp is over 9. Then split digits in half, multiply each by 2 and add them together.

SCOTTY: Damn captin we cannot handle that kind of mathematics!

JIM: SULU Beam Lee up! There is no intellegent life left down there anymore.

McCoy: I hope Lee is wearing those tight rubber pants I prescribed!

SPOCK: Why didn't Lee just use random numbers from 0 to 9?
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
Sinuvoid
Veteran
Posts: 155
Joined: Wed Jul 25, 2007 8:20 am

Post by Sinuvoid »

Ugh...CAN YOU JUST PLEASE READ THE WEB PAGE I POSTED PLEASE? That may help you understand what's being ask :)
User avatar
Seb McClouth
Veteran
Posts: 342
Joined: Wed Nov 09, 2005 7:47 am
Location: Inside the Matrix...
Contact:

Re: illogical

Post by Seb McClouth »

burger2227 wrote:JIM: SPOCK Put us in warp drive until the warp is over 9. Then split digits in half, multiply each by 2 and add them together.

SCOTTY: Damn captin we cannot handle that kind of mathematics!

JIM: SULU Beam Lee up! There is no intellegent life left down there anymore.

McCoy: I hope Lee is wearing those tight rubber pants I prescribed!

SPOCK: Why didn't Lee just use random numbers from 0 to 9?
Mss Uhura: You have an answer. I'm an illogical woman, who's beginning to feel too much a part of that communications console. Why don't you tell me I'm an attractive young lady, or ask me if I've ever been in love, tell me how your planet Vulcan looks on a lazy evening when the moon is full.
QBinux is a Linux distribution with the aim of integrating the work of the vast community of free software developers at Pete's QBASIC Site in order to create a modern, performant, safe and easy to use system for system administrators and desktop users.
Sinuvoid
Veteran
Posts: 155
Joined: Wed Jul 25, 2007 8:20 am

Post by Sinuvoid »

lmao, Scotty's answer seems to be the only right one. But I need to guys to look over my code and see if it should do what its supposed to do. But other than that I don't know how you guys are going to help :?

Thats as close as I can get of telling you guys the problem :?

And the onyl way to get the question even more is to READ THE WEBPAGE I posted. There is no stynax errors. I've ran it 100 times and cahnged it and still havnt got the right output :?
User avatar
burger2227
Veteran
Posts: 2466
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

CREDIT card numbers

Post by burger2227 »

I don't think what you are doing here is LEGAL and I will not help you generate fake credit card numbers!

That is probably why you will get no response to your question! If you want to verify a number, then you are missing a key ingredient. MOD.
Apparently you also did not understand what was on the site either.

Ted
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
Sinuvoid
Veteran
Posts: 155
Joined: Wed Jul 25, 2007 8:20 am

Post by Sinuvoid »

I was only doing this for LEARNING PURPOSES,quote "The purpose of this post is *not* to create fraudulent workable card numbers." and thus it also says that on teh webpage. But its alright if you guys dont trust me :P

btw,Its the anatomy of a credit card, what else was on that page that was horrible :? Ok, Ill delete teh topic and save some space :)

EDIT:Wheres teh delete button?!
Mac
Veteran
Posts: 151
Joined: Mon Aug 06, 2007 2:00 pm

Post by Mac »

Lee wrote:you guys dont trust me
Well, you said for your banking system. No banking system requires the ability to generate credit cards. Forget that.

Now I can understanding checking credit cards submitted to me for validity. The instructions given were

Starting with the check digit, double the value of every second digit (never double the check digit). For example, in a 16 digit credit card number, double the 15th, 13th, 11th, 9th…digits (digits in odd places). In all, you will need to double eight digits.
If doubling of a number results in a two digit number, add up the digits to get a single digit number. This will result in eight single digit numbers.
Now, replace the digits in the odd places (in the original credit card number) with these new single digit numbers to get a new 16 digit number.
Add up all the digits in this new number. If the final total is perfectly divisible by 10, then the credit card number is valid (Luhn check is satisfied), else it is invalid.

But that seems easy enough.

Yeah, good project to abandon. Who wants software on their computer which can generate credit cards that can pass vendor site authentication tests? That would be like having equipment to generate master keys for padlocks. Ouch! Better to be caught with porno.

Mac
User avatar
burger2227
Veteran
Posts: 2466
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

EASY

Post by burger2227 »

The last digit makes the card numbers added divisible by 10 so it would be rather easy to find that number using lastdigit = 10 - (total MOD 10).

However, most establishments would require a valid expiration date and many want the security number on the back of the card. It would be a good formula for verifying a number, but nowadays, cards are sent instantly to the credit companies. Even on the web.

Ted
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
Sinuvoid
Veteran
Posts: 155
Joined: Wed Jul 25, 2007 8:20 am

Post by Sinuvoid »

Is anyone gonna delete this thread now >_>

EDIT: Yeah Mac, that was the purpose. To create a card number and see if it was valid. Thats it,Thats all. :P
User avatar
Seb McClouth
Veteran
Posts: 342
Joined: Wed Nov 09, 2005 7:47 am
Location: Inside the Matrix...
Contact:

Post by Seb McClouth »

Don't delete it. I'm working on something, it'll take a couple of days but since I have some knowledge of algebra, I was gonna give it a try.

Grtz
QBinux is a Linux distribution with the aim of integrating the work of the vast community of free software developers at Pete's QBASIC Site in order to create a modern, performant, safe and easy to use system for system administrators and desktop users.
Nemesis
Coder
Posts: 36
Joined: Mon Aug 16, 2004 12:54 pm
Location: Colorado Springs, Colorado

Post by Nemesis »

What's there to try?
The last digit makes the card numbers added divisible by 10 so it would be rather easy to find that number using lastdigit = 10 - (total MOD 10).
Unless you're doing something totally different?
Patz QuickBASIC Creations
Veteran
Posts: 399
Joined: Wed Mar 02, 2005 9:01 pm
Location: Nashville, Tennessee
Contact:

Post by Patz QuickBASIC Creations »

I've checked this against some sites on the internet, all validating my code against the Luhn method, so this code does what you need it to do. However, you might want to tweak it to make sure that you're not going out of industry boundaries. More info here: http://www.merriampark.com/anatomycc.htm

Code: Select all

'Random Credit Card Generator

RANDOMIZE TIMER

FOR A = 1 TO 15   'Get our first 15 digits
  CCNum$ = CCNum$ + LTRIM$(RTRIM$(STR$(INT(RND * 10))))
NEXT A
        
ValidateNum$ = CCNum$     'Copy our Credit Card number for the Luhn check.

FOR A = 1 TO 15 STEP 2     'Perform the Luhn method on our number.
  LuhnCheck% = 2 * VAL(MID$(CCNum$, A, 1))
  LuhnCheck% = LuhnCheck% + 9 * (LuhnCheck% >= 10)
  MID$(ValidateNum$, A, 1) = LTRIM$(RTRIM$(STR$(LuhnCheck%)))
NEXT A

FOR A = 1 TO 15     'Get our checksum
  Checksum% = Checksum% + VAL(MID$(ValidateNum$, A, 1))
NEXT A

CheckDigit% = (10 - (Checksum% MOD 10)) MOD 10     'Final (check) digit

CCNum$ = CCNum$ + LTRIM$(RTRIM$(STR$(CheckDigit%)))     'Add the check digit on

PRINT CCNum$     'Show output
Code to validate a CCN to the Luhn method:

Code: Select all

'Credit Card Validator (Luhn method)
INPUT CCNum$

ValidCheck$ = CCNum$

FOR A = 1 TO 15 STEP 2     'Perform the Luhn method on our number.
  LuhnCheck% = 2 * VAL(MID$(CCNum$, A, 1))
  LuhnCheck% = LuhnCheck% + 9 * (LuhnCheck% >= 10)
  MID$(ValidCheck$, A, 1) = LTRIM$(RTRIM$(STR$(LuhnCheck%)))
NEXT A

FOR A = 1 TO 16     'Get our checksum
  Checksum% = Checksum% + VAL(MID$(ValidCheck$, A, 1))
NEXT A

IF (Checksum% MOD 10) = 0 THEN
   PRINT "Valid number."
ELSE
   PRINT "Invalid number."
END IF
Also, this is perfectly legal. People use these types of codes to test out their pre-validation systems, and it's just harmless fun since this code can't generate a valid expiration date, PIN, or CVC number.
Last edited by Patz QuickBASIC Creations on Sat Jan 12, 2008 9:21 pm, edited 1 time in total.
User avatar
burger2227
Veteran
Posts: 2466
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

How it works

Post by burger2227 »

Interesting way to check the numbers over 10 when multipied by 2:

Code: Select all

LuhnCheck% = LuhnCheck% + 9 * (LuhnCheck% >= 10) 
The code inside of the brackets is a boolean (true-false) evaluation which QB returns true as -1 and false as 0. So let's say the odd card digit is 8.

8 * 2 = 16 then 16 + 9 * (-1) = 7 . The same as 1 + 6 = 7 by adding the digits.
The number 9 is a common result of number digit manipulations.

For instance pick any number from 10 to 100. Add the digits together and subtract from your original number. The resulting number is always divisible by 9. The same thing can be done with more than 3 digits.

Perhaps it has something to do with our decimal numbering system. After all, in base 10 there are only numbers from 0 to 9.

Ted
Still King!
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
Mac
Veteran
Posts: 151
Joined: Mon Aug 06, 2007 2:00 pm

Re: How it works

Post by Mac »

burger2227 wrote:IFor instance pick any number from 10 to 100. Add the digits together and subtract from your original number. The resulting number is always divisible by 9.
To restate:

Pick 10a+b (This is a two digit number. 37 = 10*3+7
Subtract a+b (This is the sum of the digits)
Result: 9a
Wow! Marvel that 9a is divisible by 9

LOL

Mac
Patz QuickBASIC Creations
Veteran
Posts: 399
Joined: Wed Mar 02, 2005 9:01 pm
Location: Nashville, Tennessee
Contact:

Re: How it works

Post by Patz QuickBASIC Creations »

burger2227 wrote:Interesting way to check the numbers over 10 when multipied by 2:

Code: Select all

LuhnCheck% = LuhnCheck% + 9 * (LuhnCheck% >= 10) 
Subtracting the 9 wasn't my idea, but using the logical operator in there was. Coming from TI-BASIC makes you see tons of small optimizations you can do to the program.


Also, to tweak my code to make it work to where you can set the issuer digits, use the following code instead:

Code: Select all

'Random Credit Card Generator 

RANDOMIZE TIMER 

CCNum$ = "52"     'Specifies that the issuer is a Mastercard.

WHILE LEN(CCNum$) < 15   'Get our first 15 digits 
  CCNum$ = CCNum$ + LTRIM$(RTRIM$(STR$(INT(RND * 10)))) 
WEND
        
ValidateNum$ = CCNum$     'Copy our Credit Card number for the Luhn check. 

FOR A = 1 TO 15 STEP 2     'Perform the Luhn method on our number. 
  LuhnCheck% = 2 * VAL(MID$(CCNum$, A, 1)) 
  LuhnCheck% = LuhnCheck% + 9 * (LuhnCheck% >= 10) 
  MID$(ValidateNum$, A, 1) = LTRIM$(RTRIM$(STR$(LuhnCheck%))) 
NEXT A 

FOR A = 1 TO 15     'Get our checksum 
  Checksum% = Checksum% + VAL(MID$(ValidateNum$, A, 1)) 
NEXT A 

CheckDigit% = (10 - (Checksum% MOD 10)) MOD 10     'Final (check) digit 

CCNum$ = CCNum$ + LTRIM$(RTRIM$(STR$(CheckDigit%)))     'Add the check digit on 

PRINT CCNum$     'Show output
Post Reply