ISO 7064
From Lazarus wiki
Revision as of 00:42, 29 November 2021 by Bart (talk | contribs) (→Function StrMOD97: pre-condition)
│
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 wil 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;