mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-30 12:20:19 +02:00
* Some small optimizations. Fix issue #40387
This commit is contained in:
parent
52da2011dd
commit
f5280abe54
@ -344,22 +344,17 @@ end;
|
||||
|
||||
class procedure TSHA256.Stream(aStream: TStream; out aDigest: TSHA256Digest);
|
||||
|
||||
const
|
||||
BUFFER_SIZE = 64*1024;
|
||||
|
||||
var
|
||||
aLen : LongInt;
|
||||
Buffer: TBytes;
|
||||
Buffer: array[0 .. 64*1024 - 1] of Byte;
|
||||
SHA256: TSHA256;
|
||||
|
||||
begin
|
||||
Buffer:=Nil;
|
||||
SHA256.Init;
|
||||
SetLength(Buffer,BUFFER_SIZE);
|
||||
repeat
|
||||
aLen:=aStream.Read(Buffer, BUFFER_SIZE);
|
||||
if aLen <> 0 then
|
||||
SHA256.Update(PByte(Buffer),aLen);
|
||||
aLen:=aStream.Read(Buffer, Length(Buffer));
|
||||
if aLen>0 then
|
||||
SHA256.Update(PByte(Buffer),aLen);
|
||||
until aLen=0;
|
||||
SHA256.Final;
|
||||
aDigest:=SHA256.Digest;
|
||||
|
@ -517,22 +517,17 @@ end;
|
||||
|
||||
class procedure TSHA512.Stream(aStream: TStream; out aDigest: TSHA512Digest);
|
||||
|
||||
const
|
||||
BUFFER_SIZE = 64*1024;
|
||||
|
||||
var
|
||||
aLen : LongInt;
|
||||
lBuffer: TBytes;
|
||||
lBuffer: array[0 .. 64*1024 - 1] of Byte;
|
||||
SHA512: TSHA512;
|
||||
|
||||
begin
|
||||
lBuffer:=Nil;
|
||||
SHA512.Init;
|
||||
SetLength(lBuffer,BUFFER_SIZE);
|
||||
repeat
|
||||
aLen:=aStream.Read(lBuffer, BUFFER_SIZE);
|
||||
if aLen <> 0 then
|
||||
SHA512.Update(PByte(lBuffer),aLen);
|
||||
aLen:=aStream.Read(lBuffer, Length(lBuffer));
|
||||
if aLen>0 then
|
||||
SHA512.Update(PByte(lBuffer),aLen);
|
||||
until aLen=0;
|
||||
SHA512.Final;
|
||||
aDigest:=SHA512.Digest;
|
||||
|
Loading…
Reference in New Issue
Block a user