Showing posts with label HKID. Show all posts
Showing posts with label HKID. Show all posts

Wednesday, January 23, 2013

Hong Kong ID Formula (HKID Number Check Digit)

此文之中文版
http://computerterminal.blogspot.hk/2005/11/hkid-calculation.html


I found out form the Google Analystic that 1/8 of the visitors to this site is to the post HKID Calculation and 1/3 of the visitors are from Russia(!!!) and USA. So i decide to write that post in English for them.

HK ID number starts from Two English Letters plus 6 digits and end with a check digit in bracket
for example: AB987654(3)

Validate the HKID by the following steps:


1) Replace the leading English alphabet with numberic value following the rules below:

Space = 36  A = 10    B = 11   C = 12   D = 13  E = 14    F = 15

G = 16    H = 17   I = 18     J = 19   K = 20    L = 21M = 22    N = 23  O = 24   P = 25   Q = 26    R = 27S = 28    T = 29   U = 30   V = 31   W = 32   X = 33Y = 34     Z = 35

2) Weighted Total 
Calculation 
   A)If double english alphabet digit,e.g. AB987654(3):
           Total = 1st Digit x9 + 2nd Digit x8 + 3rd Digit x7 + 4th Digit x6 + 5th Digit x5 + 6th Digit x4 + 7th Digit x3 +8th Digit x2

   B) Else if single english alphabet digit,e.g. E364912(5):
           E364912(5) = (Space)E364912(5)
           Total = 36 x 9 + 1st Digit x8 + 2nd Digit x7 + 3rd Digit x6 + 4th Digit x5 + 5th Digit x4 + 6th Digit x3 + 7th Digit x2 

3) CheckDigit Calculation

Remaining= Total modulo 11 

IF
a)Remaning = 0:
   CheckDigit = 0

b)Remaning = 1:
   CheckDigit = A

c)Remaning = [2-10]:
   CheckDigit = 11 - Remaining


Example:
HKID:E364912(5)
(PS:E is equal to 14 according to step 1)

324 + 14x8 + 3x7 + 6x6 + 4x5 + 9x4 + 1x3 + 2x2 = 556

556 % 11 = 68

11 - 6 = 5

So E364912(5) is a Valid HKID


Tuesday, November 01, 2005

HKID Formula (HKID Number Check Digit) 香港身份證號碼計算

Click here for the English Version of HKID Formula 



香港身份證號碼有二個英文字母,一個六位數和一個加上括號的檢驗位。

你可用以下方法計算身份證號碼以確定身份證號碼的真確性。
請把身份證號上的英文字母用數字代表,如
空格=36 A = 10 B = 11 C = 12 D = 13 E = 14 F = 15
G = 16 H = 17 I = 18 J = 19 K = 20 L = 21
M = 22 N = 23 O = 24 P = 25 Q = 26 R = 27
S = 28 T = 29 U = 30 V = 31 W = 32 X = 33
Y = 34 Z = 35

方法:
1) 計算比重積和:

    A)如果為單字母開頭,如:E364912(5):
        E364912(5) = (空格)E364912(5)
        36 x 9 + 第一位x8 + 第二位x7 + 第三位x6 + 第四位x5 + 第五位x4 + 第六位x3 + 第七位x2 = 總和

    B)如果為雙字母開頭,如:AB987654(3):
       第一位x9 + 第二位x8 + 第三位x7 + 第四位x6 + 第五位x5 + 第六位x4 + 第七位x3 +第八位x2= 總和

    C)總和除以 11 得到餘數

2)計算檢驗位:
   A)如果餘數為0,檢驗位=0

   B)如果餘數為1,檢驗位=A

   C)如果餘數為2至10 [2—10]:
      檢驗位 = 11-餘數

例子:
身份證號碼:E364912(5)
(註:E 是第一位把它換成 14)

324 + 14x8 + 3x7 + 6x6 + 4x5 + 9x4 + 1x3 + 2x2 = 556

556 / 11 得餘數 6

11 - 6 = 5

所以這身份證號碼正確。