ISO 7064

From Free Pascal wiki
Revision as of 11:47, 4 December 2021 by Jwdietrich (talk | contribs) (Adding a paragraph on usage.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

English (en) français (fr)


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 for handling non digits
  modu = 97;
  sx: String;
  isx, ic, p: Integer;
   p := Length( s );
   while ( p > 9 ) do
       sx := Copy( s, 1, 9 );
       Delete( s, 1, 9 );
       isx := StrToInt( sx );
       ic := isx mod modu;
       s := IntToStr( ic ) + s;
       p := Length( s );
   isx := StrToInt( s );
   if isx >= modu
     then ic := isx mod modu
     else ic := isx;
  result := ic;

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


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