確認 EZ100PU 是否正常運作

可以使用 Ubuntu 的 PC/SC 套件測試。

安裝

sudo apt update

sudo apt install \
    pcscd \
    pcsc-tools \
    libpcsclite-dev

pip install pyscard

啟動服務

sudo systemctl enable pcscd
sudo systemctl start pcscd

Python 範例(偵測健保卡)

from smartcard.System import readers

r = readers()

if not r:
    print("找不到讀卡機")
    exit()

reader = r[0]

print("Reader:", reader)

connection = reader.createConnection()
connection.connect()

atr = connection.getATR()

print("ATR:")
print(" ".join(f"{x:02X}" for x in atr))

輸出例如:

Reader: EZ100PU Smart Card Reader

ATR:
3B 67 00 00 ...

可以取得 ATR

ATR (Answer To Reset) 是任何 ISO7816 卡都可以取得的資訊。

例如:

atr = connection.getATR()

print(bytes(atr).hex())

也可以送 APDU

例如

SELECT = [
    0x00,
    0xA4,
    0x04,
    0x00,
    0x00
]

data, sw1, sw2 = connection.transmit(SELECT)

print(data)
print(hex(sw1), hex(sw2))

但對於健保卡而言,未經授權的 APDU 並不能取得個人資料。


如果是在合法開發健保相關系統

例如:

  • 醫院 HIS
  • 診所系統
  • 健保署合作計畫
  • 政府專案
  • 健康存摺整合

通常會使用健保署提供的:

  • 健保卡元件(Linux/Windows)
  • 官方 API/SDK
  • 卡片存取函式庫
  • 安全認證機制

透過官方元件才能合法取得:

  • 健保卡號
  • 卡片序號
  • 身分證字號
  • 姓名
  • 出生年月日
  • 保險別
  • 卡片狀態等資料