You are not logged in.
Pages: 1
Hello,
I am using Delphi 10.3.3, Synopse commit version 1.18.6045, generating Win32 executable.
I had some legacy code that I am modifying. I used to pass parameter as array of byte and now I am changing it into TBytes. However, I am getting different result for same byte values. My test code is as following:
uses
SynCrypto;
const
TestArray: Array [0..5] of Byte = (1, 2, 3, 4, 5, 6);
TestBytes: TBytes = [1, 2, 3, 4, 5, 6];
procedure TForm1.Button1Click(Sender: TObject);
var
Sha2561: TSHA256Digest;
Sha2562: TSHA256Digest;
begin
Sha2561 := SHA256Digest(Pointer(@TestArray), SizeOf(TestArray));
Sha2562 := SHA256Digest(Pointer(@TestBytes), Length(TestBytes)); // For TBytes I must use Length, SizeOf always returns 4
if not CompareMem(@Sha2561, @Sha2562, 32) then
ShowMessage('different')
else
ShowMessage('identical');
end;
For above test, I get different message displayed.
I am not sure if I am doing something wrong. I could not remember why I did write a code like
Pointer(@TestArray)
That code is possibly a copy-paste from this forum, years ago. In any way, using it as
@TestArray
also displays different message for me.
Any help is appreciated.
Thanks & Regards,
Ertan
Offline
That worked just fine.
Pointer(TestBytes) generates identical hash.
Thank you.
Offline
Pages: 1