ISO 7064
From Free Pascal wiki
Revision as of 06:31, 30 November 2021 by Trev (talk | contribs) (→See also: Fix page link formatting)
│
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.
Function StrMOD97
The function StrMOD97 can encode and verify number checksum with ISO 7064.
function StrMOD97(s: String): integer;
//Pre-condition: s can only contain digits, otherwise this function will raise an exception.
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;
See also
- International Bank Account Number an example of usage of the above function.