ELEC332 Presentation HKID & Credit Card Number Verification Chan Ka Shing, Yuemin Lu, Tang Shuk Fan 1.

Presentation on theme: "ELEC332 Presentation HKID & Credit Card Number Verification Chan Ka Shing, Yuemin Lu, Tang Shuk Fan 1."— Presentation transcript:

ELEC332 Presentation HKID & Credit Card Number Verification Chan Ka Shing, Yuemin Lu, Tang Shuk Fan 1

Luhn Algorithm  Created by IBM scientist Hans Peter Luhn  Simple checksum formula used to validate identification numbers  Many extensions  Classical Algorithm Logic  Double the value of every second digit counting from the check digit  Sum all the digits  Mod 10 XXXXXXXXXXXXX Y X = account number, Y = check digit 2

Luhn Algorithm  Strengths and Weaknesses  Detect single-digit error  Almost all transposition of adjacent digits except 09 and 90  Detect some twin errors 3

Credit Card Verification  Credit Card pattern 8267 1232 7351 0569  Example:  16-bit Credit Card = Codeword  Double every other number, starting with the second number in from the right  If a number has two digits, add both digits together 4

Credit Card Verification  Add all numbers together  If last digit is a zero, it is a valid credit card number. If not, the credit card number is a fake. 5

HKID Verification  HK digit pattern X9999999/X999999(C)  Each letter matches to a corresponding number NumberLetterNumberLetter 1A L M7G R 2B M X8H S 3C N Y9I T 4D O Z10J U 5E P11KV 6F Q 6

HKID Verification  Example: C546234(5)  8-bit HKID = Codeword  First 7-bit = Message  Last bit = Check Bit CheckSum =char[1]*8+char[2]*7+char[3]*6+char[4]*5+char[5]*4+cha r[6]*3+char[7]*2 =3(C)*8+5*7+4*6+6*5+2*4+3*3+4*2 =138 Check Bit =11-(CheckSum mod 11) = 11-(138mod11) = 5 C546234(5) is a valid HKID. 7

HKID Verification Assume a single error is represented by e Example: C546e34(5) CheckSum =char[1]*8+char[2]*7+char[3]*6+char[4]*5+e*4+cha r[6]*3+char[7]*2 =3(C)*8+5*7+4*6+6*5+e*4+3*3+4*2 =130+4e Check Bit =11-(CheckSum mod 11) =11-(130+4e)mod11=11-(9+4e)mod11 8

HKID Verification  If Check Bit == 5 =>11-(9+4e)mod11 = 5 =>(9+4e)mod11 = 6 =>9+4e = 11n+6 n is an positive integer =>e = (11n-3)/4 Single bit error is detected. e01 2 3456789 n3/117/11 1 15/1119/1123/1127/1131/1135/1139/11 9

Download ppt "ELEC332 Presentation HKID & Credit Card Number Verification Chan Ka Shing, Yuemin Lu, Tang Shuk Fan 1."

Similar presentations