mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-26 13:09:26 +02:00
fcl-hash: fixed HexStrToBytes
This commit is contained in:
parent
606f27563e
commit
67905957cb
@ -123,7 +123,7 @@ Var
|
|||||||
begin
|
begin
|
||||||
Len:=Length(aHexStr);
|
Len:=Length(aHexStr);
|
||||||
aBytes:=[];
|
aBytes:=[];
|
||||||
SetLength(aBytes, Len div 2);
|
SetLength(aBytes, (Len+1) div 2);
|
||||||
if Len=0 then Exit;
|
if Len=0 then Exit;
|
||||||
P := PAnsiChar(aHexStr);
|
P := PAnsiChar(aHexStr);
|
||||||
PResult := PByte(aBytes);
|
PResult := PByte(aBytes);
|
||||||
@ -160,9 +160,9 @@ var
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
aHexStr:='';
|
aHexStr:='';
|
||||||
SetLength(aHexStr,aSize*2);
|
|
||||||
if aSize=0 then
|
if aSize=0 then
|
||||||
exit;
|
exit;
|
||||||
|
SetLength(aHexStr,aSize*2);
|
||||||
PB:=aBytes;
|
PB:=aBytes;
|
||||||
PC:=PChar(aHexStr);
|
PC:=PChar(aHexStr);
|
||||||
for I:=0 to aSize-1 do
|
for I:=0 to aSize-1 do
|
||||||
@ -385,9 +385,7 @@ begin
|
|||||||
Result := rs1 xor rs2 xor result;
|
Result := rs1 xor rs2 xor result;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function CryptoGetRandomBytes(Buffer: PByte; const Count: Integer): Boolean;
|
function CryptoGetRandomBytes(Buffer: PByte; const Count: Integer): Boolean;
|
||||||
|
|
||||||
var
|
var
|
||||||
I, Remainder, Rounds: Integer;
|
I, Remainder, Rounds: Integer;
|
||||||
Lecuyer: TLecuyer;
|
Lecuyer: TLecuyer;
|
||||||
@ -402,8 +400,8 @@ begin
|
|||||||
if Remainder > 0 then
|
if Remainder > 0 then
|
||||||
begin
|
begin
|
||||||
R := Lecuyer.Next;
|
R := Lecuyer.Next;
|
||||||
Move(R, PByteArray(Buffer)[Rounds*SizeOf(UInt32)], Remainder);
|
Move(R, Buffer[Rounds*SizeOf(UInt32)], Remainder);
|
||||||
R:=R+R;// Silence compiler warning
|
R:=R-R;// Silence compiler warning
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user