ISO 7064
│
English (en) │
français (fr) │
Overview
ISO 7064 specifies a set of check character systems capable of protecting strings against errors which occur when people copy or key data.
The check character systems specified in ISO/IEC 7064:2002 can detect:
- all single substitution errors (the substitution of a single character for another, for example 4234 for 1234);
- all or nearly all single (local) transposition errors (the transposition of two single characters, either adjacent or with * one character between them, for example 12354 or 12543 for 12345);
- all or nearly all shift errors (shifts of the whole string to the left or right);
- a high proportion of double substitution errors (two separate single substitution errors in the same string, for example 7234587 for 1234567);
- a high proportion of all other errors.
Function StrMOD97
The function StrMOD97 can encode and verify a check character (an added character which may be used to verify the accuracy of the string by a mathematical relationship to that string) and a supplementary check character (a character which does not belong to the character set of the strings which are to be protected) in accordance with ISO 7064, MOD 97-10 for numeric strings with two check digits.
function StrMOD97(s: String): integer;
// Pre-condition: s can only contain digits, otherwise this function will raise an exception.
// See https://wiki.freepascal.org/International_Bank_Account_Number for handling non digits
const
modu = 97;
var
sx: String;
isx, ic, p: Integer;
begin
p := Length( s );
while ( p > 9 ) do
begin
sx := Copy( s, 1, 9 );
Delete( s, 1, 9 );
isx := StrToInt( sx );
ic := isx mod modu;
s := IntToStr( ic ) + s;
p := Length( s );
end;
isx := StrToInt( s );
if isx >= modu
then ic := isx mod modu
else ic := isx;
result := ic;
end;
All ISO 7064 check character systems
Pure system algorithms
Pure system algorithms use a single modulus for all stages of the computation.
- ISO/IEC 7064, MOD 11-2 for numeric strings with one check digit or the supplementary check character X
- ISO/IEC 7064, MOD 37-2 for alphanumeric strings with one check digit or letter or the supplementary check character * (asterisk)
- ISO/IEC 7064, MOD 97-10 for numeric strings with two check digits (implemented above)
- ISO/IEC 7064, MOD 661-26 for alphabetic strings with two check letters
- ISO/IEC 7064, MOD 1271-36 for alphanumeric strings with two check digits or letters
Hybrid system algorithms
Hybrid system algorithms use two moduli in the computation. One modulus is equal to, and other other is greater than, the number of characters in the characters set of the string being protected. They always produce a single check character within the character set of the string to be protected.
- ISO/IEC 7064, MOD 11,10 for numeric strings with one check digit
- ISO/IEC 7064, MOD 27,26 for alphabetic strings with one check letter
- ISO/IEC 7064, MOD 37,36 for alphanumeric strings with one check digit or letter
Usage
The ISO/IEC 7064 standard has multiple applications including International Bank Account Numbers, International Standard Name Identifiers (ISNI), ORCID IDs and VAT identification numbers of several countries.
See also
- International Bank Account Number an example of usage of the StrMOD97 function handling both digits and non-digits.