chinese-idcard-generator
v1.1.3
Published
一个中国居民身份证校验码生成器
Downloads
16
Maintainers
Readme
获取身份证信息
安装:
npm install chinese-idcard-generator
API
var card = require('chinese-idcard-generator');
/**
* param:chinese-idcard-generator(string)
* return boolean
*/
card.verify('511902200910140013');//false
var card = require('chinese-idcard-generator');
/**
* param:chinese-idcard-generator(string)
* return object
*/
card.info('511902200910140010');
返回结果:
//身份证合法时返回的数据结构
{
valid: true,//身份证是否合法的标志
gender: 'Male',//Male->男,Female->女
birthday: 20091014,//
province: {
code: '510000',//行政区域编码
text: '四川省'
},
city: {
code: '511900',
text: '巴中市'
},
area: {
code: '511902',
text: '巴州区'
},
cardType: 1,//身份证类型,1->大陆,2->港澳台
cardText: '大陆',
address: '四川省巴中市巴州区',
age: 11,
constellation: '天秤'//星座
}
//身份证非法时返回数据
{
valid: false
}
var card = require('chinese-idcard-generator');
/**
* return string
*/
card.generateIdcard();//返回随机身份证号码
var card = require('chinese-idcard-generator');
/**
* return string
*/
card.constellation(20091014);//天秤
card.constellation('2009/10/14','/');//天秤
var card = require('chinese-idcard-generator');
/**
* return number
*/
card.getAge(20091014);//11 (调用时的日期:2021/03/27)
var card = require('chinese-idcard-generator');
/**
* return Object
*/
var result = card.upgrade15To18(513722820923415); // 这里找一个身份证号码
result结构:
{
code: 0,
msg: '升级成功',
card: '18位的身份证'
}
附录:行政区域代码