Luhn's Algorythm

Description

This script shows an implementation of Luhn's algorythm, which you probably haven't heard of unless you have ever looked into credit card authentication. Put simply it is a mathamatical expression that lets you determine whether or not any given sequence, which in theory should conform to it, returns a valid result.

To put it in more practical terms, you can let a someone enter their card number on your site and do a very simple quick check to make sure that they haven't mis-typed their number before sending them off on what may be a slow (and potentially wasted) trip to your external credit card processor. This isn't a full card authentication - it simply allow you to check that what was entered at least looks right so that is one less thing that can go wrong when the number is properly authenticated.

I wrote this because I read about it one day and wondered how it worked, soon after this script was born. The main feature is a form which you can enter your number into, click a link and it will tell you if the number was valid or not.

In addition to the checking function it also seemed trivial to reverse the process and create a correction function which simply takes a wrong number and makes it look right. This is simply a feature I thought was interesting and which I have left in simply because it was so trivial to write, meaning that most people could write it too, this also just goes to show you how easy it is to generate a technically valid credit card number using known sequences and a few random numbers. Doubtlessly if you wanted this for some nefarious purpose you would be able to find a much more useful version out on the web already since Luhn is public knowledge and has been around and documented for a long time.

Requirements

Single Compressed Download

Individual Components

  1. Source code

Installation & Setup

  1. Save the source code file into a directory somewhere within your webroot, naming it code.asp.

User Guide

First of all let us start with a very simple example of how this script works. Browse to the script, get out your Visa card (or any similar card with a 16 digit sequence on the face) and key that sequence into the form. Don't worry the number is only going between you and the script and then being forgotten - you have the source so you can quite easily check for yourself if you really feel the need to!

Submit the form - it should say "valid" since what you keyed in is indeed the number from a credit card and so that is a correct number, now change the last digit and try again - it should say "invalid" but then offer you the corrected number by means of the validation method, but this time in reverse.
Evolved
Code
ASP, SQL & VB meet the internet.

Navigate

Home Parent Directory Meta-Search

Technical

ASP Scripts SQL Scripts VB Programs Show All

Guides

Show All

Other

Contact Site News About Legal Sitemap Links