You are not logged in.
Pages: 1
Hello,
I am a little confused about this simple program that calculates the SHA256 of an array of Byte.
The line marked "<=== PB here" does not compile if I write:
vSHA256Static: = SHA256(pointer(vStatic), MAX_T);
The line
vSHA256Static: = SHA256(Pointer(vStatic [0]), MAX_T);
compile but I get an access violation at execution.
The calculation of SHA256 with the dynamic array works perfectly.
I do not understand why.
Thank you for your help
P.S. : I am using Delphi 7 Pro
const
MAX_T = 22400;
var
vStatic : array[0..MAX_T-1] of Byte;
vDynamic : array of Byte;
vFS : TFileStream;
vSHA256Static : AnsiString;
vSHA256Dynamic : AnsiString;
begin
SetLength(vDynamic, MAX_T);
vFS := TFileStream.Create(---some file greater then MAX_T---, fmOpenRead);
vFS.Position := 0;
vFS.ReadBuffer(vStatic[0], MAX_T);
vFS.Position := 0;
vFS.ReadBuffer(vDynamic[0], MAX_T);
FreeAndNil(vFS);
vSHA256Static := SynCrypto.SHA256(Pointer(vStatic[0]), MAX_T); // <==== PB here
vSHA256Dynamic := SynCrypto.SHA256(Pointer(vDynamic), MAX_T);
ShowMessage
(
'Static'#9 + vSHA256Static + #10
+ 'Dynamic'#9 + vSHA256Dynamic
);
end;
Last edited by MC (2019-04-25 12:47:12)
Offline
@ab Thank you, I understand now !
Offline
Pages: 1