Difference between revisions of "ISO 7064"
m (→Function StrMOD97: Tweak) |
m (→Pure system algorithms: Note 97-10 implemented above) |
||
Line 51: | Line 51: | ||
* ISO/IEC 7064, MOD 11-2 for numeric strings with one check digit or the supplementary check character "X" | * 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 "*" | * ISO/IEC 7064, MOD 37-2 for alphanumeric strings with one check digit or letter or the supplementary check character "*" | ||
− | * ISO/IEC 7064, MOD 97-10 for numeric strings with two check digits | + | * 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 661-26 for alphabetic strings with two check letters | ||
* ISO/IEC 7064, MOD 1271-36 for alphanumeric strings with two check digits or letters | * ISO/IEC 7064, MOD 1271-36 for alphanumeric strings with two check digits or letters |
Revision as of 08:16, 4 December 2021
│
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
- 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 "*"
- 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
Hybid system algorithms always produce a single check character within the character set of the string that is being 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
See also
- International Bank Account Number an example of usage of the above function handling both digits and non-digits.