<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Wilson Reddy</title>
    <description>The latest articles on DEV Community by Wilson Reddy (@wilsonreddy).</description>
    <link>https://dev.to/wilsonreddy</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F726209%2F6d73b663-5f5b-430e-8295-3d55c7017eab.jpg</url>
      <title>DEV Community: Wilson Reddy</title>
      <link>https://dev.to/wilsonreddy</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/wilsonreddy"/>
    <language>en</language>
    <item>
      <title>Credit Card Generator in Python (All Code)</title>
      <dc:creator>Wilson Reddy</dc:creator>
      <pubDate>Fri, 15 Oct 2021 07:20:11 +0000</pubDate>
      <link>https://dev.to/wilsonreddy/credit-card-generator-in-python-all-code-1n6l</link>
      <guid>https://dev.to/wilsonreddy/credit-card-generator-in-python-all-code-1n6l</guid>
      <description>&lt;p&gt;If you just need a bunch of numbers use the &lt;a href="https://www.cardgenerators.org"&gt;online credit card number generator&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Python, Java, C#, PHP and Javascript programs to generate valid credit card numbers (MOD 10). Useful for testing payment systems. This generates VISA, Mastercard, Amex, and a whole bunch of others.&lt;/p&gt;

&lt;p&gt;The Luhn algorithm, also known as the "modulus 10" algorithm, is a checksum formula used to validate a variety of identification numbers, such as credit card numbers, IMEI numbers, National Provider Identifier numbers in the United States, Canadian Social Insurance Numbers, and Israel ID Numbers.&lt;/p&gt;

&lt;p&gt;Algorithm:&lt;/p&gt;

&lt;p&gt;The formula verifies a number against its included check digit, which is usually appended to a partial account number to generate the full account number.&lt;/p&gt;

&lt;p&gt;Generating check digit:&lt;/p&gt;

&lt;p&gt;Lets assume you have a number as: 3 - 7 - 5 - 6 - 2 - 1 - 9 - 8 - 6 - 7 - X where X is the check digit.&lt;br&gt;
Now starting from the rightmost digit i.e. check digit, double every second digit. New number will be: 3 - 14 - 5 - 12 - 2 - 2 - 9 - 16 - 6 - 14 - X&lt;br&gt;
Now if double of a digit is more then 9, add the digits. So the number will become: 3 - 5 - 5 - 3 - 2 - 2 - 9 - 7 - 6 - 5 - X&lt;br&gt;
Now add all digits. 47 + X&lt;br&gt;
Multiply the non-check part by 9. So it will be 47 * 9 = 423&lt;br&gt;
The unit digit in the multiplication result is the check digit. X = 3&lt;br&gt;
The valid number would be 37562198673.&lt;br&gt;
Validating the generated number:&lt;br&gt;
You can use tools available online to validate that the number generated is valid as per Luhn's algorithm or not. You can validate the number by visiting this site.&lt;/p&gt;

&lt;p&gt;from random import randint&lt;/p&gt;

&lt;p&gt;cc_number = []&lt;br&gt;
multiplied_by_two = []&lt;br&gt;
remaining_numbers = []&lt;br&gt;
new_number = ''&lt;/p&gt;

&lt;h1&gt;
  
  
  Ask for a first 15 digits of a card
&lt;/h1&gt;

&lt;p&gt;starting_15 = input('Enter first 15 digits: ')&lt;/p&gt;

&lt;p&gt;z = 0&lt;br&gt;
y = 0&lt;/p&gt;

&lt;p&gt;while z &amp;lt; 25:&lt;br&gt;
    for i in str(starting_15):&lt;br&gt;
        cc_number.append(int(i))&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# extract all the numbers that have to be multiplied by 2
for i in cc_number[0:16:2]:
    i *= 2
    if len(str(i)) == 2:        # check if the multiplied number is a two digit number
        for x in str(i):        # if it is, separate them, and add them together
            y += int(str(x))
        i = y
    multiplied_by_two.append(i)
    y = 0

for i in cc_number[1:15:2]:     # extract remaining numbers
    remaining_numbers.append(i)

# Luhn's algorithm
last_digit = ((sum(multiplied_by_two) + sum(remaining_numbers)) * 9) % 10

for i in cc_number:
    new_number += str(i)

print(new_number + str(last_digit))
cc_number = []
multiplied_by_two = []
remaining_numbers = []
new_number = ''

starting_15 = int(starting_15) + randint(-15, 25)
z += 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
    </item>
  </channel>
</rss>
