更新时间:2023-11-29 12:50:10
更新
6月25日,2011年,SSA改变了SSN分配过程为SSN随机化[27] SSN随机影响SSN分配过程在以下几个方面:
有消除了SSN,previously称为区域号码,通过不再分配区号码的分配,以在特定状态的个体的前三位的地理意义。 它消除的最高组号码的意义,并且作为结果,高组列表被冻结在时间和可用于随机化实施日期之前发放的SSN的验证。 previously未分配的区域号码目前已经提出了分配不包括区号000,666和900-999。
新规则
http://en.wikipedia.org/wiki/Social_Security_number#Structure
previous答案
下面是一个SSN的妆最完整的描述我发现。
Anyone out there know how to improve this function? I'm not worried about shortening the code, I'm sure this could be done with better regex, I am more concerned about correct logic. I have had a terrible time finding documentation for SSN #'s. Most of the rules I use below have come from other programmers who work in the credit industry (no sources cited).
Thanks for any insight!
public static bool isSSN(string ssn)
{
Regex rxBadSSN = new Regex(@"(\d)\1\1\1\1\1\1\1\1");
//Must be 9 bytes
if(ssn.Trim().Length != 9)
return false;
//Must be numeric
if(!isNumeric(ssn))
return false;
//Must be less than 772999999
if( (Int32)Double.Parse(ssn.Substring(0,3)) > 772 )
{
//Check for Green Card Temp SSN holders
// Could be 900700000
// 900800000
if(ssn.Substring(0,1) != "9")
return false;
if(ssn.Substring(3,1) != "7" && ssn.Substring(3,1) != "8")
return false;
}
//Obviously Fake!
if(ssn == "123456789")
return false;
//Try again!
if(ssn == "123121234")
return false;
//No single group can have all zeros
if(ssn.Substring(0,3) == "000")
return false;
if(ssn.Substring(3,2) == "00")
return false;
if(ssn.Substring(5,4) == "0000")
return false;
//Check to make sure the SSN number is not repeating
if (rxBadSSN.IsMatch(ssn))
return false;
return true;
}
UPDATE
On June 25, 2011, the SSA changed the SSN assignment process to "SSN randomization".[27] SSN randomization affects the SSN assignment process in the following ways:
It eliminates the geographical significance of the first three digits of the SSN, previously referred to as the Area Number, by no longer allocating the Area Numbers for assignment to individuals in specific states. It eliminates the significance of the highest Group Number and, as a result, the High Group List is frozen in time and can be used for validation of SSNs issued prior to the randomization implementation date. Previously unassigned Area Numbers have been introduced for assignment excluding Area Numbers 000, 666 and 900–999.
New Rules
http://en.wikipedia.org/wiki/Social_Security_number#Structure
Previous Answer
Here's the most-complete description of the makeup of an SSN that I have found.