/* CC Checksum Verification Program
by Belgarion of the Coed Naked Hackers Guild
Permission is given for free distribution.
Choose the lesser of two evils. Vote for Satan in 96*/
include stdio.h
main
char cc20
int check, len, prod, j
printfnAmex/MC/Visa Checksum Verification Program
printfnby Crazed Luddite Murdering Thugn
for
printfnEnter Card Number w/o spaces or dashes. Q to
quitn:
scanfs,cc
if cc0Qcc0q break /* exit infinite loop, if
Q */
/* Verify Card Type */
if cc0!3cc0!4cc0!5
printfnCard number must begin with a 3, 4, or 5.
continue
else if cc05striencc!16
printfnMastercard must be 16 digits.
continue
else if cc04striencc!13striencc!16
printfnVisa numbers must be 13 or 16 digits.
continue
else if cc03striencc!15
printfnAmerican Express numbers must be 15 digits.
continue
/* Perform Checksum - Weighing list 2121212121212121.... */
check 0 /* reset check to 0 */
len striencc
for j1jlenj++ /* go through entire cc num string
prod ccj-1-0 /* convert char to int */
if len-j2 prodprod*2 /* if odd digit from end,
prodprod*2 */
/* otherwise prodprod*1 */
if prod10 prodprod-9 /* subtract 9 if prod is 10 */
checkcheck+prod /* add to check */
if check100 /* card good if check divisible by
10 */
printfnCard passed checksum test.
else
printfnCard did not pass checksum test.