Computes MRZ check digit for given string of characters. @param str the string @return check digit in range of 0..9, inclusive. See MRTD documentation part 15 for details.
(String str)
| 239 | * @return check digit in range of 0..9, inclusive. See <a href="http://www2.icao.int/en/MRTD/Downloads/Doc%209303/Doc%209303%20English/Doc%209303%20Part%203%20Vol%201.pdf">MRTD documentation</a> part 15 for details. |
| 240 | */ |
| 241 | public static int computeCheckDigit(String str) { |
| 242 | int result = 0; |
| 243 | for (int i = 0; i < str.length(); i++) { |
| 244 | result += getCharacterValue(str.charAt(i)) * MRZ_WEIGHTS[i % MRZ_WEIGHTS.length]; |
| 245 | } |
| 246 | return result % 10; |
| 247 | } |
| 248 | |
| 249 | /** |
| 250 | * Computes MRZ check digit for given string of characters. |