Legality check of "China Citizen ID Card Number" and "China Unified Social Credit Code for Legal Persons and Other Organizations"
中文 | English
A go package for verify the ID card number and the unified social credit code of legal persons and other organizations.
Calculation rules refer to national standard documents:
-
GB 11643-1999: China citizen identification number
-
GB 32100-2015: The coding rule of the unified social credit identifier for legal entities and other organizations
Note: Due to the earlier implementation of the “Unified Social Credit Code for Legal Persons and Other Organizations” in some pilot areas of China, some code may not meet national standards, But they are all rightful code and should be handled separately. For example:
福建恒跃柳工机械销售有限公司:
91350100M0001TGQXM
The calculated check digit is1
andM
does not match厦门云上晴空航空科技有限公司:
91350211M0000XUF46
The calculated check digit isR
and6
does not match.厦门黑脉网络科技有限公司:
91350203M0001FUE2P
The calculated check digit isJ
and P dos not match.
go get github.com/bluesky335/IDCheck
- Unified social credit code for legal persons and other organizations
import "github.com/bluesky335/IDCheck/USCI"
var usci = USCI.New("91350100M000100Y43")
if usci.IsValid() {
fmt.Printf("✅\n")
} else {
fmt.Printf("❌\n")
}
- identification number
import "github.com/bluesky335/IDCheck/IdNumber"
var id = IdNumber.New("11010519491231002X")
if id.IsValid() {
fmt.Printf("%s -> %s\n", id, "✅")
} else {
fmt.Printf("%s -> %s\n", id, "❌")
}
var birthday = id.GetBirthday()
if birthday != nil {
fmt.Printf("Birthday:%s-%s-%s\n", birthday.Year, birthday.Month, birthday.Day)
} else {
// invalid ID card number
}
var gender = id.GetGender()
if gender != -1 {
genderMap := map[Gender]string{
Female: "Female",
Male: "Male",
}
fmt.Printf("Gender:%s\n", genderMap[gender])
} else {
// invalid ID card number
}
// Generate a random ID number that conforms to the verification rules. Although it complies with the verification rules, it does not necessarily exist.
randomIDCard := IdNumber.Random()
fmt.Printf("random ID number:%s\n", randomIDCard)
ChrisDowney1996 validators