An optional checksum is available at any level of code precision.For example KFPX-WT7D/5
has the optional checksum character 5 which validates the characters in the code.
It uses the same system as the PPS checksum (but modulus 31 rather than 23).
It makes a postcode verifiable and protects against transcription and OCR mistakes.
It is a character added to the code based on a mathematical calculation on the characters to check that it has been entered correctly. It is designed to trap codes with at least one incorrect character or codes with at least two transposed characters or codes with a missing character, while also catching many more - even if the incorrect character is the checksum itself.
As variations of the OpenPostcode can exist with different parameters, these are also included in the checksum calculation - codes generated for one region will mostly fail in another.
Many codes randomly created or mistyped with characters outside the allowed character set will also stand out as invalid codes.
Calculation of Checksum
- For each character (in e.g. KFPXTV7D),
multiply its number equivalent by its position (left to right);
calculate the total; add the integer of the parameters
west*north-wide*high (which amounts to zero in the Irish calculation and
so can be ignored); and calculate the total modulus (or remainder after
dividing by) the number of available checksum characters
("0123456789ACDEFGHJKLMNPQRTUVWXY" = 31) thus:
Reading from position 5+1, the checksum character is "5".
- (14*1 + 10*2 + 18*3 + 24*4 + 23*5 + 21*6 + 5*7 + 9*8) mod 31 = 5
- Thus the final 8-digit code of KFPXTV7D/5.
|Put simply, to calculate the checksum for the "EAIONL59" base 25 code above:|
- (base25to10("E")*1 +base25to10("A")*2 +base25to10("I")*3 +base25to10("O")*4 +base25to10("N")*5 +base25to10(L)*6 +base25to10(5)*7 +base25to10(9)) mod 31 = 5
- Which equates to a checksum "5" from its character set. Thus the final 8-digit code of KFPXTV7D/5.