This is a new site that's currently running on alpha code. There are going to be bugs. If you discover any, please report them on the site's issues page (GitHub account required). Thanks.
Warning: Many URLs are going to change. Refer to the README file to discover which library project's documentation has been completed.
Project: MD5 Message Digest Unit
Unit: PJMD5
Class: TPJMD5
Applies to: ~>1.0
class operator NotEqual(const D1, D2: TPJMD5Digest): Boolean;
class operator NotEqual(const D: TPJMD5Digest; const B: TBytes): Boolean;
class operator NotEqual(const B: TBytes; const D: TPJMD5Digest): Boolean;
class operator NotEqual(const D: TPJMD5Digest; const S: string): Boolean;
class operator NotEqual(const S: string; const D: TPJMD5Digest): Boolean;
TPJMD5Digest defines five overloads of the <>
operator that permit TPJMD5Digest variables to be tested for inequality with:
Two TPJMD5Digest records are considered unequal if their LongWords array fields differ in any element.
var
D1, D2: TPJMD5Digest;
begin
D1 := TPJMD5.Calculate('foo');
D2 := TPJMD5.Calculate('bar');
Assert(D1 <> D2);
Assert(D2 <> D1);
end;
A TPJMD5Digest record is considered unequal to a Unicode string if:
A
to F
are permitted) – orconst
S1 = '000102030405060708090A0B0C0D0E0F';
S2 = '*foobarfoobarfoobarfoobarfoobar*'
S3 = '000102030405060708';
D: TPJMD5Digest = (
Bytes: (
$D1, $74, $AB, $98, $D2, $77, $D9, $F5,
$A5, $61, $1C, $2C, $9F, $41, $9D, $9F
)
);
begin
Assert(S1 <> D);
Assert(D <> S1);
Assert(S2 <> D);
Assert(D <> S2);
Assert(S3 <> D);
Assert(D <> S3);
end;
A TPJMD5Digest record is considered unequal to a TBytes array if:
const
D: TPJMD5Digest = (
Bytes: (
$D1, $74, $AB, $98, $D2, $77, $D9, $F5,
$A5, $61, $1C, $2C, $9F, $41, $9D, $9F
)
);
var
A1, A2, A3: TBytes;
begin
A1 := TBytes.Create( // 16 elements
$00, $01, $02, $03, $04, $05, $06, $07,
$08, $09, $0A, $0B, $0C, $0D, $0E, $0F
);
A2 := TBytes.Create( // 2 elements
$D1, $74
);
A3 := TBytes.Create( // 18 elements
$D1, $74, $AB, $98, $D2, $77, $D9, $F5,
$A5, $61, $1C, $2C, $9F, $41, $9D, $9F,
$00, $FF
);
Assert(A1 <> D);
Assert(D <> A1);
Assert(A2 <> D);
Assert(D <> A2);
Assert(A3 <> D);
Assert(D <> A3);
end;
Although a byte array with more than 16 elements can be assigned to a TPJMD5Digest, the two items do not compare equal:
var
D: TPJMD5Digest;
A: TBytes;
begin
A := TBytes.Create( // 18 elements
$D1, $74, $AB, $98, $D2, $77, $D9, $F5,
$A5, $61, $1C, $2C, $9F, $41, $9D, $9F,
$00, $FF
);
D := A;
Assert(D <> A);
end;
This is because the “overflow” bytes from the byte array are discarded when assigning to the TPJMD5Digest record.