Author: Dan Mares, dmares @ maresware . com (you will be asked for e-mail address confirmation)
Portions Copyright 2005-2014 by Mares and Company, LLC
Phone: (770)242-6687 X 119
Last update: August 12, 2011



Determine if an SSN is valid and has been issued. THIS PROGRAM DOES NOT PROVIDE THE ISSUE YEAR FOR AN SSN. Beginning sometime in 2011, Social Security numbers will not be issued with the traditional state/group number sequences. This will make it harder to verify a valid number. However, a realistic assumption can be made that a social security number of a person over a few years of age, had a number issued via the old(er) algorith which this program abides by.

The program take either manual input from the user, or a file containing SSN's and attempts to validate if the SSN has been issued, and in which state it was most likely issued.

To perform the validation, it uses a number of tables referenced on the Social Security web site. These tables are frequently updated on the website, and as such, the program may not have the most current ones implemented.

There is an option (-g) which will allow the user to point to a more recent "group" file. This file can be downloaded from the Social Security web site, but requires a special format. (described below).

As of June 2011, the program will also take a list of credit card number and attempt to verify that the number complies with the correct algorithm and issuing company. It will process either a single command line number, or a file containing numbers as the first field.



The program takes an SSN (wheter input manually, or in a text file provided by the user), and splits it into its three components.

Since June 2011 the Social Security administration is using a "random" generation algorithm. see explanaion here
to assign numbers. This means that the state identification (first three digits) is no longer valid. For this reason, the program display of the state of issue will be invalid if the number was issued after Aug. 2011. It may also misinterpret the validity of the number. So BE WARNED.

The Social Security number consists of nine (9) digits. The first three (3) digits denote the area (or State) where the application for an original Social Security number was filed.

Within each area, the group number (middle two (2) digits) range from 01 to 99 but are not assigned in consecutive order. For administrative reasons, group numbers issued first consist of the ODD numbers from 01 through 09 and then EVEN numbers from 10 through 98, within each area number allocated to a State. After all numbers in group 98 of a particular area have been issued, the EVEN Groups 02 through 08 are used, followed by ODD Groups 11 through 99.

This chart below shows how Group numbers are assigned:

ODD - 01, 03, 05, 07, 09 

EVEN - 10 to 98

EVEN - 02, 04, 06, 08 

ODD - 11 to 99

Within each group, the serial numbers (last four (4) digits) run consecutively from 0001 through 9999.

After the SSN is split, the state or area is checked. to determine what state has issuing authority for that number.

Then it checks to see that the group number is valid for that state. This chart is constantly changing, and as a result, if the program determines that the SSN is invalid, it might be wise for the user to manually confirm at ( the recent issuance of any particular number. Current group values can be downloaded from this site, and input to the program using the -g option. (see below).

If the state and group numbers are found to be valid, then the last check is to see if the last 4 digits are valid. Usually all are deemed valid, unless the group number is the same as the highest current group. In this case, it is possible that all the numbers for that group have not yet been issued. This is the case where the user should manually check the validity of the SSN, using the website shown above. (If this is the case, the user will see the word CONFIRM in the output line to indicate that the 4 digits may part of the current highest group value).

If all the tests are passed, the output indicates a valid SSN, if the tests fail, the output indicates an invalid SSN.

In all instances the output results should only be considered an estimate based on the current tables (highest group, and state issued) built into the program, and should not be 100% relied upon unless checked by other means.


Credit Card Numbers

The program can take a list or single credit card number (properly formed) and attempt to show if it is a valid number (based on an appropriate algorithm), and/or display the issuing authority, IE: AMEX, VISA, MC, Discover, etc.

If the number calculates to a number from one of the companies, but calculates to an invalid number, then a value of (_X) is added to the name in the output. This syntax will become evident when the program is run.



-?:  Get a help screen.

-i + ssnfilename:  Filename containing SSN's to check. The format of this file should be a plain text file with the SSN's one per line. They should be formatted as: 123-45-6789. The (-) delimeter can be any seperator except a space. There doesn't need to be a delimeter, and the SSN's can be in the form of 123456789 also. But the requirement of one per line is mandatory, and no header or footer lines, and no leading spaces on the lines.


-C: The numbers provided are credit card numbers, and attempt to treat them accordingly. The default is to assume they are SSN's

-g + groupfilename:  A file, with informatin from containing the most current highest group values. The file should be a text file, with nothing in it except the group table itself. The headers and footers should be eliminated. (Cut and past from the above mentioned page, and create a plain text file as:

001 02  002 02	003 98  004 06  005 06  006 04
007 04  008 88	009 86  010 88  011 88  012 88
013 88  014 88	015 88  016 88  017 88  018 88
019 88  020 88	021 86  022 86  023 86  024 86
025 86  026 86	027 86  028 86  029 86  030 86
031 86  032 86	033 86  034 86  035 70  036 70
037 70  038 70	039 68  040 08  041 08  042 06
043 06  044 06	045 06  046 06  047 06  048 06
The program has a built in group list, but it may not be the latest. The only problem the user will have in not using the latest highest list, is that some (most recent issued) numbers will inadvertenly be identified as invalid. Necessitating a manual check.



Command lines can take one of three formats:

nothing is put on the command line. The program interacts with the user, and asks for SSN's. The user inputs one ssn at a time, and obtains a result. To end the program, the user enters a blank line when asked for the ssn.

ssn_valid 123-45-6789
an explicit SSN is provided on the command line. a single check is made, and the program exits.

ssn_valid -i ssns.txt
the user inputs an input file containing the list of ssn's to check. The program outputs the results to the screen. The output can be redirected to an output file > outputfile.    (ssn_valid -i ssns.txt > outputfile).

The format for all the outputs is a single line text output with the following fields.

1. the literal SSN:
2. the SSN begin checked
3. the state of issue
4. the word VALID=
5. the word, YES or NO (indicating a valid or invalid SSN)
6. (optional word CONFIRM, if this SSN may have been issued since the last group update information.

SSN: 001-02-1234   New Hampshire         VALID=YES  CONFIRM
SSN: 001-10-1234   New Hampshire         VALID=YES
SSN: 001-11-1234   New Hampshire         VALID=NO
SSN: 005-02-1234   Maine                 VALID=YES
SSN: 005-06-1234   Maine                 VALID=YES  CONFIRM
SSN: 005-11-1234   Maine                 VALID=NO
SSN: 014-02-1234   Massachusetts         VALID=NO
SSN: 368-31-1234   Michigan              VALID=YES  CONFIRM
SSN: 368-02-1234   Michigan              VALID=YES
SSN: 368-97-1234   Michigan              VALID=NO