close
本文經授權轉載自果殼(ID:Guokr42)





溫馨提示:如果你暈公式,可以跳過這段……
身份證最後一位的算法採用的是 ISO 7064 《數據處理——校驗符系統》中給出的 MOD 11-2 校驗碼系統。這裡的MOD 11-2表示模數是11,基數是2。也就是校驗公式(見下)中,需要將總數除以11(模數)並取餘數,而每個位置上的加權因子是通過以2(基數)為底的幾何級數算出來的。

公民身份號碼校驗公式丨國家標準《公民身份號碼》GB11643—1999
身份號碼中的校驗碼位於最右邊,所以它位置序號i=1,對應的加權因子W1也等於1。按照公式,我們需要將身份證號碼中其他各個位置上的數字都乘以對應的因子,把它們加起來得到總數,再將總數除以11並取餘數。如果這個餘數加上校驗碼(乘1還是本身)以後,除以11的餘數是1,那就說明這個號碼能夠滿足公式的校驗。
為了方便計算,國家標準中直接給出了校驗碼a1和餘數的換算關係對應表:

來源:國家標準《公民身份號碼》GB11643—1999
舉個例子:

校驗碼計算範例丨國家標準《公民身份號碼》GB11643—1999
因為模數是11,所以最後的結果有0~10共10種可能性,為了保證校驗碼只占1個字符位置,當算出來的 a1 等於10時,在身份證上用羅馬數字符X表示。




·一 周 熱 點 回 顧·


全站熱搜