= [];
145 | for (let i = 0; i < howMany; i++) {
146 |
147 | let randomArrayIndex: number = Math.floor(Math.random() * prefixList.length);
148 | let ccnumber: string = prefixList[ randomArrayIndex ];
149 | result.push( completed_number(ccnumber, length) );
150 | }
151 | return result;
152 | }
153 |
--------------------------------------------------------------------------------
/gencc.js:
--------------------------------------------------------------------------------
1 | /*
2 | Javascript credit card number generator
3 | Copyright (C) 2006-2012 Graham King graham@gkgk.org
4 |
5 | This program is free software; you can redistribute it and/or
6 | modify it under the terms of the GNU General Public License
7 | as published by the Free Software Foundation; either version 2
8 | of the License, or (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program; if not, write to the Free Software
17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 |
19 | www.darkcoding.net
20 | */
21 |
22 | var visaPrefixList = new Array(
23 | "4539",
24 | "4556",
25 | "4916",
26 | "4532",
27 | "4929",
28 | "40240071",
29 | "4485",
30 | "4716",
31 | "4"
32 | );
33 |
34 | var mastercardPrefixList = new Array(
35 | "51",
36 | "52",
37 | "53",
38 | "54",
39 | "55",
40 | "2221",
41 | "2222",
42 | "2223",
43 | "2224",
44 | "2225",
45 | "2226",
46 | "2227",
47 | "2228",
48 | "2229",
49 | "223",
50 | "224",
51 | "225",
52 | "226",
53 | "227",
54 | "228",
55 | "229",
56 | "23",
57 | "24",
58 | "25",
59 | "26",
60 | "270",
61 | "271",
62 | "2720"
63 | );
64 |
65 | var amexPrefixList = new Array(
66 | "34",
67 | "37"
68 | );
69 |
70 | var discoverPrefixList = new Array("6011");
71 |
72 | var dinersPrefixList = new Array(
73 | "300",
74 | "301",
75 | "302",
76 | "303",
77 | "36",
78 | "38"
79 | );
80 |
81 | var enRoutePrefixList = new Array(
82 | "2014",
83 | "2149"
84 | );
85 |
86 | var jcbPrefixList = new Array(
87 | "35"
88 | );
89 |
90 | var voyagerPrefixList = new Array("8699");
91 |
92 |
93 | function strrev(str) {
94 | if (!str) return '';
95 | var revstr='';
96 | for (i = str.length-1; i>=0; i--)
97 | revstr+=str.charAt(i)
98 | return revstr;
99 | }
100 |
101 | /*
102 | 'prefix' is the start of the CC number as a string, any number of digits.
103 | 'length' is the length of the CC number to generate. Typically 13 or 16
104 | */
105 | function completed_number(prefix, length) {
106 |
107 | var ccnumber = prefix;
108 |
109 | // generate digits
110 |
111 | while ( ccnumber.length < (length - 1) ) {
112 | ccnumber += Math.floor(Math.random()*10);
113 | }
114 |
115 | // reverse number and convert to int
116 |
117 | var reversedCCnumberString = strrev( ccnumber );
118 |
119 | var reversedCCnumber = new Array();
120 | for ( var i=0; i < reversedCCnumberString.length; i++ ) {
121 | reversedCCnumber[i] = parseInt( reversedCCnumberString.charAt(i) );
122 | }
123 |
124 | // calculate sum
125 |
126 | var sum = 0;
127 | var pos = 0;
128 |
129 | while ( pos < length - 1 ) {
130 |
131 | odd = reversedCCnumber[ pos ] * 2;
132 | if ( odd > 9 ) {
133 | odd -= 9;
134 | }
135 |
136 | sum += odd;
137 |
138 | if ( pos != (length - 2) ) {
139 |
140 | sum += reversedCCnumber[ pos +1 ];
141 | }
142 | pos += 2;
143 | }
144 |
145 | // calculate check digit
146 |
147 | var checkdigit = (( Math.floor(sum/10) + 1) * 10 - sum) % 10;
148 | ccnumber += checkdigit;
149 |
150 | return ccnumber;
151 |
152 | }
153 |
154 | function credit_card_number(prefixList, length, howMany) {
155 |
156 | var result = new Array();
157 | for (var i = 0; i < howMany; i++) {
158 |
159 | var randomArrayIndex = Math.floor(Math.random() * prefixList.length);
160 | var ccnumber = prefixList[ randomArrayIndex ];
161 | result.push( completed_number(ccnumber, length) );
162 | }
163 |
164 | return result;
165 | }
166 |
--------------------------------------------------------------------------------
/EACreditCardNumberGenerator.m:
--------------------------------------------------------------------------------
1 | //
2 | // EACreditCardNumberGenerator.m
3 | // ccnumber
4 | //
5 | // Created by Ethan Arbuckle on 7/4/13.
6 | // Copyright (c) 2013 Ethan Arbuckle. All rights reserved.
7 | //
8 |
9 | #import "EACreditCardNumberGenerator.h"
10 |
11 | @implementation EACreditCardNumberGenerator
12 |
13 | - (NSArray*)generateMasterCardNumbers_Count:(int)howMany {
14 | NSArray *masterCardPrefixes = [[NSArray alloc] initWithObjects:@"51", @"52", @"53", @"54", @"55", @"2221", @"2222", @"2223", @"2224", @"2225", @"2226", @"2227", @"2228", @"2229", @"223", @"224", @"225", @"226", @"227", @"228", @"229", @"23", @"24", @"25", @"26", @"270", @"271", @"2720", nil];
15 | return [self credit_card_number:masterCardPrefixes :16 :howMany];
16 | }
17 |
18 | - (NSArray*)generateVisaNumbers_Count:(int)howMany {
19 | NSArray *visaPrefixes = [[NSArray alloc] initWithObjects:@"4539", @"4556", @"4532", @"4929", @"40240071", @"4485", @"4716", @"4", nil];
20 | return [self credit_card_number:visaPrefixes :16 :howMany];
21 | }
22 |
23 | - (NSArray*)generateDiscoveryNumbers_Count:(int)howMany {
24 | NSArray *discoveryPrefixes = [[NSArray alloc] initWithObjects:@"6011", nil];
25 | return [self credit_card_number:discoveryPrefixes :16 :howMany];
26 | }
27 |
28 | - (NSArray*)generateAmexNumbers_Count:(int)howMany {
29 | NSArray *amexPrefixes = [[NSArray alloc] initWithObjects:@"34", @"37", nil];
30 | return [self credit_card_number:amexPrefixes :16 :howMany];
31 | }
32 |
33 | - (NSArray*)generateDinersNumbers_Count:(int)howMany {
34 | NSArray *dinersPrefixes = [[NSArray alloc] initWithObjects:@"300", @"301", @"302", @"303", @"36", @"38", nil];
35 | return [self credit_card_number:dinersPrefixes :16 :howMany];
36 | }
37 |
38 | - (NSArray*)generateEnrouteNumbers_Count:(int)howMany {
39 | NSArray *enroutePrefixes = [[NSArray alloc] initWithObjects:@"2014", @"2149", nil];
40 | return [self credit_card_number:enroutePrefixes :16 :howMany];
41 | }
42 |
43 | - (NSArray*)generateJCBNumbers_Count:(int)howMany {
44 | NSArray *JCBPrefixes = [[NSArray alloc] initWithObjects:@"35", nil];
45 | return [self credit_card_number:JCBPrefixes :16 :howMany];
46 | }
47 |
48 | - (NSArray*)generateVoyagerNumbers_Count:(int)howMany {
49 | NSArray *voyagerPrefixes = [[NSArray alloc] initWithObjects:@"8699", nil];
50 | return [self credit_card_number:voyagerPrefixes :16 :howMany];
51 | }
52 |
53 | - (NSArray*)credit_card_number :(NSArray*)prefixList :(int)length :(int)howMany {
54 | NSMutableArray *stack = [[NSMutableArray alloc] init];
55 | for (int i = 0; i < howMany; i++) {
56 | int randomArrayIndex = arc4random() % [prefixList count];
57 | NSString *ccnumber = [prefixList objectAtIndex:randomArrayIndex];
58 | [stack addObject:[self completed_number:ccnumber :length]];
59 | }
60 | return stack;
61 | }
62 |
63 | - (NSString*)completed_number :(NSString*)prefix :(int)length {
64 | NSMutableString *ccnumber = [[NSMutableString alloc] initWithFormat:@"%@", prefix];
65 | while ([ccnumber length] < (length - 1)) {
66 | int num = floor(arc4random() % 10);
67 | [ccnumber appendString:[NSMutableString stringWithFormat:@"%d", num]];
68 | }
69 | NSString *reversedCCnumber = [self reverseString:(NSString*)ccnumber];
70 | NSMutableArray *reversedCCNumList = [NSMutableArray array];
71 | for (int i = 0; i < [reversedCCnumber length]; i++) {
72 | NSString *ch = [reversedCCnumber substringWithRange:NSMakeRange(i, 1)];
73 | [reversedCCNumList addObject:ch];
74 | }
75 | int sum = 0;
76 | int pos = 0;
77 | while (pos < length - 1) {
78 | int odd = [[reversedCCNumList objectAtIndex:pos] intValue] * 2;
79 | if (odd > 9) {
80 | odd -= 9;
81 | }
82 | sum += odd;
83 | if (pos != (length - 2)) {
84 | sum += [[reversedCCNumList objectAtIndex:pos + 1] intValue];
85 | }
86 | pos += 2;
87 | }
88 | int digitInt = ((floor(sum / 10) + 1) * 10 - sum);
89 | int checkDigit = digitInt % 10;
90 | [ccnumber appendString:[NSMutableString stringWithFormat:@"%d", checkDigit]];
91 | return ccnumber;
92 | }
93 |
94 | - (NSString*)reverseString :(NSString*)str {
95 | NSMutableArray *temp=[[NSMutableArray alloc] init];
96 | for(int i = 0; i < [str length]; i++)
97 | {
98 | [temp addObject:[NSString stringWithFormat:@"%c", [str characterAtIndex:i]]];
99 | }
100 | temp = [NSMutableArray arrayWithArray:[[temp reverseObjectEnumerator] allObjects]];
101 | NSString *reverseString = @"";
102 | for(int i = 0; i < [temp count]; i++)
103 | {
104 | reverseString = [NSString stringWithFormat:@"%@%@", reverseString, [temp objectAtIndex:i]];
105 | }
106 | return reverseString;
107 | }
108 |
109 | - (BOOL)isValidCreditCardNumber:(NSString*)ccnum {
110 | BOOL isValid = NO;
111 | NSString *reversedCCNumber = [self reverseString:ccnum];
112 | int mod10Count = 0;
113 | for (int i = 0; i < [reversedCCNumber length]; i++) {
114 | int augend = [[reversedCCNumber substringWithRange:NSMakeRange(i, 1)] intValue];
115 | if (((i + 1) % 2) == 0) {
116 | NSString *productString = [NSString stringWithFormat:@"%d", (augend * 2)];
117 | augend = 0;
118 | for (int j = 0; j < [productString length]; j++) {
119 | augend += [[productString substringWithRange:NSMakeRange(j, 1)] intValue];
120 | }
121 | }
122 | mod10Count += augend;
123 | }
124 | if ((mod10Count%10) == 0) {
125 | isValid = YES;
126 | }
127 | return isValid;
128 | }
129 |
130 | @end
131 |
--------------------------------------------------------------------------------
/gencc.php:
--------------------------------------------------------------------------------
1 | 9 ) {
104 | $odd -= 9;
105 | }
106 |
107 | $sum += $odd;
108 |
109 | if ( $pos != ($length - 2) ) {
110 |
111 | $sum += $reversedCCnumber[ $pos +1 ];
112 | }
113 | $pos += 2;
114 | }
115 |
116 | # Calculate check digit
117 |
118 | $checkdigit = (( floor($sum/10) + 1) * 10 - $sum) % 10;
119 | $ccnumber .= $checkdigit;
120 |
121 | return $ccnumber;
122 | }
123 |
124 | function credit_card_number($prefixList, $length, $howMany) {
125 |
126 | for ($i = 0; $i < $howMany; $i++) {
127 |
128 | $ccnumber = $prefixList[ array_rand($prefixList) ];
129 | $result[] = completed_number($ccnumber, $length);
130 | }
131 |
132 | return $result;
133 | }
134 |
135 | function output($title, $numbers) {
136 |
137 | $result[] = "";
138 | $result[] = "
$title
";
139 | $result[] = implode('
', $numbers);
140 | $result[]= '';
141 |
142 | return implode('
', $result);
143 | }
144 |
145 | #
146 | # Main
147 | #
148 |
149 | echo "";
150 | $mastercard = credit_card_number($mastercardPrefixList, 16, 10);
151 | echo output("Mastercard", $mastercard);
152 |
153 | $visa16 = credit_card_number($visaPrefixList, 16, 10);
154 | echo output("VISA 16 digit", $visa16);
155 | echo "
";
156 |
157 | echo "";
158 | $visa13 = credit_card_number($visaPrefixList, 13, 5);
159 | echo output("VISA 13 digit", $visa13);
160 |
161 | $amex = credit_card_number($amexPrefixList, 15, 5);
162 | echo output("American Express", $amex);
163 | echo "
";
164 |
165 | # Minor cards
166 |
167 | echo "";
168 | $discover = credit_card_number($discoverPrefixList, 16, 3);
169 | echo output("Discover", $discover);
170 |
171 | $diners = credit_card_number($dinersPrefixList, 14, 3);
172 | echo output("Diners Club", $diners);
173 | echo "
";
174 |
175 | echo "";
176 | $enRoute = credit_card_number($enRoutePrefixList, 15, 3);
177 | echo output("enRoute", $enRoute);
178 |
179 | $jcb = credit_card_number($jcbPrefixList, 16, 3);
180 | echo output("JCB", $jcb);
181 | echo "
";
182 |
183 | echo "";
184 | $voyager = credit_card_number($voyagerPrefixList, 15, 3);
185 | echo output("Voyager", $voyager);
186 | echo "
";
187 | ?>
188 |
--------------------------------------------------------------------------------
/gencc.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 |
3 | """
4 | gencc: A simple program to generate credit card numbers that pass the
5 | MOD 10 check (Luhn formula).
6 | Usefull for testing e-commerce sites during development.
7 |
8 | Copyright 2003-2012 Graham King
9 |
10 | This program is free software; you can redistribute it and/or modify
11 | it under the terms of the GNU General Public License as published by
12 | the Free Software Foundation; either version 2 of the License, or
13 | (at your option) any later version.
14 |
15 | This program is distributed in the hope that it will be useful,
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | GNU General Public License for more details.
19 |
20 | You should have received a copy of the GNU General Public License
21 | along with this program; if not, write to the Free Software
22 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 | """
24 |
25 | # Different naming convention, because translated from PHP
26 | # pylint: disable=C0103
27 |
28 | from random import Random
29 | import copy
30 |
31 | visaPrefixList = [
32 | ['4', '5', '3', '9'],
33 | ['4', '5', '5', '6'],
34 | ['4', '9', '1', '6'],
35 | ['4', '5', '3', '2'],
36 | ['4', '9', '2', '9'],
37 | ['4', '0', '2', '4', '0', '0', '7', '1'],
38 | ['4', '4', '8', '6'],
39 | ['4', '7', '1', '6'],
40 | ['4']]
41 |
42 | mastercardPrefixList = [
43 | ['5', '1'],
44 | ['5', '2'],
45 | ['5', '3'],
46 | ['5', '4'],
47 | ['5', '5'],
48 | ['2', '2', '2', '1'],
49 | ['2', '2', '2', '2'],
50 | ['2', '2', '2', '3'],
51 | ['2', '2', '2', '4'],
52 | ['2', '2', '2', '5'],
53 | ['2', '2', '2', '6'],
54 | ['2', '2', '2', '7'],
55 | ['2', '2', '2', '8'],
56 | ['2', '2', '2', '9'],
57 | ['2', '2', '3'],
58 | ['2', '2', '4'],
59 | ['2', '2', '5'],
60 | ['2', '2', '6'],
61 | ['2', '2', '7'],
62 | ['2', '2', '8'],
63 | ['2', '2', '9'],
64 | ['2', '3'],
65 | ['2', '4'],
66 | ['2', '5'],
67 | ['2', '6'],
68 | ['2', '7', '0'],
69 | ['2', '7', '1'],
70 | ['2', '7', '2', '0']]
71 |
72 | amexPrefixList = [['3', '4'], ['3', '7']]
73 |
74 | discoverPrefixList = [['6', '0', '1', '1']]
75 |
76 | dinersPrefixList = [
77 | ['3', '0', '0'],
78 | ['3', '0', '1'],
79 | ['3', '0', '2'],
80 | ['3', '0', '3'],
81 | ['3', '6'],
82 | ['3', '8']]
83 |
84 | enRoutePrefixList = [['2', '0', '1', '4'], ['2', '1', '4', '9']]
85 |
86 | jcbPrefixList = [['3', '5']]
87 |
88 | voyagerPrefixList = [['8', '6', '9', '9']]
89 |
90 |
91 | def completed_number(prefix, length):
92 | """
93 | 'prefix' is the start of the CC number as a string, any number of digits.
94 | 'length' is the length of the CC number to generate. Typically 13 or 16
95 | """
96 |
97 | ccnumber = prefix
98 |
99 | # generate digits
100 |
101 | while len(ccnumber) < (length - 1):
102 | digit = str(generator.choice(range(0, 10)))
103 | ccnumber.append(digit)
104 |
105 | # Calculate sum
106 |
107 | sum = 0
108 | pos = 0
109 |
110 | reversedCCnumber = []
111 | reversedCCnumber.extend(ccnumber)
112 | reversedCCnumber.reverse()
113 |
114 | while pos < length - 1:
115 |
116 | odd = int(reversedCCnumber[pos]) * 2
117 | if odd > 9:
118 | odd -= 9
119 |
120 | sum += odd
121 |
122 | if pos != (length - 2):
123 |
124 | sum += int(reversedCCnumber[pos + 1])
125 |
126 | pos += 2
127 |
128 | # Calculate check digit
129 |
130 | checkdigit = ((sum / 10 + 1) * 10 - sum) % 10
131 |
132 | ccnumber.append(str(checkdigit))
133 |
134 | return ''.join(ccnumber)
135 |
136 |
137 | def credit_card_number(rnd, prefixList, length, howMany):
138 |
139 | result = []
140 |
141 | while len(result) < howMany:
142 |
143 | ccnumber = copy.copy(rnd.choice(prefixList))
144 | result.append(completed_number(ccnumber, length))
145 |
146 | return result
147 |
148 |
149 | def output(title, numbers):
150 |
151 | result = []
152 | result.append(title)
153 | result.append('-' * len(title))
154 | result.append('\n'.join(numbers))
155 | result.append('')
156 |
157 | return '\n'.join(result)
158 |
159 | #
160 | # Main
161 | #
162 |
163 | generator = Random()
164 | generator.seed() # Seed from current time
165 |
166 | print("darkcoding credit card generator\n")
167 |
168 | mastercard = credit_card_number(generator, mastercardPrefixList, 16, 10)
169 | print(output("Mastercard", mastercard))
170 |
171 | visa16 = credit_card_number(generator, visaPrefixList, 16, 10)
172 | print(output("VISA 16 digit", visa16))
173 |
174 | visa13 = credit_card_number(generator, visaPrefixList, 13, 5)
175 | print(output("VISA 13 digit", visa13))
176 |
177 | amex = credit_card_number(generator, amexPrefixList, 15, 5)
178 | print(output("American Express", amex))
179 |
180 | # Minor cards
181 |
182 | discover = credit_card_number(generator, discoverPrefixList, 16, 3)
183 | print(output("Discover", discover))
184 |
185 | diners = credit_card_number(generator, dinersPrefixList, 14, 3)
186 | print(output("Diners Club / Carte Blanche", diners))
187 |
188 | enRoute = credit_card_number(generator, enRoutePrefixList, 15, 3)
189 | print(output("enRoute", enRoute))
190 |
191 | jcb = credit_card_number(generator, jcbPrefixList, 16, 3)
192 | print(output("JCB", jcb))
193 |
194 | voyager = credit_card_number(generator, voyagerPrefixList, 15, 3)
195 | print(output("Voyager", voyager))
196 |
--------------------------------------------------------------------------------
/RandomCreditCardNumberGenerator.java:
--------------------------------------------------------------------------------
1 | import java.util.List;
2 | import java.util.Stack;
3 | import java.util.Vector;
4 |
5 | /**
6 | * See the license below. Obviously, this is not a Javascript credit card number
7 | * generator. However, The following class is a port of a Javascript credit card
8 | * number generator.
9 | *
10 | * @author robweber
11 | *
12 | */
13 | public class RandomCreditCardNumberGenerator {
14 | /*
15 | * Javascript credit card number generator Copyright (C) 2006-2012 Graham King
16 | *
17 | * This program is free software; you can redistribute it and/or modify it
18 | * under the terms of the GNU General Public License as published by the
19 | * Free Software Foundation; either version 2 of the License, or (at your
20 | * option) any later version.
21 | *
22 | * This program is distributed in the hope that it will be useful, but
23 | * WITHOUT ANY WARRANTY; without even the implied warranty of
24 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
25 | * Public License for more details.
26 | *
27 | * You should have received a copy of the GNU General Public License along
28 | * with this program; if not, write to the Free Software Foundation, Inc.,
29 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
30 | *
31 | * www.darkcoding.net
32 | */
33 |
34 | public static final String[] VISA_PREFIX_LIST = new String[] { "4539",
35 | "4556", "4916", "4532", "4929", "40240071", "4485", "4716", "4" };
36 |
37 | public static final String[] MASTERCARD_PREFIX_LIST = new String[] { "51",
38 | "52", "53", "54", "55", "2221", "2222", "2223", "2224", "2225", "2226", "2227", "2228", "2229", "223", "224", "225", "226", "227", "228", "229", "23", "24", "25", "26", "270", "271", "2720" };
39 |
40 | public static final String[] AMEX_PREFIX_LIST = new String[] { "34", "37" };
41 |
42 | public static final String[] DISCOVER_PREFIX_LIST = new String[] { "6011" };
43 |
44 | public static final String[] DINERS_PREFIX_LIST = new String[] { "300",
45 | "301", "302", "303", "36", "38" };
46 |
47 | public static final String[] ENROUTE_PREFIX_LIST = new String[] { "2014",
48 | "2149" };
49 |
50 | public static final String[] JCB_PREFIX_LIST = new String[] { "35" };
51 |
52 | public static final String[] VOYAGER_PREFIX_LIST = new String[] { "8699" };
53 |
54 | static String strrev(String str) {
55 | if (str == null)
56 | return "";
57 | String revstr = "";
58 | for (int i = str.length() - 1; i >= 0; i--) {
59 | revstr += str.charAt(i);
60 | }
61 |
62 | return revstr;
63 | }
64 |
65 | /*
66 | * 'prefix' is the start of the CC number as a string, any number of digits.
67 | * 'length' is the length of the CC number to generate. Typically 13 or 16
68 | */
69 | static String completed_number(String prefix, int length) {
70 |
71 | String ccnumber = prefix;
72 |
73 | // generate digits
74 |
75 | while (ccnumber.length() < (length - 1)) {
76 | ccnumber += new Double(Math.floor(Math.random() * 10)).intValue();
77 | }
78 |
79 | // reverse number and convert to int
80 |
81 | String reversedCCnumberString = strrev(ccnumber);
82 |
83 | List reversedCCnumberList = new Vector();
84 | for (int i = 0; i < reversedCCnumberString.length(); i++) {
85 | reversedCCnumberList.add(new Integer(String
86 | .valueOf(reversedCCnumberString.charAt(i))));
87 | }
88 |
89 | // calculate sum
90 |
91 | int sum = 0;
92 | int pos = 0;
93 |
94 | Integer[] reversedCCnumber = reversedCCnumberList
95 | .toArray(new Integer[reversedCCnumberList.size()]);
96 | while (pos < length - 1) {
97 |
98 | int odd = reversedCCnumber[pos] * 2;
99 | if (odd > 9) {
100 | odd -= 9;
101 | }
102 |
103 | sum += odd;
104 |
105 | if (pos != (length - 2)) {
106 | sum += reversedCCnumber[pos + 1];
107 | }
108 | pos += 2;
109 | }
110 |
111 | // calculate check digit
112 |
113 | int checkdigit = new Double(
114 | ((Math.floor(sum / 10) + 1) * 10 - sum) % 10).intValue();
115 | ccnumber += checkdigit;
116 |
117 | return ccnumber;
118 |
119 | }
120 |
121 | public static String[] credit_card_number(String[] prefixList, int length,
122 | int howMany) {
123 |
124 | Stack result = new Stack();
125 | for (int i = 0; i < howMany; i++) {
126 | int randomArrayIndex = (int) Math.floor(Math.random()
127 | * prefixList.length);
128 | String ccnumber = prefixList[randomArrayIndex];
129 | result.push(completed_number(ccnumber, length));
130 | }
131 |
132 | return result.toArray(new String[result.size()]);
133 | }
134 |
135 | public static String[] generateMasterCardNumbers(int howMany) {
136 | return credit_card_number(MASTERCARD_PREFIX_LIST, 16, howMany);
137 | }
138 |
139 | public static String generateMasterCardNumber() {
140 | return credit_card_number(MASTERCARD_PREFIX_LIST, 16, 1)[0];
141 | }
142 |
143 | public static boolean isValidCreditCardNumber(String creditCardNumber) {
144 | boolean isValid = false;
145 |
146 | try {
147 | String reversedNumber = new StringBuffer(creditCardNumber)
148 | .reverse().toString();
149 | int mod10Count = 0;
150 | for (int i = 0; i < reversedNumber.length(); i++) {
151 | int augend = Integer.parseInt(String.valueOf(reversedNumber
152 | .charAt(i)));
153 | if (((i + 1) % 2) == 0) {
154 | String productString = String.valueOf(augend * 2);
155 | augend = 0;
156 | for (int j = 0; j < productString.length(); j++) {
157 | augend += Integer.parseInt(String.valueOf(productString
158 | .charAt(j)));
159 | }
160 | }
161 |
162 | mod10Count += augend;
163 | }
164 |
165 | if ((mod10Count % 10) == 0) {
166 | isValid = true;
167 | }
168 | } catch (NumberFormatException e) {
169 | }
170 |
171 | return isValid;
172 | }
173 |
174 | public static void main(String[] args) {
175 | int howMany = 0;
176 | try {
177 | howMany = Integer.parseInt(args[0]);
178 | } catch (Exception e) {
179 | System.err
180 | .println("Usage error. You need to supply a numeric argument (ex: 500000)");
181 | }
182 | String[] creditcardnumbers = generateMasterCardNumbers(howMany);
183 | for (int i = 0; i < creditcardnumbers.length; i++) {
184 | System.out.println(creditcardnumbers[i]
185 | + ":"
186 | + (isValidCreditCardNumber(creditcardnumbers[i]) ? "valid"
187 | : "invalid"));
188 | }
189 | }
190 | }
191 |
--------------------------------------------------------------------------------
/CreditCardNumberGenerator.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 |
5 | namespace CreditCardNumberGenerator
6 | {
7 | public static class RandomCreditCardNumberGenerator
8 | {
9 | /*
10 | Copy Kev Hunter's changes August 16, 2009 from from https://kevhunter.wordpress.com/2009/08/16/creating-fake-credit-card-numbers/
11 | Include comments from Zoltan siaynoq(http://en.gravatar.com/siaynoq) April 20, 2011
12 | Included in GitHub by MNF 31 May 2016.
13 | MNF 31 May 2016 Added PrefixAndLength struct and methods to generate random numbers of different types in the same call to GetCreditCardNumbers
14 |
15 | This is a port of the port of of the Javascript credit card number generator now in C#
16 | * by Kev Hunter https://kevhunter.wordpress.com
17 | * See the license below. Obviously, this is not a Javascript credit card number
18 | generator. However, The following class is a port of a Javascript credit card
19 | number generator.
20 | @author robweber
21 | Javascript credit card number generator Copyright (C) 2006 Graham King
22 | graham@darkcoding.net
23 |
24 | This program is free software; you can redistribute it and/or modify it
25 | under the terms of the GNU General Public License as published by the
26 | Free Software Foundation; either version 2 of the License, or (at your
27 | option) any later version.
28 | This program is distributed in the hope that it will be useful, but
29 | WITHOUT ANY WARRANTY; without even the implied warranty of
30 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
31 | Public License for more details.
32 |
33 | You should have received a copy of the GNU General Public License along
34 | with this program; if not, write to the Free Software Foundation, Inc.,
35 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
36 | www.darkcoding.net
37 | */
38 | /*
39 | Example of use:
40 | var random = new Random();
41 | var cardsList = random.GetCreditCardNumbers(RandomCreditCardNumberGenerator.BuildPrefixAndLengthArrayForVisaMasterCardAmex(), 10);
42 | */
43 |
44 | public static string[] AMEX_PREFIX_LIST = new[] {"34", "37"};
45 |
46 |
47 | public static string[] DINERS_PREFIX_LIST = new[]
48 | {
49 | "300",
50 | "301", "302", "303", "36", "38"
51 | };
52 |
53 |
54 | public static string[] DISCOVER_PREFIX_LIST = new[] {"6011"};
55 |
56 |
57 | public static string[] ENROUTE_PREFIX_LIST = new[]
58 | {
59 | "2014",
60 | "2149"
61 | };
62 |
63 | public static String[] JCB_PREFIX_LIST = new[]
64 | {
65 | "35"
66 | };
67 |
68 |
69 | public static string[] MASTERCARD_PREFIX_LIST = new[]
70 | {
71 | "51",
72 | "52", "53", "54", "55",
73 | "2221",
74 | "2222",
75 | "2223",
76 | "2224",
77 | "2225",
78 | "2226",
79 | "2227",
80 | "2228",
81 | "2229",
82 | "223",
83 | "224",
84 | "225",
85 | "226",
86 | "227",
87 | "228",
88 | "229",
89 | "23",
90 | "24",
91 | "25",
92 | "26",
93 | "270",
94 | "271",
95 | "2720"
96 | };
97 |
98 |
99 | public static string[] VISA_PREFIX_LIST = new[]
100 | {
101 | "4539",
102 | "4556", "4916", "4532", "4929", "40240071", "4485", "4716", "4"
103 | };
104 |
105 |
106 | public static string[] VOYAGER_PREFIX_LIST = new[] {"8699"};
107 |
108 | public struct PrefixAndLength
109 | {
110 | public PrefixAndLength(string prefix, int length)
111 | {
112 | Prefix = prefix;
113 | Length = length;
114 | }
115 | public string Prefix { get; set; }
116 | public int Length { get; set; }
117 | }
118 |
119 | public static IEnumerable BuildPrefixAndLengthList(string[] prefixList, int length)
120 | {
121 | var list=from p in prefixList select new PrefixAndLength(p, length);
122 | return list;
123 | }
124 | ///
125 | /// This is an example how BuildPrefixAndLengthList can be used
126 | ///
127 | ///
128 | public static PrefixAndLength[] BuildPrefixAndLengthArrayForVisaMasterCardAmex()
129 | {
130 | var list=BuildPrefixAndLengthList(VISA_PREFIX_LIST, 16)
131 | .Union(BuildPrefixAndLengthList(MASTERCARD_PREFIX_LIST, 16))
132 | .Union(BuildPrefixAndLengthList(AMEX_PREFIX_LIST, 15))
133 | ;
134 | return list.ToArray();
135 | }
136 | ///
137 | /// Better to use extension overload with [this Random random] paramenter. See http://stackoverflow.com/questions/2706500/how-do-i-generate-a-random-int-number-in-c
138 | ///
139 | ///
140 | ///
141 | ///
142 | public static IEnumerable GetCreditCardNumbers(PrefixAndLength[] prefixAndLengthList,
143 | int howMany)
144 | {
145 | Random rndGen = new Random();
146 | return GetCreditCardNumbers(rndGen, prefixAndLengthList, howMany);
147 | }
148 |
149 | public static IEnumerable GetCreditCardNumbers(this Random random, PrefixAndLength[] prefixAndLengthList, int howMany)
150 | {
151 | var result = new Stack();
152 | for (int i = 0; i < howMany; i++)
153 | {
154 | int randomPrefix = random.Next(0, prefixAndLengthList.Length - 1);
155 |
156 | var prefixAndLength = prefixAndLengthList[randomPrefix];
157 |
158 | result.Push(CreateFakeCreditCardNumber(random, prefixAndLength.Prefix, prefixAndLength.Length));
159 | }
160 |
161 | return result;
162 | }
163 |
164 | /*
165 | 'prefix' is the start of the CC number as a string, any number
166 | private of digits 'length' is the length of the CC number to generate.
167 | * Typically 13 or 16
168 | */
169 | private static string CreateFakeCreditCardNumber(this Random random, string prefix, int length)
170 | {
171 | string ccnumber = prefix;
172 | while (ccnumber.Length < (length - 1))
173 | {
174 | double rnd = (random.NextDouble()*1.0f - 0f);
175 |
176 | ccnumber += Math.Floor(rnd*10);
177 | }
178 |
179 |
180 | // reverse number and convert to int
181 | var reversedCCnumberstring = ccnumber.ToCharArray().Reverse();
182 |
183 | var reversedCCnumberList = reversedCCnumberstring.Select(c => Convert.ToInt32(c.ToString()));
184 |
185 | // calculate sum //Luhn Algorithm http://en.wikipedia.org/wiki/Luhn_algorithm
186 | int sum = 0;
187 | int pos = 0;
188 | int[] reversedCCnumber = reversedCCnumberList.ToArray();
189 |
190 | while (pos < length - 1)
191 | {
192 | int odd = reversedCCnumber[pos]*2;
193 |
194 | if (odd > 9)
195 | odd -= 9;
196 |
197 | sum += odd;
198 |
199 | if (pos != (length - 2))
200 | sum += reversedCCnumber[pos + 1];
201 |
202 | pos += 2;
203 | }
204 |
205 | // calculate check digit
206 | int checkdigit =
207 | Convert.ToInt32((Math.Floor((decimal) sum/10) + 1)*10 - sum)%10;
208 |
209 | ccnumber += checkdigit;
210 |
211 | return ccnumber;
212 | }
213 |
214 |
215 | public static IEnumerable GetCreditCardNumbers(string[] prefixList, int length,
216 | int howMany)
217 | {
218 | var result = new Stack();
219 | var random = new Random();
220 | for (int i = 0; i < howMany; i++)
221 | {
222 | int randomPrefix = random.Next(0, prefixList.Length - 1);
223 |
224 | if(randomPrefix>1) //Why??, is it a bug ? it never will select last element
225 | {
226 | randomPrefix--;
227 | }
228 |
229 | string ccnumber = prefixList[randomPrefix];
230 |
231 | result.Push(CreateFakeCreditCardNumber(random, ccnumber, length));
232 | }
233 |
234 | return result;
235 | }
236 |
237 |
238 | public static IEnumerable GenerateMasterCardNumbers(int howMany)
239 | {
240 | return GetCreditCardNumbers(MASTERCARD_PREFIX_LIST, 16, howMany);
241 | }
242 |
243 |
244 | public static string GenerateMasterCardNumber()
245 | {
246 | return GetCreditCardNumbers(MASTERCARD_PREFIX_LIST, 16, 1).First();
247 | }
248 |
249 | public static bool IsValidCreditCardNumber(string creditCardNumber)
250 | {
251 | try
252 | {
253 | var reversedNumber = creditCardNumber.ToCharArray().Reverse();
254 |
255 | int mod10Count = 0;
256 | for (int i = 0; i < reversedNumber.Count(); i++)
257 | {
258 | int augend = Convert.ToInt32(reversedNumber.ElementAt(i).ToString());
259 |
260 | if (((i + 1)%2) == 0)
261 | {
262 | string productstring = (augend*2).ToString();
263 | augend = 0;
264 | for (int j = 0; j < productstring.Length; j++)
265 | {
266 | augend += Convert.ToInt32(productstring.ElementAt(j).ToString());
267 | }
268 | }
269 | mod10Count += augend;
270 | }
271 |
272 | if ((mod10Count%10) == 0)
273 | {
274 | return true;
275 | }
276 | }
277 | catch
278 | {
279 | return false;
280 | }
281 | return false;
282 | }
283 | }
284 | }
285 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 2, June 1991
3 |
4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6 | Everyone is permitted to copy and distribute verbatim copies
7 | of this license document, but changing it is not allowed.
8 |
9 | Preamble
10 |
11 | The licenses for most software are designed to take away your
12 | freedom to share and change it. By contrast, the GNU General Public
13 | License is intended to guarantee your freedom to share and change free
14 | software--to make sure the software is free for all its users. This
15 | General Public License applies to most of the Free Software
16 | Foundation's software and to any other program whose authors commit to
17 | using it. (Some other Free Software Foundation software is covered by
18 | the GNU Lesser General Public License instead.) You can apply it to
19 | your programs, too.
20 |
21 | When we speak of free software, we are referring to freedom, not
22 | price. Our General Public Licenses are designed to make sure that you
23 | have the freedom to distribute copies of free software (and charge for
24 | this service if you wish), that you receive source code or can get it
25 | if you want it, that you can change the software or use pieces of it
26 | in new free programs; and that you know you can do these things.
27 |
28 | To protect your rights, we need to make restrictions that forbid
29 | anyone to deny you these rights or to ask you to surrender the rights.
30 | These restrictions translate to certain responsibilities for you if you
31 | distribute copies of the software, or if you modify it.
32 |
33 | For example, if you distribute copies of such a program, whether
34 | gratis or for a fee, you must give the recipients all the rights that
35 | you have. You must make sure that they, too, receive or can get the
36 | source code. And you must show them these terms so they know their
37 | rights.
38 |
39 | We protect your rights with two steps: (1) copyright the software, and
40 | (2) offer you this license which gives you legal permission to copy,
41 | distribute and/or modify the software.
42 |
43 | Also, for each author's protection and ours, we want to make certain
44 | that everyone understands that there is no warranty for this free
45 | software. If the software is modified by someone else and passed on, we
46 | want its recipients to know that what they have is not the original, so
47 | that any problems introduced by others will not reflect on the original
48 | authors' reputations.
49 |
50 | Finally, any free program is threatened constantly by software
51 | patents. We wish to avoid the danger that redistributors of a free
52 | program will individually obtain patent licenses, in effect making the
53 | program proprietary. To prevent this, we have made it clear that any
54 | patent must be licensed for everyone's free use or not licensed at all.
55 |
56 | The precise terms and conditions for copying, distribution and
57 | modification follow.
58 |
59 | GNU GENERAL PUBLIC LICENSE
60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61 |
62 | 0. This License applies to any program or other work which contains
63 | a notice placed by the copyright holder saying it may be distributed
64 | under the terms of this General Public License. The "Program", below,
65 | refers to any such program or work, and a "work based on the Program"
66 | means either the Program or any derivative work under copyright law:
67 | that is to say, a work containing the Program or a portion of it,
68 | either verbatim or with modifications and/or translated into another
69 | language. (Hereinafter, translation is included without limitation in
70 | the term "modification".) Each licensee is addressed as "you".
71 |
72 | Activities other than copying, distribution and modification are not
73 | covered by this License; they are outside its scope. The act of
74 | running the Program is not restricted, and the output from the Program
75 | is covered only if its contents constitute a work based on the
76 | Program (independent of having been made by running the Program).
77 | Whether that is true depends on what the Program does.
78 |
79 | 1. You may copy and distribute verbatim copies of the Program's
80 | source code as you receive it, in any medium, provided that you
81 | conspicuously and appropriately publish on each copy an appropriate
82 | copyright notice and disclaimer of warranty; keep intact all the
83 | notices that refer to this License and to the absence of any warranty;
84 | and give any other recipients of the Program a copy of this License
85 | along with the Program.
86 |
87 | You may charge a fee for the physical act of transferring a copy, and
88 | you may at your option offer warranty protection in exchange for a fee.
89 |
90 | 2. You may modify your copy or copies of the Program or any portion
91 | of it, thus forming a work based on the Program, and copy and
92 | distribute such modifications or work under the terms of Section 1
93 | above, provided that you also meet all of these conditions:
94 |
95 | a) You must cause the modified files to carry prominent notices
96 | stating that you changed the files and the date of any change.
97 |
98 | b) You must cause any work that you distribute or publish, that in
99 | whole or in part contains or is derived from the Program or any
100 | part thereof, to be licensed as a whole at no charge to all third
101 | parties under the terms of this License.
102 |
103 | c) If the modified program normally reads commands interactively
104 | when run, you must cause it, when started running for such
105 | interactive use in the most ordinary way, to print or display an
106 | announcement including an appropriate copyright notice and a
107 | notice that there is no warranty (or else, saying that you provide
108 | a warranty) and that users may redistribute the program under
109 | these conditions, and telling the user how to view a copy of this
110 | License. (Exception: if the Program itself is interactive but
111 | does not normally print such an announcement, your work based on
112 | the Program is not required to print an announcement.)
113 |
114 | These requirements apply to the modified work as a whole. If
115 | identifiable sections of that work are not derived from the Program,
116 | and can be reasonably considered independent and separate works in
117 | themselves, then this License, and its terms, do not apply to those
118 | sections when you distribute them as separate works. But when you
119 | distribute the same sections as part of a whole which is a work based
120 | on the Program, the distribution of the whole must be on the terms of
121 | this License, whose permissions for other licensees extend to the
122 | entire whole, and thus to each and every part regardless of who wrote it.
123 |
124 | Thus, it is not the intent of this section to claim rights or contest
125 | your rights to work written entirely by you; rather, the intent is to
126 | exercise the right to control the distribution of derivative or
127 | collective works based on the Program.
128 |
129 | In addition, mere aggregation of another work not based on the Program
130 | with the Program (or with a work based on the Program) on a volume of
131 | a storage or distribution medium does not bring the other work under
132 | the scope of this License.
133 |
134 | 3. You may copy and distribute the Program (or a work based on it,
135 | under Section 2) in object code or executable form under the terms of
136 | Sections 1 and 2 above provided that you also do one of the following:
137 |
138 | a) Accompany it with the complete corresponding machine-readable
139 | source code, which must be distributed under the terms of Sections
140 | 1 and 2 above on a medium customarily used for software interchange; or,
141 |
142 | b) Accompany it with a written offer, valid for at least three
143 | years, to give any third party, for a charge no more than your
144 | cost of physically performing source distribution, a complete
145 | machine-readable copy of the corresponding source code, to be
146 | distributed under the terms of Sections 1 and 2 above on a medium
147 | customarily used for software interchange; or,
148 |
149 | c) Accompany it with the information you received as to the offer
150 | to distribute corresponding source code. (This alternative is
151 | allowed only for noncommercial distribution and only if you
152 | received the program in object code or executable form with such
153 | an offer, in accord with Subsection b above.)
154 |
155 | The source code for a work means the preferred form of the work for
156 | making modifications to it. For an executable work, complete source
157 | code means all the source code for all modules it contains, plus any
158 | associated interface definition files, plus the scripts used to
159 | control compilation and installation of the executable. However, as a
160 | special exception, the source code distributed need not include
161 | anything that is normally distributed (in either source or binary
162 | form) with the major components (compiler, kernel, and so on) of the
163 | operating system on which the executable runs, unless that component
164 | itself accompanies the executable.
165 |
166 | If distribution of executable or object code is made by offering
167 | access to copy from a designated place, then offering equivalent
168 | access to copy the source code from the same place counts as
169 | distribution of the source code, even though third parties are not
170 | compelled to copy the source along with the object code.
171 |
172 | 4. You may not copy, modify, sublicense, or distribute the Program
173 | except as expressly provided under this License. Any attempt
174 | otherwise to copy, modify, sublicense or distribute the Program is
175 | void, and will automatically terminate your rights under this License.
176 | However, parties who have received copies, or rights, from you under
177 | this License will not have their licenses terminated so long as such
178 | parties remain in full compliance.
179 |
180 | 5. You are not required to accept this License, since you have not
181 | signed it. However, nothing else grants you permission to modify or
182 | distribute the Program or its derivative works. These actions are
183 | prohibited by law if you do not accept this License. Therefore, by
184 | modifying or distributing the Program (or any work based on the
185 | Program), you indicate your acceptance of this License to do so, and
186 | all its terms and conditions for copying, distributing or modifying
187 | the Program or works based on it.
188 |
189 | 6. Each time you redistribute the Program (or any work based on the
190 | Program), the recipient automatically receives a license from the
191 | original licensor to copy, distribute or modify the Program subject to
192 | these terms and conditions. You may not impose any further
193 | restrictions on the recipients' exercise of the rights granted herein.
194 | You are not responsible for enforcing compliance by third parties to
195 | this License.
196 |
197 | 7. If, as a consequence of a court judgment or allegation of patent
198 | infringement or for any other reason (not limited to patent issues),
199 | conditions are imposed on you (whether by court order, agreement or
200 | otherwise) that contradict the conditions of this License, they do not
201 | excuse you from the conditions of this License. If you cannot
202 | distribute so as to satisfy simultaneously your obligations under this
203 | License and any other pertinent obligations, then as a consequence you
204 | may not distribute the Program at all. For example, if a patent
205 | license would not permit royalty-free redistribution of the Program by
206 | all those who receive copies directly or indirectly through you, then
207 | the only way you could satisfy both it and this License would be to
208 | refrain entirely from distribution of the Program.
209 |
210 | If any portion of this section is held invalid or unenforceable under
211 | any particular circumstance, the balance of the section is intended to
212 | apply and the section as a whole is intended to apply in other
213 | circumstances.
214 |
215 | It is not the purpose of this section to induce you to infringe any
216 | patents or other property right claims or to contest validity of any
217 | such claims; this section has the sole purpose of protecting the
218 | integrity of the free software distribution system, which is
219 | implemented by public license practices. Many people have made
220 | generous contributions to the wide range of software distributed
221 | through that system in reliance on consistent application of that
222 | system; it is up to the author/donor to decide if he or she is willing
223 | to distribute software through any other system and a licensee cannot
224 | impose that choice.
225 |
226 | This section is intended to make thoroughly clear what is believed to
227 | be a consequence of the rest of this License.
228 |
229 | 8. If the distribution and/or use of the Program is restricted in
230 | certain countries either by patents or by copyrighted interfaces, the
231 | original copyright holder who places the Program under this License
232 | may add an explicit geographical distribution limitation excluding
233 | those countries, so that distribution is permitted only in or among
234 | countries not thus excluded. In such case, this License incorporates
235 | the limitation as if written in the body of this License.
236 |
237 | 9. The Free Software Foundation may publish revised and/or new versions
238 | of the General Public License from time to time. Such new versions will
239 | be similar in spirit to the present version, but may differ in detail to
240 | address new problems or concerns.
241 |
242 | Each version is given a distinguishing version number. If the Program
243 | specifies a version number of this License which applies to it and "any
244 | later version", you have the option of following the terms and conditions
245 | either of that version or of any later version published by the Free
246 | Software Foundation. If the Program does not specify a version number of
247 | this License, you may choose any version ever published by the Free Software
248 | Foundation.
249 |
250 | 10. If you wish to incorporate parts of the Program into other free
251 | programs whose distribution conditions are different, write to the author
252 | to ask for permission. For software which is copyrighted by the Free
253 | Software Foundation, write to the Free Software Foundation; we sometimes
254 | make exceptions for this. Our decision will be guided by the two goals
255 | of preserving the free status of all derivatives of our free software and
256 | of promoting the sharing and reuse of software generally.
257 |
258 | NO WARRANTY
259 |
260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268 | REPAIR OR CORRECTION.
269 |
270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278 | POSSIBILITY OF SUCH DAMAGES.
279 |
280 | END OF TERMS AND CONDITIONS
281 |
282 | How to Apply These Terms to Your New Programs
283 |
284 | If you develop a new program, and you want it to be of the greatest
285 | possible use to the public, the best way to achieve this is to make it
286 | free software which everyone can redistribute and change under these terms.
287 |
288 | To do so, attach the following notices to the program. It is safest
289 | to attach them to the start of each source file to most effectively
290 | convey the exclusion of warranty; and each file should have at least
291 | the "copyright" line and a pointer to where the full notice is found.
292 |
293 |
294 | Copyright (C)
295 |
296 | This program is free software; you can redistribute it and/or modify
297 | it under the terms of the GNU General Public License as published by
298 | the Free Software Foundation; either version 2 of the License, or
299 | (at your option) any later version.
300 |
301 | This program is distributed in the hope that it will be useful,
302 | but WITHOUT ANY WARRANTY; without even the implied warranty of
303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304 | GNU General Public License for more details.
305 |
306 | You should have received a copy of the GNU General Public License along
307 | with this program; if not, write to the Free Software Foundation, Inc.,
308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309 |
310 | Also add information on how to contact you by electronic and paper mail.
311 |
312 | If the program is interactive, make it output a short notice like this
313 | when it starts in an interactive mode:
314 |
315 | Gnomovision version 69, Copyright (C) year name of author
316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317 | This is free software, and you are welcome to redistribute it
318 | under certain conditions; type `show c' for details.
319 |
320 | The hypothetical commands `show w' and `show c' should show the appropriate
321 | parts of the General Public License. Of course, the commands you use may
322 | be called something other than `show w' and `show c'; they could even be
323 | mouse-clicks or menu items--whatever suits your program.
324 |
325 | You should also get your employer (if you work as a programmer) or your
326 | school, if any, to sign a "copyright disclaimer" for the program, if
327 | necessary. Here is a sample; alter the names:
328 |
329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330 | `Gnomovision' (which makes passes at compilers) written by James Hacker.
331 |
332 | , 1 April 1989
333 | Ty Coon, President of Vice
334 |
335 | This General Public License does not permit incorporating your program into
336 | proprietary programs. If your program is a subroutine library, you may
337 | consider it more useful to permit linking proprietary applications with the
338 | library. If this is what you want to do, use the GNU Lesser General
339 | Public License instead of this License.
340 |
--------------------------------------------------------------------------------