GithubHelp home page GithubHelp logo

node-idcard-reader's Introduction

通用二代身份证读卡


在widnows客户端实现通过二代身份证机具读取二代身份证信息

  • 使用通过 sdtapi.dll 驱动实现对多数机具的读取
  • 通过 node-ffi 实现访问dll读卡接口
  • 通用dll下载地址

安装依赖

npm install node-gyp -g

  • gyp安装比较麻烦,可以先npm安装 windows-build-tools 模块来自动安装相关开发环境和工具

安装

npm install idcard-reader

使用

import * as idcr from '../lib/index'


const opts = {
    dllTxt: 'c:/sdtapi.dll',
    dllImage: 'c:/wltrs.dll',   // 可空 空则不处理头像
    imgSaveDir: '',             // 头像图片生成保存目录 空则使用系统临时目录
}

idcr.init(opts)
  .then((devices) => {
    // 使用第一个机具进行读取
    return idcr.read(devices[0])
      .then(data => {
        console.log(data)
      })
  })
  .catch(console.error)

命令行调用

// 全局安装
npm install -g idcard-reader
// 执行
idc-reader

读取数据结构

{
    base: {
        name: string;       // 姓名
        gender: number;     // 性别 1,2
        genderName: string; // 性别 男,女
        nation: string;     // 民族代码
        nationName: string; // 民族中文
        birth: string;      // 出生日期
        address: string;    // 住址
        idc: string;        // 身份证号
        regorg: string;     // 签发机关
        startdate: string;  // 有效期开始
        enddate: string;    // 有效期结束 日期或者"长期"
    }
    imagePath: string;      // 头像文件路径
    samid: string;          // 机具SAM序列号
}

注意事项

  • 因保护设计,身份证成功读取后必须移出机具读取感应区或者取出插卡,否则下次连接硬件执行找卡会出现找卡失败情况
  • 若系统无法识别 USB 接口的机具,请尝试切换机具到主板 USB2.0 接口
  • 大头照解码可能需要配合机具厂商提供的 WltRS.dll 文件
  • gyp 需要编译为与 dll 相同的 32/64 位版本(通常为32位)

资源

  • 若需合成图片则自行准备以下字体 华文细黑(hwxhei.ttf) 黑体(simhei.ttf) OCR-B 10 BT(ocrb10bt.ttf)
  • 感谢 身份证模板

License

MIT

node-idcard-reader's People

Contributors

waitingsong avatar

Stargazers

Beta avatar

Watchers

James Cloos avatar  avatar  avatar

Forkers

radtek nyrf

node-idcard-reader's Issues

执行 idc-reader报错

安装完成后,执行idc-reader报错: win32 error 193.
两个dll也放到了C盘下。 请问还有哪里需要注意么? 谢谢

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.