Browse Source

update hashlib

Ugochukwu Mmaduekwe 6 years ago
parent
commit
afd8e5f157
100 changed files with 8944 additions and 9277 deletions
  1. 21 22
      src/libraries/hashlib4pascal/HashLib.inc
  2. 33 31
      src/libraries/hashlib4pascal/HlpAP.pas
  3. 39 44
      src/libraries/hashlib4pascal/HlpAdler32.pas
  4. 56 55
      src/libraries/hashlib4pascal/HlpArrayUtils.pas
  5. 21 22
      src/libraries/hashlib4pascal/HlpBKDR.pas
  6. 21 23
      src/libraries/hashlib4pascal/HlpBernstein.pas
  7. 21 23
      src/libraries/hashlib4pascal/HlpBernstein1.pas
  8. 219 282
      src/libraries/hashlib4pascal/HlpBitConverter.pas
  9. 88 87
      src/libraries/hashlib4pascal/HlpBits.pas
  10. 177 189
      src/libraries/hashlib4pascal/HlpBlake2B.pas
  11. 16 16
      src/libraries/hashlib4pascal/HlpBlake2BConfig.pas
  12. 43 40
      src/libraries/hashlib4pascal/HlpBlake2BIvBuilder.pas
  13. 26 26
      src/libraries/hashlib4pascal/HlpBlake2BTreeConfig.pas
  14. 177 190
      src/libraries/hashlib4pascal/HlpBlake2S.pas
  15. 16 16
      src/libraries/hashlib4pascal/HlpBlake2SConfig.pas
  16. 48 45
      src/libraries/hashlib4pascal/HlpBlake2SIvBuilder.pas
  17. 27 27
      src/libraries/hashlib4pascal/HlpBlake2STreeConfig.pas
  18. 142 155
      src/libraries/hashlib4pascal/HlpCRC.pas
  19. 13 11
      src/libraries/hashlib4pascal/HlpCRC16.pas
  20. 13 11
      src/libraries/hashlib4pascal/HlpCRC32.pas
  21. 18 19
      src/libraries/hashlib4pascal/HlpCRC32Fast.pas
  22. 13 11
      src/libraries/hashlib4pascal/HlpCRC64.pas
  23. 283 247
      src/libraries/hashlib4pascal/HlpConverters.pas
  24. 12 14
      src/libraries/hashlib4pascal/HlpDEK.pas
  25. 21 23
      src/libraries/hashlib4pascal/HlpDJB.pas
  26. 28 27
      src/libraries/hashlib4pascal/HlpELF.pas
  27. 21 23
      src/libraries/hashlib4pascal/HlpFNV.pas
  28. 21 23
      src/libraries/hashlib4pascal/HlpFNV1a.pas
  29. 21 22
      src/libraries/hashlib4pascal/HlpFNV1a64.pas
  30. 21 22
      src/libraries/hashlib4pascal/HlpFNV64.pas
  31. 107 106
      src/libraries/hashlib4pascal/HlpGOST3411_2012.pas
  32. 189 198
      src/libraries/hashlib4pascal/HlpGost.pas
  33. 144 159
      src/libraries/hashlib4pascal/HlpGrindahl256.pas
  34. 143 163
      src/libraries/hashlib4pascal/HlpGrindahl512.pas
  35. 89 92
      src/libraries/hashlib4pascal/HlpHAS160.pas
  36. 54 66
      src/libraries/hashlib4pascal/HlpHMACNotBuildInAdapter.pas
  37. 116 127
      src/libraries/hashlib4pascal/HlpHash.pas
  38. 62 64
      src/libraries/hashlib4pascal/HlpHashBuffer.pas
  39. 40 42
      src/libraries/hashlib4pascal/HlpHashCryptoNotBuildIn.pas
  40. 89 90
      src/libraries/hashlib4pascal/HlpHashFactory.pas
  41. 1 6
      src/libraries/hashlib4pascal/HlpHashLibTypes.pas
  42. 90 98
      src/libraries/hashlib4pascal/HlpHashResult.pas
  43. 2 2
      src/libraries/hashlib4pascal/HlpHashSize.pas
  44. 557 566
      src/libraries/hashlib4pascal/HlpHaval.pas
  45. 4 4
      src/libraries/hashlib4pascal/HlpIBlake2BConfig.pas
  46. 7 7
      src/libraries/hashlib4pascal/HlpIBlake2BTreeConfig.pas
  47. 4 4
      src/libraries/hashlib4pascal/HlpIBlake2SConfig.pas
  48. 7 7
      src/libraries/hashlib4pascal/HlpIBlake2STreeConfig.pas
  49. 2 2
      src/libraries/hashlib4pascal/HlpICRC.pas
  50. 25 29
      src/libraries/hashlib4pascal/HlpIHash.pas
  51. 2 2
      src/libraries/hashlib4pascal/HlpIHashInfo.pas
  52. 2 2
      src/libraries/hashlib4pascal/HlpIHashResult.pas
  53. 3 3
      src/libraries/hashlib4pascal/HlpIKDF.pas
  54. 21 23
      src/libraries/hashlib4pascal/HlpJS.pas
  55. 285 299
      src/libraries/hashlib4pascal/HlpJenkins3.pas
  56. 2 2
      src/libraries/hashlib4pascal/HlpKDF.pas
  57. 47 56
      src/libraries/hashlib4pascal/HlpMD2.pas
  58. 68 70
      src/libraries/hashlib4pascal/HlpMD4.pas
  59. 84 87
      src/libraries/hashlib4pascal/HlpMD5.pas
  60. 29 29
      src/libraries/hashlib4pascal/HlpMDBase.pas
  61. 18 21
      src/libraries/hashlib4pascal/HlpMultipleTransformNonBlock.pas
  62. 59 65
      src/libraries/hashlib4pascal/HlpMurmur2.pas
  63. 99 110
      src/libraries/hashlib4pascal/HlpMurmur2_64.pas
  64. 262 284
      src/libraries/hashlib4pascal/HlpMurmurHash3_x64_128.pas
  65. 316 329
      src/libraries/hashlib4pascal/HlpMurmurHash3_x86_128.pas
  66. 118 124
      src/libraries/hashlib4pascal/HlpMurmurHash3_x86_32.pas
  67. 23 23
      src/libraries/hashlib4pascal/HlpNullDigest.pas
  68. 2 6
      src/libraries/hashlib4pascal/HlpNullable.pas
  69. 26 27
      src/libraries/hashlib4pascal/HlpOneAtTime.pas
  70. 67 57
      src/libraries/hashlib4pascal/HlpPBKDF2_HMACNotBuildInAdapter.pas
  71. 251 157
      src/libraries/hashlib4pascal/HlpPBKDF_Argon2NotBuildInAdapter.pas
  72. 217 210
      src/libraries/hashlib4pascal/HlpPBKDF_ScryptNotBuildInAdapter.pas
  73. 27 26
      src/libraries/hashlib4pascal/HlpPJW.pas
  74. 198 212
      src/libraries/hashlib4pascal/HlpPanama.pas
  75. 125 127
      src/libraries/hashlib4pascal/HlpRIPEMD.pas
  76. 150 152
      src/libraries/hashlib4pascal/HlpRIPEMD128.pas
  77. 185 189
      src/libraries/hashlib4pascal/HlpRIPEMD160.pas
  78. 161 165
      src/libraries/hashlib4pascal/HlpRIPEMD256.pas
  79. 199 201
      src/libraries/hashlib4pascal/HlpRIPEMD320.pas
  80. 24 24
      src/libraries/hashlib4pascal/HlpRS.pas
  81. 94 102
      src/libraries/hashlib4pascal/HlpRadioGatun32.pas
  82. 94 101
      src/libraries/hashlib4pascal/HlpRadioGatun64.pas
  83. 21 23
      src/libraries/hashlib4pascal/HlpRotating.pas
  84. 22 23
      src/libraries/hashlib4pascal/HlpSDBM.pas
  85. 265 272
      src/libraries/hashlib4pascal/HlpSHA0.pas
  86. 142 204
      src/libraries/hashlib4pascal/HlpSHA1.pas
  87. 15 17
      src/libraries/hashlib4pascal/HlpSHA2_224.pas
  88. 15 19
      src/libraries/hashlib4pascal/HlpSHA2_256.pas
  89. 353 353
      src/libraries/hashlib4pascal/HlpSHA2_256Base.pas
  90. 15 20
      src/libraries/hashlib4pascal/HlpSHA2_384.pas
  91. 15 19
      src/libraries/hashlib4pascal/HlpSHA2_512.pas
  92. 440 439
      src/libraries/hashlib4pascal/HlpSHA2_512Base.pas
  93. 15 20
      src/libraries/hashlib4pascal/HlpSHA2_512_224.pas
  94. 15 20
      src/libraries/hashlib4pascal/HlpSHA2_512_256.pas
  95. 242 254
      src/libraries/hashlib4pascal/HlpSHA3.pas
  96. 21 22
      src/libraries/hashlib4pascal/HlpShiftAndXor.pas
  97. 159 166
      src/libraries/hashlib4pascal/HlpSipHash.pas
  98. 108 118
      src/libraries/hashlib4pascal/HlpSnefru.pas
  99. 52 55
      src/libraries/hashlib4pascal/HlpSuperFast.pas
  100. 363 370
      src/libraries/hashlib4pascal/HlpTiger.pas

+ 21 - 22
src/libraries/hashlib4pascal/HashLib.inc

@@ -56,26 +56,7 @@
 
 {$IFDEF DELPHI}
 
-{$DEFINE USE_UNROLLED_VARIANT}
-
-// This option is needed to enable code browsing (aka Ctrl+Click)
-// It does not affect the binary size or generated code
-{$DEFINITIONINFO ON}
-
-// Disable Overflow and RangeChecks.
-{$OVERFLOWCHECKS OFF}
-{$RANGECHECKS OFF}
-
- // Enable Pointer Math
-{$POINTERMATH ON}
-
-// Disable String Checks
-{$STRINGCHECKS OFF}
-
-// Disable Duplicate Constructor Warnings
-{$WARN DUPLICATE_CTOR_DTOR OFF}
-
- // XE3 and Above
+  // XE3 and Above
 {$IF CompilerVersion >= 24.0}
    {$DEFINE DELPHIXE3_UP}
    {$LEGACYIFEND ON}
@@ -100,7 +81,6 @@
   // XE2 and Above
 {$IF CompilerVersion >= 23.0}
    {$DEFINE DELPHIXE2_UP}
-   {$DEFINE HAS_UNITSCOPE}
 {$IFEND}
 
  // XE4 and Above
@@ -112,6 +92,8 @@
   // XE7 and Above
 {$IF CompilerVersion >= 28.0}
    {$DEFINE DELPHIXE7_UP}
+   {$DEFINE HAS_DELPHI_PPL} // Has Delphi Parallel Programming Library
+   {$DEFINE HAS_DELPHI_NET_ENCODING}
 {$IFEND}
 
   // 2010 and Above
@@ -119,8 +101,25 @@
    {$MESSAGE ERROR 'This Library requires Delphi 2010 or higher.'}
 {$ENDIF}
 
+{$DEFINE USE_UNROLLED_VARIANT}
+
+// This option is needed to enable code browsing (aka Ctrl+Click)
+// It does not affect the binary size or generated code
+{$DEFINITIONINFO ON}
+
+// Disable Overflow and RangeChecks.
+{$OVERFLOWCHECKS OFF}
+{$RANGECHECKS OFF}
+
+ // Enable Pointer Math
+{$POINTERMATH ON}
+
+// Disable String Checks
+{$STRINGCHECKS OFF}
+
+// Disable Duplicate Constructor Warnings
+{$WARN DUPLICATE_CTOR_DTOR OFF}
 
 {$ENDIF DELPHI}
 
 (* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *)
-

+ 33 - 31
src/libraries/hashlib4pascal/HlpAP.pas

@@ -15,15 +15,15 @@ uses
 type
   TAP = class sealed(THash, IHash32, ITransformBlock)
   strict private
-
-    Fm_hash: UInt32;
-    Fm_index: Int32;
+  var
+    FHash: UInt32;
+    FIndex: Int32;
 
   public
     constructor Create();
     procedure Initialize(); override;
-    procedure TransformBytes(const a_data: THashLibByteArray;
-      a_index, a_length: Int32); override;
+    procedure TransformBytes(const AData: THashLibByteArray;
+      AIndex, ALength: Int32); override;
     function TransformFinal(): IHashResult; override;
     function Clone(): IHash; override;
 
@@ -35,12 +35,12 @@ implementation
 
 function TAP.Clone(): IHash;
 var
-  HashInstance: TAP;
+  LHashInstance: TAP;
 begin
-  HashInstance := TAP.Create();
-  HashInstance.Fm_hash := Fm_hash;
-  HashInstance.Fm_index := Fm_index;
-  result := HashInstance as IHash;
+  LHashInstance := TAP.Create();
+  LHashInstance.FHash := FHash;
+  LHashInstance.FIndex := FIndex;
+  result := LHashInstance as IHash;
   result.BufferSize := BufferSize;
 end;
 
@@ -51,41 +51,43 @@ end;
 
 procedure TAP.Initialize;
 begin
-  Fm_hash := $AAAAAAAA;
-  Fm_index := 0;
+  FHash := $AAAAAAAA;
+  FIndex := 0;
 end;
 
-procedure TAP.TransformBytes(const a_data: THashLibByteArray;
-  a_index, a_length: Int32);
+procedure TAP.TransformBytes(const AData: THashLibByteArray;
+  AIndex, ALength: Int32);
 var
-  i: Int32;
+  LIdx: Int32;
 begin
 {$IFDEF DEBUG}
-  System.Assert(a_index >= 0);
-  System.Assert(a_length >= 0);
-  System.Assert(a_index + a_length <= System.Length(a_data));
+  System.Assert(AIndex >= 0);
+  System.Assert(ALength >= 0);
+  System.Assert(AIndex + ALength <= System.Length(AData));
 {$ENDIF DEBUG}
-  i := a_index;
-  while a_length > 0 do
+  LIdx := AIndex;
+  while ALength > 0 do
   begin
 
-    if (Fm_index and 1) = 0 then
-      Fm_hash := Fm_hash xor ((Fm_hash shl 7) xor a_data[i] * (Fm_hash shr 3))
-
+    if (FIndex and 1) = 0 then
+    begin
+      FHash := FHash xor ((FHash shl 7) xor AData[LIdx] * (FHash shr 3))
+    end
     else
-
-      Fm_hash := Fm_hash xor
-        (not((Fm_hash shl 11) xor a_data[i] xor (Fm_hash shr 5)));
-
-    System.Inc(Fm_index);
-    System.Inc(i);
-    System.Dec(a_length);
+    begin
+      FHash := FHash xor
+        (not((FHash shl 11) xor AData[LIdx] xor (FHash shr 5)));
+    end;
+
+    System.Inc(FIndex);
+    System.Inc(LIdx);
+    System.Dec(ALength);
   end;
 end;
 
 function TAP.TransformFinal: IHashResult;
 begin
-  result := THashResult.Create(Fm_hash);
+  result := THashResult.Create(FHash);
   Initialize();
 end;
 

+ 39 - 44
src/libraries/hashlib4pascal/HlpAdler32.pas

@@ -13,12 +13,11 @@ uses
   HlpIHashResult;
 
 type
-  TAdler32 = class sealed(THash, IChecksum, IHash32,
-    ITransformBlock)
+  TAdler32 = class sealed(THash, IChecksum, IHash32, ITransformBlock)
 
   strict private
-
-    Fm_a, Fm_b: UInt32;
+  var
+    FA, FB: UInt32;
 
   const
     MOD_ADLER = UInt32(65521);
@@ -26,8 +25,8 @@ type
   public
     constructor Create();
     procedure Initialize(); override;
-    procedure TransformBytes(const a_data: THashLibByteArray;
-      a_index, a_length: Int32); override;
+    procedure TransformBytes(const AData: THashLibByteArray;
+      AIndex, ALength: Int32); override;
     function TransformFinal: IHashResult; override;
     function Clone(): IHash; override;
 
@@ -39,79 +38,75 @@ implementation
 
 function TAdler32.Clone(): IHash;
 var
-  HashInstance: TAdler32;
+  LHashInstance: TAdler32;
 begin
-  HashInstance := TAdler32.Create();
-  HashInstance.Fm_a := Fm_a;
-  HashInstance.Fm_b := Fm_b;
-  result := HashInstance as IHash;
+  LHashInstance := TAdler32.Create();
+  LHashInstance.FA := FA;
+  LHashInstance.FB := FB;
+  result := LHashInstance as IHash;
   result.BufferSize := BufferSize;
 end;
 
 constructor TAdler32.Create;
 begin
   Inherited Create(4, 1);
-
 end;
 
 procedure TAdler32.Initialize;
 begin
-  Fm_a := 1;
-  Fm_b := 0;
+  FA := 1;
+  FB := 0;
 end;
 
-procedure TAdler32.TransformBytes(const a_data: THashLibByteArray;
-  a_index, a_length: Int32);
+procedure TAdler32.TransformBytes(const AData: THashLibByteArray;
+  AIndex, ALength: Int32);
 var
-  i, n: Int32;
-
+  LIdx, LN: Int32;
 begin
 {$IFDEF DEBUG}
-  System.Assert(a_index >= 0);
-  System.Assert(a_length >= 0);
-  System.Assert(a_index + a_length <= System.Length(a_data));
+  System.Assert(AIndex >= 0);
+  System.Assert(ALength >= 0);
+  System.Assert(AIndex + ALength <= System.Length(AData));
 {$ENDIF DEBUG}
-  i := a_index;
+  LIdx := AIndex;
 
-  { while a_length > 0 do
+  { while ALength > 0 do
     begin
-    Fm_a := (Fm_a + a_data[i]) mod MOD_ADLER;
-    Fm_b := (Fm_b + Fm_a) mod MOD_ADLER;
-    System.Inc(i);
-    System.Dec(a_length);
+    FA := (FA + AData[LIdx]) mod MOD_ADLER;
+    FB := (FB + FA) mod MOD_ADLER;
+    System.Inc(LIdx);
+    System.Dec(ALength);
     end; }
 
   // lifted from PngEncoder Adler32.cs
 
-  while a_length > 0 do
+  while ALength > 0 do
   begin
     // We can defer the modulo operation:
-    // Fm_a maximally grows from 65521 to 65521 + 255 * 3800
-    // Fm_b maximally grows by3800 * median(Fm_a) = 2090079800 < 2^31
-    n := 3800;
-    if (n > a_length) then
+    // FA maximally grows from 65521 to 65521 + 255 * 3800
+    // FB maximally grows by3800 * median(FA) = 2090079800 < 2^31
+    LN := 3800;
+    if (LN > ALength) then
     begin
-      n := a_length;
+      LN := ALength;
     end;
-    a_length := a_length - n;
+    ALength := ALength - LN;
 
-    while (n - 1) >= 0 do
+    while (LN - 1) >= 0 do
     begin
-      Fm_a := (Fm_a + a_data[i]);
-      Fm_b := (Fm_b + Fm_a);
-      System.Inc(i);
-      System.Dec(n);
+      FA := (FA + AData[LIdx]);
+      FB := (FB + FA);
+      System.Inc(LIdx);
+      System.Dec(LN);
     end;
-    Fm_a := Fm_a mod MOD_ADLER;
-    Fm_b := Fm_b mod MOD_ADLER;
-
+    FA := FA mod MOD_ADLER;
+    FB := FB mod MOD_ADLER;
   end;
-
 end;
 
 function TAdler32.TransformFinal: IHashResult;
 begin
-  result := THashResult.Create(UInt32((Fm_b shl 16) or Fm_a));
+  result := THashResult.Create(UInt32((FB shl 16) or FA));
   Initialize();
 end;
 

+ 56 - 55
src/libraries/hashlib4pascal/HlpArrayUtils.pas

@@ -13,26 +13,29 @@ type
 
   public
 
-    class function AreEqual(const A, B: THashLibByteArray): Boolean;
-      overload; static;
+    class function AreEqual(const ABuffer1, ABuffer2: THashLibByteArray)
+      : Boolean; overload; static;
 
-    class function ConstantTimeAreEqual(const a_ar1, a_ar2: THashLibByteArray)
-      : Boolean; static;
+    class function ConstantTimeAreEqual(const ABuffer1,
+      ABuffer2: THashLibByteArray): Boolean; static;
 
-    class procedure Fill(const buf: THashLibByteArray; from, &to: Int32;
-      filler: Byte); overload; static;
+    class procedure Fill(const ABuffer: THashLibByteArray; AFrom, ATo: Int32;
+      AFiller: Byte); overload; static;
 
-    class procedure Fill(const buf: THashLibUInt32Array; from, &to: Int32;
-      filler: UInt32); overload; static;
+    class procedure Fill(const ABuffer: THashLibUInt32Array; AFrom, ATo: Int32;
+      AFiller: UInt32); overload; static;
 
-    class procedure Fill(const buf: THashLibUInt64Array; from, &to: Int32;
-      filler: UInt64); overload; static;
+    class procedure Fill(const ABuffer: THashLibUInt64Array; AFrom, ATo: Int32;
+      AFiller: UInt64); overload; static;
 
-    class procedure ZeroFill(const buf: THashLibByteArray); overload; static;
+    class procedure ZeroFill(const ABuffer: THashLibByteArray);
+      overload; static;
 
-    class procedure ZeroFill(const buf: THashLibUInt32Array); overload; static;
+    class procedure ZeroFill(const ABuffer: THashLibUInt32Array);
+      overload; static;
 
-    class procedure ZeroFill(const buf: THashLibUInt64Array); overload; static;
+    class procedure ZeroFill(const ABuffer: THashLibUInt64Array);
+      overload; static;
 
   end;
 
@@ -40,97 +43,95 @@ implementation
 
 { TArrayUtils }
 
-class function TArrayUtils.AreEqual(const A, B: THashLibByteArray): Boolean;
+class function TArrayUtils.AreEqual(const ABuffer1,
+  ABuffer2: THashLibByteArray): Boolean;
 begin
-  if System.Length(A) <> System.Length(B) then
+  if System.Length(ABuffer1) <> System.Length(ABuffer2) then
   begin
     Result := false;
     Exit;
   end;
-
-  Result := CompareMem(A, B, System.Length(A) * System.SizeOf(Byte));
+  Result := CompareMem(ABuffer1, ABuffer2, System.Length(ABuffer1) *
+    System.SizeOf(Byte));
 end;
 
 {$B+}
 
-class function TArrayUtils.ConstantTimeAreEqual(const a_ar1,
-  a_ar2: THashLibByteArray): Boolean;
+class function TArrayUtils.ConstantTimeAreEqual(const ABuffer1,
+  ABuffer2: THashLibByteArray): Boolean;
 var
-  I: Int32;
-  diff: UInt32;
-
+  LIdx: Int32;
+  LDiff: UInt32;
 begin
-  diff := UInt32(System.Length(a_ar1)) xor UInt32(System.Length(a_ar2));
-
-  I := 0;
-
-  while (I <= System.High(a_ar1)) and (I <= System.High(a_ar2)) do
+  LDiff := UInt32(System.Length(ABuffer1)) xor UInt32(System.Length(ABuffer2));
+  LIdx := 0;
+  while (LIdx <= System.High(ABuffer1)) and (LIdx <= System.High(ABuffer2)) do
   begin
-    diff := diff or (UInt32(a_ar1[I] xor a_ar2[I]));
-    System.Inc(I);
+    LDiff := LDiff or (UInt32(ABuffer1[LIdx] xor ABuffer2[LIdx]));
+    System.Inc(LIdx);
   end;
-
-  Result := diff = 0;
+  Result := LDiff = 0;
 end;
 
 {$B-}
 
-class procedure TArrayUtils.Fill(const buf: THashLibByteArray; from, &to: Int32;
-  filler: Byte);
+class procedure TArrayUtils.Fill(const ABuffer: THashLibByteArray;
+  AFrom, ATo: Int32; AFiller: Byte);
 begin
-  if buf <> Nil then
+  if ABuffer <> Nil then
   begin
-    System.FillChar(buf[from], (&to - from) * System.SizeOf(Byte), filler);
+    System.FillChar(ABuffer[AFrom], (ATo - AFrom) *
+      System.SizeOf(Byte), AFiller);
   end;
 end;
 
-class procedure TArrayUtils.Fill(const buf: THashLibUInt32Array;
-  from, &to: Int32; filler: UInt32);
+class procedure TArrayUtils.Fill(const ABuffer: THashLibUInt32Array;
+  AFrom, ATo: Int32; AFiller: UInt32);
 begin
-  if buf <> Nil then
+  if ABuffer <> Nil then
   begin
 {$IFDEF FPC}
-    System.FillDWord(buf[from], (&to - from), filler);
+    System.FillDWord(ABuffer[AFrom], (ATo - AFrom), AFiller);
 {$ELSE}
-    while from < &to do
+    while AFrom < ATo do
     begin
-      buf[from] := filler;
-      System.Inc(from);
+      ABuffer[AFrom] := AFiller;
+      System.Inc(AFrom);
     end;
 {$ENDIF}
   end;
 end;
 
-class procedure TArrayUtils.Fill(const buf: THashLibUInt64Array;
-  from, &to: Int32; filler: UInt64);
+class procedure TArrayUtils.Fill(const ABuffer: THashLibUInt64Array;
+  AFrom, ATo: Int32; AFiller: UInt64);
 begin
-  if buf <> Nil then
+  if ABuffer <> Nil then
   begin
 {$IFDEF FPC}
-    System.FillQWord(buf[from], (&to - from), filler);
+    System.FillQWord(ABuffer[AFrom], (ATo - AFrom), AFiller);
 {$ELSE}
-    while from < &to do
+    while AFrom < ATo do
     begin
-      buf[from] := filler;
-      System.Inc(from);
+      ABuffer[AFrom] := AFiller;
+      System.Inc(AFrom);
     end;
 {$ENDIF}
   end;
 end;
 
-class procedure TArrayUtils.ZeroFill(const buf: THashLibByteArray);
+class procedure TArrayUtils.ZeroFill(const ABuffer: THashLibByteArray);
 begin
-  TArrayUtils.Fill(buf, 0, System.Length(buf), Byte(0));
+  TArrayUtils.Fill(ABuffer, 0, System.Length(ABuffer), Byte(0));
 end;
 
-class procedure TArrayUtils.ZeroFill(const buf: THashLibUInt32Array);
+class procedure TArrayUtils.ZeroFill(const ABuffer: THashLibUInt32Array);
 begin
-  TArrayUtils.Fill(buf, 0, System.Length(buf), UInt32(0));
+  TArrayUtils.Fill(ABuffer, 0, System.Length(ABuffer), UInt32(0));
 end;
 
-class procedure TArrayUtils.ZeroFill(const buf: THashLibUInt64Array);
+class procedure TArrayUtils.ZeroFill(const ABuffer: THashLibUInt64Array);
 begin
-  TArrayUtils.Fill(buf, 0, System.Length(buf), UInt64(0));
+  TArrayUtils.Fill(ABuffer, 0, System.Length(ABuffer), UInt64(0));
 end;
 
 end.

+ 21 - 22
src/libraries/hashlib4pascal/HlpBKDR.pas

@@ -16,8 +16,8 @@ type
 
   TBKDR = class sealed(THash, IHash32, ITransformBlock)
   strict private
-
-    Fm_hash: UInt32;
+  var
+    FHash: UInt32;
 
   const
     SEED = Int32(131);
@@ -25,8 +25,8 @@ type
   public
     constructor Create();
     procedure Initialize(); override;
-    procedure TransformBytes(const a_data: THashLibByteArray;
-      a_index, a_length: Int32); override;
+    procedure TransformBytes(const AData: THashLibByteArray;
+      AIndex, ALength: Int32); override;
     function TransformFinal(): IHashResult; override;
     function Clone(): IHash; override;
   end;
@@ -37,11 +37,11 @@ implementation
 
 function TBKDR.Clone(): IHash;
 var
-  HashInstance: TBKDR;
+  LHashInstance: TBKDR;
 begin
-  HashInstance := TBKDR.Create();
-  HashInstance.Fm_hash := Fm_hash;
-  result := HashInstance as IHash;
+  LHashInstance := TBKDR.Create();
+  LHashInstance.FHash := FHash;
+  result := LHashInstance as IHash;
   result.BufferSize := BufferSize;
 end;
 
@@ -52,32 +52,31 @@ end;
 
 procedure TBKDR.Initialize;
 begin
-  Fm_hash := 0;
+  FHash := 0;
 end;
 
-procedure TBKDR.TransformBytes(const a_data: THashLibByteArray;
-  a_index, a_length: Int32);
+procedure TBKDR.TransformBytes(const AData: THashLibByteArray;
+  AIndex, ALength: Int32);
 var
-  i: Int32;
+  LIdx: Int32;
 begin
 {$IFDEF DEBUG}
-  System.Assert(a_index >= 0);
-  System.Assert(a_length >= 0);
-  System.Assert(a_index + a_length <= System.Length(a_data));
+  System.Assert(AIndex >= 0);
+  System.Assert(ALength >= 0);
+  System.Assert(AIndex + ALength <= System.Length(AData));
 {$ENDIF DEBUG}
-  i := a_index;
-  while a_length > 0 do
+  LIdx := AIndex;
+  while ALength > 0 do
   begin
-    Fm_hash := (Fm_hash * UInt32(SEED)) + a_data[i];
-    System.Inc(i);
-    System.Dec(a_length);
+    FHash := (FHash * UInt32(SEED)) + AData[LIdx];
+    System.Inc(LIdx);
+    System.Dec(ALength);
   end;
-
 end;
 
 function TBKDR.TransformFinal: IHashResult;
 begin
-  result := THashResult.Create(Fm_hash);
+  result := THashResult.Create(FHash);
   Initialize();
 end;
 

+ 21 - 23
src/libraries/hashlib4pascal/HlpBernstein.pas

@@ -15,14 +15,14 @@ uses
 type
   TBernstein = class sealed(THash, IHash32, ITransformBlock)
   strict private
-
-    Fm_hash: UInt32;
+  var
+    FHash: UInt32;
 
   public
     constructor Create();
     procedure Initialize(); override;
-    procedure TransformBytes(const a_data: THashLibByteArray;
-      a_index, a_length: Int32); override;
+    procedure TransformBytes(const AData: THashLibByteArray;
+      AIndex, ALength: Int32); override;
     function TransformFinal(): IHashResult; override;
     function Clone(): IHash; override;
   end;
@@ -33,48 +33,46 @@ implementation
 
 function TBernstein.Clone(): IHash;
 var
-  HashInstance: TBernstein;
+  LHashInstance: TBernstein;
 begin
-  HashInstance := TBernstein.Create();
-  HashInstance.Fm_hash := Fm_hash;
-  result := HashInstance as IHash;
+  LHashInstance := TBernstein.Create();
+  LHashInstance.FHash := FHash;
+  result := LHashInstance as IHash;
   result.BufferSize := BufferSize;
 end;
 
 constructor TBernstein.Create;
 begin
   Inherited Create(4, 1);
-
 end;
 
 procedure TBernstein.Initialize;
 begin
-  Fm_hash := 5381;
+  FHash := 5381;
 end;
 
-procedure TBernstein.TransformBytes(const a_data: THashLibByteArray;
-  a_index, a_length: Int32);
+procedure TBernstein.TransformBytes(const AData: THashLibByteArray;
+  AIndex, ALength: Int32);
 var
-  i: Int32;
+  LIdx: Int32;
 begin
 {$IFDEF DEBUG}
-  System.Assert(a_index >= 0);
-  System.Assert(a_length >= 0);
-  System.Assert(a_index + a_length <= System.Length(a_data));
+  System.Assert(AIndex >= 0);
+  System.Assert(ALength >= 0);
+  System.Assert(AIndex + ALength <= System.Length(AData));
 {$ENDIF DEBUG}
-  i := a_index;
-  while a_length > 0 do
+  LIdx := AIndex;
+  while ALength > 0 do
   begin
-    Fm_hash := (Fm_hash * 33) + a_data[i];
-    System.Inc(i);
-    System.Dec(a_length);
+    FHash := (FHash * 33) + AData[LIdx];
+    System.Inc(LIdx);
+    System.Dec(ALength);
   end;
-
 end;
 
 function TBernstein.TransformFinal: IHashResult;
 begin
-  result := THashResult.Create(Fm_hash);
+  result := THashResult.Create(FHash);
   Initialize();
 end;
 

+ 21 - 23
src/libraries/hashlib4pascal/HlpBernstein1.pas

@@ -15,14 +15,14 @@ uses
 type
   TBernstein1 = class sealed(THash, IHash32, ITransformBlock)
   strict private
-
-    Fm_hash: UInt32;
+  var
+    FHash: UInt32;
 
   public
     constructor Create();
     procedure Initialize(); override;
-    procedure TransformBytes(const a_data: THashLibByteArray;
-      a_index, a_length: Int32); override;
+    procedure TransformBytes(const AData: THashLibByteArray;
+      AIndex, ALength: Int32); override;
     function TransformFinal(): IHashResult; override;
     function Clone(): IHash; override;
   end;
@@ -33,48 +33,46 @@ implementation
 
 function TBernstein1.Clone(): IHash;
 var
-  HashInstance: TBernstein1;
+  LHashInstance: TBernstein1;
 begin
-  HashInstance := TBernstein1.Create();
-  HashInstance.Fm_hash := Fm_hash;
-  result := HashInstance as IHash;
+  LHashInstance := TBernstein1.Create();
+  LHashInstance.FHash := FHash;
+  result := LHashInstance as IHash;
   result.BufferSize := BufferSize;
 end;
 
 constructor TBernstein1.Create;
 begin
   Inherited Create(4, 1);
-
 end;
 
 procedure TBernstein1.Initialize;
 begin
-  Fm_hash := 5381;
+  FHash := 5381;
 end;
 
-procedure TBernstein1.TransformBytes(const a_data: THashLibByteArray;
-  a_index, a_length: Int32);
+procedure TBernstein1.TransformBytes(const AData: THashLibByteArray;
+  AIndex, ALength: Int32);
 var
-  i: Int32;
+  LIdx: Int32;
 begin
 {$IFDEF DEBUG}
-  System.Assert(a_index >= 0);
-  System.Assert(a_length >= 0);
-  System.Assert(a_index + a_length <= System.Length(a_data));
+  System.Assert(AIndex >= 0);
+  System.Assert(ALength >= 0);
+  System.Assert(AIndex + ALength <= System.Length(AData));
 {$ENDIF DEBUG}
-  i := a_index;
-  while a_length > 0 do
+  LIdx := AIndex;
+  while ALength > 0 do
   begin
-    Fm_hash := (Fm_hash * 33) xor a_data[i];
-    System.Inc(i);
-    System.Dec(a_length);
+    FHash := (FHash * 33) xor AData[LIdx];
+    System.Inc(LIdx);
+    System.Dec(ALength);
   end;
-
 end;
 
 function TBernstein1.TransformFinal: IHashResult;
 begin
-  result := THashResult.Create(Fm_hash);
+  result := THashResult.Create(FHash);
   Initialize();
 end;
 

+ 219 - 282
src/libraries/hashlib4pascal/HlpBitConverter.pas

@@ -18,7 +18,7 @@ type
 
       FIsLittleEndian: Boolean;
 
-    class function GetHexValue(i: Int32): Char; static; inline;
+    class function GetHexValue(AValue: Int32): Char; static; inline;
     class function GetIsLittleEndian(): Boolean; static; inline;
     class constructor BitConverter();
 
@@ -28,58 +28,58 @@ type
 
     { ==================================================================== }
 
-    class function GetBytes(value: Boolean): THashLibByteArray; overload;
+    class function GetBytes(AValue: Boolean): THashLibByteArray; overload;
       static; inline;
-    class function GetBytes(value: Char): THashLibByteArray; overload;
+    class function GetBytes(AValue: Char): THashLibByteArray; overload;
       static; inline;
-    class function GetBytes(value: Double): THashLibByteArray; overload;
+    class function GetBytes(AValue: Double): THashLibByteArray; overload;
       static; inline;
-    class function GetBytes(value: Int16): THashLibByteArray; overload;
+    class function GetBytes(AValue: Int16): THashLibByteArray; overload;
       static; inline;
-    class function GetBytes(value: Int32): THashLibByteArray; overload;
+    class function GetBytes(AValue: Int32): THashLibByteArray; overload;
       static; inline;
-    class function GetBytes(value: Int64): THashLibByteArray; overload;
+    class function GetBytes(AValue: Int64): THashLibByteArray; overload;
       static; inline;
-    class function GetBytes(value: Single): THashLibByteArray; overload;
+    class function GetBytes(AValue: Single): THashLibByteArray; overload;
       static; inline;
-    class function GetBytes(value: UInt8): THashLibByteArray; overload;
+    class function GetBytes(AValue: UInt8): THashLibByteArray; overload;
       static; inline;
-    class function GetBytes(value: UInt16): THashLibByteArray; overload;
+    class function GetBytes(AValue: UInt16): THashLibByteArray; overload;
       static; inline;
-    class function GetBytes(value: UInt32): THashLibByteArray; overload;
+    class function GetBytes(AValue: UInt32): THashLibByteArray; overload;
       static; inline;
-    class function GetBytes(value: UInt64): THashLibByteArray; overload;
+    class function GetBytes(AValue: UInt64): THashLibByteArray; overload;
       static; inline;
 
     { ==================================================================== }
 
-    class function ToBoolean(const value: THashLibByteArray; StartIndex: Int32)
-      : Boolean; static; inline;
-    class function ToChar(const value: THashLibByteArray; StartIndex: Int32)
+    class function ToBoolean(const AValue: THashLibByteArray;
+      AStartIndex: Int32): Boolean; static; inline;
+    class function ToChar(const AValue: THashLibByteArray; AStartIndex: Int32)
       : Char; static; inline;
-    class function ToDouble(const value: THashLibByteArray; StartIndex: Int32)
+    class function ToDouble(const AValue: THashLibByteArray; AStartIndex: Int32)
       : Double; static; inline;
-    class function ToInt16(const value: THashLibByteArray; StartIndex: Int32)
+    class function ToInt16(const AValue: THashLibByteArray; AStartIndex: Int32)
       : Int16; static; inline;
-    class function ToInt32(const value: THashLibByteArray; StartIndex: Int32)
+    class function ToInt32(const AValue: THashLibByteArray; AStartIndex: Int32)
       : Int32; static; inline;
-    class function ToInt64(const value: THashLibByteArray; StartIndex: Int32)
+    class function ToInt64(const AValue: THashLibByteArray; AStartIndex: Int32)
       : Int64; static; inline;
-    class function ToSingle(const value: THashLibByteArray; StartIndex: Int32)
+    class function ToSingle(const AValue: THashLibByteArray; AStartIndex: Int32)
       : Single; static; inline;
-    class function ToString(const value: THashLibByteArray): String;
+    class function ToString(const AValue: THashLibByteArray): String;
       reintroduce; overload; static;
-    class function ToString(const value: THashLibByteArray; StartIndex: Int32)
+    class function ToString(const AValue: THashLibByteArray; AStartIndex: Int32)
       : String; reintroduce; overload; static;
-    class function ToString(const value: THashLibByteArray;
-      StartIndex, &Length: Int32): String; reintroduce; overload; static;
-    class function ToUInt8(const value: THashLibByteArray; StartIndex: Int32)
+    class function ToString(const AValue: THashLibByteArray;
+      AStartIndex, ALength: Int32): String; reintroduce; overload; static;
+    class function ToUInt8(const AValue: THashLibByteArray; AStartIndex: Int32)
       : UInt8; static; inline;
-    class function ToUInt16(const value: THashLibByteArray; StartIndex: Int32)
+    class function ToUInt16(const AValue: THashLibByteArray; AStartIndex: Int32)
       : UInt16; static; inline;
-    class function ToUInt32(const value: THashLibByteArray; StartIndex: Int32)
+    class function ToUInt32(const AValue: THashLibByteArray; AStartIndex: Int32)
       : UInt32; static; inline;
-    class function ToUInt64(const value: THashLibByteArray; StartIndex: Int32)
+    class function ToUInt64(const AValue: THashLibByteArray; AStartIndex: Int32)
       : UInt64; static; inline;
 
   end;
@@ -90,127 +90,114 @@ implementation
 
 class constructor TBitConverter.BitConverter;
 var
-  IntValue: Int32;
-  PIIntValueAddress: PInteger;
-  PBIntValueAddress: PByte;
-  ByteValue: Byte;
+  LInt32Value: Int32;
 begin
-  IntValue := 1;
-  PIIntValueAddress := @IntValue;
-  PBIntValueAddress := PByte(PIIntValueAddress);
-  ByteValue := PBIntValueAddress^;
-  FIsLittleEndian := ByteValue = 1;
+  LInt32Value := 1;
+  FIsLittleEndian := (PByte((@LInt32Value))^) = 1;
 end;
 
 { ==================================================================== }
 
-class function TBitConverter.GetBytes(value: Int16): THashLibByteArray;
+class function TBitConverter.GetBytes(AValue: Int16): THashLibByteArray;
 begin
-
-  // System.SetLength(result, System.SizeOf(value));
-  // PSmallInt(@result[0])^ := value;
-  System.SetLength(result, System.SizeOf(value));
-  System.Move(value, result[0], System.SizeOf(value));
+  // System.SetLength(result, System.SizeOf(AValue));
+  // PSmallInt(@result[0])^ := AValue;
+  System.SetLength(result, System.SizeOf(AValue));
+  System.Move(AValue, result[0], System.SizeOf(AValue));
 end;
 
-class function TBitConverter.GetBytes(value: Int32): THashLibByteArray;
+class function TBitConverter.GetBytes(AValue: Int32): THashLibByteArray;
 begin
-
-  // System.SetLength(result, System.SizeOf(value));
-  // PInteger(@result[0])^ := value;
-  System.SetLength(result, System.SizeOf(value));
-  System.Move(value, result[0], System.SizeOf(value));
-
+  // System.SetLength(result, System.SizeOf(AValue));
+  // PInteger(@result[0])^ := AValue;
+  System.SetLength(result, System.SizeOf(AValue));
+  System.Move(AValue, result[0], System.SizeOf(AValue));
 end;
 
-class function TBitConverter.GetBytes(value: Double): THashLibByteArray;
+class function TBitConverter.GetBytes(AValue: Double): THashLibByteArray;
 begin
-
-  // System.SetLength(result, System.SizeOf(value));
-  // PDouble(@result[0])^ := value;
-  System.SetLength(result, System.SizeOf(value));
-  System.Move(value, result[0], System.SizeOf(value));
+  // System.SetLength(result, System.SizeOf(AValue));
+  // PDouble(@result[0])^ := AValue;
+  System.SetLength(result, System.SizeOf(AValue));
+  System.Move(AValue, result[0], System.SizeOf(AValue));
 end;
 
-class function TBitConverter.GetBytes(value: Boolean): THashLibByteArray;
+class function TBitConverter.GetBytes(AValue: Boolean): THashLibByteArray;
 begin
-
-  // System.SetLength(result, System.SizeOf(value));
-  // PBoolean(@result[0])^ := value;
-  System.SetLength(result, System.SizeOf(value));
-  System.Move(value, result[0], System.SizeOf(value));
+  // System.SetLength(result, System.SizeOf(AValue));
+  // PBoolean(@result[0])^ := AValue;
+  System.SetLength(result, System.SizeOf(AValue));
+  System.Move(AValue, result[0], System.SizeOf(AValue));
 end;
 
-class function TBitConverter.GetBytes(value: Char): THashLibByteArray;
+class function TBitConverter.GetBytes(AValue: Char): THashLibByteArray;
 begin
-
-  // System.SetLength(result, System.SizeOf(value));
-  // PChar(@result[0])^ := value;
-  System.SetLength(result, System.SizeOf(value));
-  System.Move(value, result[0], System.SizeOf(value));
+  // System.SetLength(result, System.SizeOf(AValue));
+  // PChar(@result[0])^ := AValue;
+  System.SetLength(result, System.SizeOf(AValue));
+  System.Move(AValue, result[0], System.SizeOf(AValue));
 end;
 
-class function TBitConverter.GetBytes(value: UInt8): THashLibByteArray;
+class function TBitConverter.GetBytes(AValue: UInt8): THashLibByteArray;
 begin
-  // System.SetLength(result, System.SizeOf(value));
-  // PByte(@result[0])^ := value;
-  System.SetLength(result, System.SizeOf(value));
-  System.Move(value, result[0], System.SizeOf(value));
+  // System.SetLength(result, System.SizeOf(AValue));
+  // PByte(@result[0])^ := AValue;
+  System.SetLength(result, System.SizeOf(AValue));
+  System.Move(AValue, result[0], System.SizeOf(AValue));
 end;
 
-class function TBitConverter.GetBytes(value: UInt16): THashLibByteArray;
+class function TBitConverter.GetBytes(AValue: UInt16): THashLibByteArray;
 begin
-
-  // System.SetLength(result, System.SizeOf(value));
-  // PWord(@result[0])^ := value;
-  System.SetLength(result, System.SizeOf(value));
-  System.Move(value, result[0], System.SizeOf(value));
+  // System.SetLength(result, System.SizeOf(AValue));
+  // PWord(@result[0])^ := AValue;
+  System.SetLength(result, System.SizeOf(AValue));
+  System.Move(AValue, result[0], System.SizeOf(AValue));
 end;
 
-class function TBitConverter.GetBytes(value: Int64): THashLibByteArray;
+class function TBitConverter.GetBytes(AValue: Int64): THashLibByteArray;
 begin
-
-  // System.SetLength(result, System.SizeOf(value));
-  // PInt64(@result[0])^ := value;
-  System.SetLength(result, System.SizeOf(value));
-  System.Move(value, result[0], System.SizeOf(value));
+  // System.SetLength(result, System.SizeOf(AValue));
+  // PInt64(@result[0])^ := AValue;
+  System.SetLength(result, System.SizeOf(AValue));
+  System.Move(AValue, result[0], System.SizeOf(AValue));
 end;
 
-class function TBitConverter.GetBytes(value: Single): THashLibByteArray;
+class function TBitConverter.GetBytes(AValue: Single): THashLibByteArray;
 begin
-
-  // System.SetLength(result, System.SizeOf(value));
-  // PSingle(@result[0])^ := value;
-  System.SetLength(result, System.SizeOf(value));
-  System.Move(value, result[0], System.SizeOf(value));
+  // System.SetLength(result, System.SizeOf(AValue));
+  // PSingle(@result[0])^ := AValue;
+  System.SetLength(result, System.SizeOf(AValue));
+  System.Move(AValue, result[0], System.SizeOf(AValue));
 end;
 
-class function TBitConverter.GetBytes(value: UInt32): THashLibByteArray;
+class function TBitConverter.GetBytes(AValue: UInt32): THashLibByteArray;
 begin
-
-  // System.SetLength(result, System.SizeOf(value));
-  // PCardinal(@result[0])^ := value;
-  System.SetLength(result, System.SizeOf(value));
-  System.Move(value, result[0], System.SizeOf(value));
+  // System.SetLength(result, System.SizeOf(AValue));
+  // PCardinal(@result[0])^ := AValue;
+  System.SetLength(result, System.SizeOf(AValue));
+  System.Move(AValue, result[0], System.SizeOf(AValue));
 end;
 
-class function TBitConverter.GetBytes(value: UInt64): THashLibByteArray;
+class function TBitConverter.GetBytes(AValue: UInt64): THashLibByteArray;
 begin
-
-  // System.SetLength(result, System.SizeOf(value));
-  // PUInt64(@result[0])^ := value;
-  System.SetLength(result, System.SizeOf(value));
-  System.Move(value, result[0], System.SizeOf(value));
+  // System.SetLength(result, System.SizeOf(AValue));
+  // PUInt64(@result[0])^ := AValue;
+  System.SetLength(result, System.SizeOf(AValue));
+  System.Move(AValue, result[0], System.SizeOf(AValue));
 end;
 
 { ==================================================================== }
 
-class function TBitConverter.GetHexValue(i: Int32): Char;
+class function TBitConverter.GetHexValue(AValue: Int32): Char;
 begin
-  if i < 10 then
-    result := Char(i + System.Ord('0'))
+  if AValue < 10 then
+  begin
+    result := Char(AValue + System.Ord('0'))
+  end
   else
-    result := Char((i - 10) + System.Ord('A'));
+  begin
+    result := Char((AValue - 10) + System.Ord('A'));
+  end;
 end;
 
 class function TBitConverter.GetIsLittleEndian: Boolean;
@@ -220,278 +207,228 @@ end;
 
 { ==================================================================== }
 
-class function TBitConverter.ToBoolean(const value: THashLibByteArray;
-  StartIndex: Int32): Boolean;
+class function TBitConverter.ToBoolean(const AValue: THashLibByteArray;
+  AStartIndex: Int32): Boolean;
 begin
-  // result := PBoolean(@value[StartIndex])^;
-  System.Move(value[StartIndex], result, System.SizeOf(result));
-
+  // result := PBoolean(@AValue[AStartIndex])^;
+  System.Move(AValue[AStartIndex], result, System.SizeOf(result));
 end;
 
-class function TBitConverter.ToChar(const value: THashLibByteArray;
-  StartIndex: Int32): Char;
+class function TBitConverter.ToChar(const AValue: THashLibByteArray;
+  AStartIndex: Int32): Char;
 begin
-  // System.Move(value[StartIndex], result, System.SizeOf(result));
-
+  // System.Move(AValue[AStartIndex], result, System.SizeOf(result));
   if (IsLittleEndian) then
   begin
-    result := Char(value[StartIndex] or (value[StartIndex + 1] shl 8));
-    Exit;
+    result := Char(AValue[AStartIndex] or (AValue[AStartIndex + 1] shl 8));
   end
   else
   begin
-
-    result := Char((value[StartIndex] shl 8) or value[StartIndex + 1]);
-    Exit;
+    result := Char((AValue[AStartIndex] shl 8) or AValue[AStartIndex + 1]);
   end;
-
 end;
 
-class function TBitConverter.ToDouble(const value: THashLibByteArray;
-  StartIndex: Int32): Double;
+class function TBitConverter.ToDouble(const AValue: THashLibByteArray;
+  AStartIndex: Int32): Double;
 var
   i1, i2: Int32;
-  val: Int64;
+  LValue: Int64;
 begin
-  // System.Move(value[StartIndex], result, System.SizeOf(result));
-
+  // System.Move(AValue[AStartIndex], result, System.SizeOf(result));
   if (IsLittleEndian) then
   begin
-    i1 := value[StartIndex] or (value[StartIndex + 1] shl 8) or
-      (value[StartIndex + 2] shl 16) or (value[StartIndex + 3] shl 24);
-    i2 := (value[StartIndex + 4]) or (value[StartIndex + 5] shl 8) or
-      (value[StartIndex + 6] shl 16) or (value[StartIndex + 7] shl 24);
-    val := UInt32(i1) or (Int64(i2) shl 32);
-    result := PDouble(@val)^;
-    Exit;
+    i1 := AValue[AStartIndex] or (AValue[AStartIndex + 1] shl 8) or
+      (AValue[AStartIndex + 2] shl 16) or (AValue[AStartIndex + 3] shl 24);
+    i2 := (AValue[AStartIndex + 4]) or (AValue[AStartIndex + 5] shl 8) or
+      (AValue[AStartIndex + 6] shl 16) or (AValue[AStartIndex + 7] shl 24);
+    LValue := UInt32(i1) or (Int64(i2) shl 32);
+    result := PDouble(@LValue)^;
   end
   else
   begin
-
-    i1 := (value[StartIndex] shl 24) or (value[StartIndex + 1] shl 16) or
-      (value[StartIndex + 2] shl 8) or (value[StartIndex + 3]);
-    i2 := (value[StartIndex + 4] shl 24) or (value[StartIndex + 5] shl 16) or
-      (value[StartIndex + 6] shl 8) or (value[StartIndex + 7]);
-    val := UInt32(i2) or (Int64(i1) shl 32);
-    result := PDouble(@val)^;
-    Exit;
+    i1 := (AValue[AStartIndex] shl 24) or (AValue[AStartIndex + 1] shl 16) or
+      (AValue[AStartIndex + 2] shl 8) or (AValue[AStartIndex + 3]);
+    i2 := (AValue[AStartIndex + 4] shl 24) or (AValue[AStartIndex + 5] shl 16)
+      or (AValue[AStartIndex + 6] shl 8) or (AValue[AStartIndex + 7]);
+    LValue := UInt32(i2) or (Int64(i1) shl 32);
+    result := PDouble(@LValue)^;
   end;
-
 end;
 
-class function TBitConverter.ToInt16(const value: THashLibByteArray;
-  StartIndex: Int32): Int16;
+class function TBitConverter.ToInt16(const AValue: THashLibByteArray;
+  AStartIndex: Int32): Int16;
 begin
-
-  // System.Move(value[StartIndex], result, System.SizeOf(result));
-
+  // System.Move(AValue[AStartIndex], result, System.SizeOf(result));
   if (IsLittleEndian) then
   begin
-    result := SmallInt(value[StartIndex] or (value[StartIndex + 1] shl 8));
-    Exit;
+    result := SmallInt(AValue[AStartIndex] or (AValue[AStartIndex + 1] shl 8));
   end
   else
   begin
-
-    result := SmallInt((value[StartIndex] shl 8) or value[StartIndex + 1]);
-    Exit;
+    result := SmallInt((AValue[AStartIndex] shl 8) or AValue[AStartIndex + 1]);
   end;
-
 end;
 
-class function TBitConverter.ToInt32(const value: THashLibByteArray;
-  StartIndex: Int32): Int32;
+class function TBitConverter.ToInt32(const AValue: THashLibByteArray;
+  AStartIndex: Int32): Int32;
 begin
-  // System.Move(value[StartIndex], result, System.SizeOf(result));
-
+  // System.Move(AValue[AStartIndex], result, System.SizeOf(result));
   if (IsLittleEndian) then
   begin
-    result := value[StartIndex] or (value[StartIndex + 1] shl 8) or
-      (value[StartIndex + 2] shl 16) or (value[StartIndex + 3] shl 24);
-    Exit;
+    result := AValue[AStartIndex] or (AValue[AStartIndex + 1] shl 8) or
+      (AValue[AStartIndex + 2] shl 16) or (AValue[AStartIndex + 3] shl 24);
   end
   else
   begin
-
-    result := (value[StartIndex] shl 24) or (value[StartIndex + 1] shl 16) or
-      (value[StartIndex + 2] shl 8) or (value[StartIndex + 3]);
-    Exit;
+    result := (AValue[AStartIndex] shl 24) or (AValue[AStartIndex + 1] shl 16)
+      or (AValue[AStartIndex + 2] shl 8) or (AValue[AStartIndex + 3]);
   end;
-
 end;
 
-class function TBitConverter.ToInt64(const value: THashLibByteArray;
-  StartIndex: Int32): Int64;
+class function TBitConverter.ToInt64(const AValue: THashLibByteArray;
+  AStartIndex: Int32): Int64;
 var
   i1, i2: Int32;
 begin
-  // System.Move(value[StartIndex], result, System.SizeOf(result));
+  // System.Move(AValue[AStartIndex], result, System.SizeOf(result));
   if (IsLittleEndian) then
   begin
-    i1 := value[StartIndex] or (value[StartIndex + 1] shl 8) or
-      (value[StartIndex + 2] shl 16) or (value[StartIndex + 3] shl 24);
-    i2 := (value[StartIndex + 4]) or (value[StartIndex + 5] shl 8) or
-      (value[StartIndex + 6] shl 16) or (value[StartIndex + 7] shl 24);
+    i1 := AValue[AStartIndex] or (AValue[AStartIndex + 1] shl 8) or
+      (AValue[AStartIndex + 2] shl 16) or (AValue[AStartIndex + 3] shl 24);
+    i2 := (AValue[AStartIndex + 4]) or (AValue[AStartIndex + 5] shl 8) or
+      (AValue[AStartIndex + 6] shl 16) or (AValue[AStartIndex + 7] shl 24);
     result := UInt32(i1) or (Int64(i2) shl 32);
-    Exit;
   end
   else
   begin
-
-    i1 := (value[StartIndex] shl 24) or (value[StartIndex + 1] shl 16) or
-      (value[StartIndex + 2] shl 8) or (value[StartIndex + 3]);
-    i2 := (value[StartIndex + 4] shl 24) or (value[StartIndex + 5] shl 16) or
-      (value[StartIndex + 6] shl 8) or (value[StartIndex + 7]);
+    i1 := (AValue[AStartIndex] shl 24) or (AValue[AStartIndex + 1] shl 16) or
+      (AValue[AStartIndex + 2] shl 8) or (AValue[AStartIndex + 3]);
+    i2 := (AValue[AStartIndex + 4] shl 24) or (AValue[AStartIndex + 5] shl 16)
+      or (AValue[AStartIndex + 6] shl 8) or (AValue[AStartIndex + 7]);
     result := UInt32(i2) or (Int64(i1) shl 32);
-    Exit;
   end;
 end;
 
-class function TBitConverter.ToSingle(const value: THashLibByteArray;
-  StartIndex: Int32): Single;
+class function TBitConverter.ToSingle(const AValue: THashLibByteArray;
+  AStartIndex: Int32): Single;
 var
-  val: Int32;
+  LValue: Int32;
 begin
-  // System.Move(value[StartIndex], result, System.SizeOf(result));
+  // System.Move(AValue[AStartIndex], result, System.SizeOf(result));
   if (IsLittleEndian) then
   begin
-    val := (value[StartIndex] or (value[StartIndex + 1] shl 8) or
-      (value[StartIndex + 2] shl 16) or (value[StartIndex + 3] shl 24));
-    result := PSingle(@val)^;
-    Exit;
+    LValue := (AValue[AStartIndex] or (AValue[AStartIndex + 1] shl 8) or
+      (AValue[AStartIndex + 2] shl 16) or (AValue[AStartIndex + 3] shl 24));
+    result := PSingle(@LValue)^;
   end
   else
   begin
-    val := (value[StartIndex] shl 24) or (value[StartIndex + 1] shl 16) or
-      (value[StartIndex + 2] shl 8) or (value[StartIndex + 3]);
-    result := PSingle(@val)^;
-    Exit;
+    LValue := (AValue[AStartIndex] shl 24) or (AValue[AStartIndex + 1] shl 16)
+      or (AValue[AStartIndex + 2] shl 8) or (AValue[AStartIndex + 3]);
+    result := PSingle(@LValue)^;
   end;
-
 end;
 
-class function TBitConverter.ToString(const value: THashLibByteArray): String;
-var
-  LowVal: Int32;
+class function TBitConverter.ToUInt8(const AValue: THashLibByteArray;
+  AStartIndex: Int32): UInt8;
 begin
-  LowVal := System.Low(value);
-  result := ToString(value, LowVal);
+  // result := PByte(@AValue[AStartIndex])^;
+  System.Move(AValue[AStartIndex], result, System.SizeOf(result));
 end;
 
-class function TBitConverter.ToString(const value: THashLibByteArray;
-  StartIndex: Int32): String;
+class function TBitConverter.ToUInt16(const AValue: THashLibByteArray;
+  AStartIndex: Int32): UInt16;
 begin
-  result := ToString(value, StartIndex, System.Length(value) - StartIndex);
-end;
-
-class function TBitConverter.ToString(const value: THashLibByteArray;
-  StartIndex, &Length: Int32): String;
-
-var
-  Idx, Index, chArrayLength, LowVal: Int32;
-  chArray: THashLibCharArray;
-  b: Byte;
-
-begin
-  result := '';
-
-  chArrayLength := &Length * 3;
-
-  System.SetLength(chArray, chArrayLength);
-  Idx := 0;
-  Index := StartIndex;
-  while Idx < chArrayLength do
-  begin
-    b := value[Index];
-    System.Inc(Index);
-
-    chArray[Idx] := GetHexValue(b shr 4);
-    chArray[Idx + 1] := GetHexValue(b and 15);
-    chArray[Idx + 2] := '-';
-
-    System.Inc(Idx, 3);
-  end;
-
-  LowVal := System.Low(chArray);
-
-  System.SetString(result, PChar(@chArray[LowVal]), System.Length(chArray) - 1);
-
-end;
-
-class function TBitConverter.ToUInt8(const value: THashLibByteArray;
-  StartIndex: Int32): UInt8;
-begin
-  // result := PByte(@value[StartIndex])^;
-  System.Move(value[StartIndex], result, System.SizeOf(result));
-end;
-
-class function TBitConverter.ToUInt16(const value: THashLibByteArray;
-  StartIndex: Int32): UInt16;
-begin
-  // System.Move(value[StartIndex], result, System.SizeOf(result));
-
+  // System.Move(AValue[AStartIndex], result, System.SizeOf(result));
   if (IsLittleEndian) then
   begin
-    result := Word(value[StartIndex] or (value[StartIndex + 1] shl 8));
-    Exit;
+    result := Word(AValue[AStartIndex] or (AValue[AStartIndex + 1] shl 8));
   end
   else
   begin
-
-    result := Word((value[StartIndex] shl 8) or value[StartIndex + 1]);
-    Exit;
+    result := Word((AValue[AStartIndex] shl 8) or AValue[AStartIndex + 1]);
   end;
 end;
 
-class function TBitConverter.ToUInt32(const value: THashLibByteArray;
-  StartIndex: Int32): UInt32;
+class function TBitConverter.ToUInt32(const AValue: THashLibByteArray;
+  AStartIndex: Int32): UInt32;
 begin
-  // System.Move(value[StartIndex], result, System.SizeOf(result));
-
+  // System.Move(AValue[AStartIndex], result, System.SizeOf(result));
   if (IsLittleEndian) then
   begin
-    result := UInt32(value[StartIndex] or (value[StartIndex + 1] shl 8) or
-      (value[StartIndex + 2] shl 16) or (value[StartIndex + 3] shl 24));
-    Exit;
+    result := UInt32(AValue[AStartIndex] or (AValue[AStartIndex + 1] shl 8) or
+      (AValue[AStartIndex + 2] shl 16) or (AValue[AStartIndex + 3] shl 24));
   end
   else
   begin
-
-    result := UInt32((value[StartIndex] shl 24) or
-      (value[StartIndex + 1] shl 16) or (value[StartIndex + 2] shl 8) or
-      (value[StartIndex + 3]));
-    Exit;
+    result := UInt32((AValue[AStartIndex] shl 24) or
+      (AValue[AStartIndex + 1] shl 16) or (AValue[AStartIndex + 2] shl 8) or
+      (AValue[AStartIndex + 3]));
   end;
 end;
 
-class function TBitConverter.ToUInt64(const value: THashLibByteArray;
-  StartIndex: Int32): UInt64;
+class function TBitConverter.ToUInt64(const AValue: THashLibByteArray;
+  AStartIndex: Int32): UInt64;
 var
   i1, i2: Int32;
 begin
-
-  // System.Move(value[StartIndex], result, System.SizeOf(result));
-
+  // System.Move(AValue[AStartIndex], result, System.SizeOf(result));
   if (IsLittleEndian) then
   begin
-    i1 := value[StartIndex] or (value[StartIndex + 1] shl 8) or
-      (value[StartIndex + 2] shl 16) or (value[StartIndex + 3] shl 24);
-    i2 := (value[StartIndex + 4]) or (value[StartIndex + 5] shl 8) or
-      (value[StartIndex + 6] shl 16) or (value[StartIndex + 7] shl 24);
+    i1 := AValue[AStartIndex] or (AValue[AStartIndex + 1] shl 8) or
+      (AValue[AStartIndex + 2] shl 16) or (AValue[AStartIndex + 3] shl 24);
+    i2 := (AValue[AStartIndex + 4]) or (AValue[AStartIndex + 5] shl 8) or
+      (AValue[AStartIndex + 6] shl 16) or (AValue[AStartIndex + 7] shl 24);
     result := UInt64(UInt32(i1) or (Int64(i2) shl 32));
-    Exit;
   end
   else
   begin
-
-    i1 := (value[StartIndex] shl 24) or (value[StartIndex + 1] shl 16) or
-      (value[StartIndex + 2] shl 8) or (value[StartIndex + 3]);
-    i2 := (value[StartIndex + 4] shl 24) or (value[StartIndex + 5] shl 16) or
-      (value[StartIndex + 6] shl 8) or (value[StartIndex + 7]);
+    i1 := (AValue[AStartIndex] shl 24) or (AValue[AStartIndex + 1] shl 16) or
+      (AValue[AStartIndex + 2] shl 8) or (AValue[AStartIndex + 3]);
+    i2 := (AValue[AStartIndex + 4] shl 24) or (AValue[AStartIndex + 5] shl 16)
+      or (AValue[AStartIndex + 6] shl 8) or (AValue[AStartIndex + 7]);
     result := UInt64(UInt32(i2) or (Int64(i1) shl 32));
-    Exit;
   end;
+end;
+
+class function TBitConverter.ToString(const AValue: THashLibByteArray): String;
+begin
+  result := ToString(AValue, System.Low(AValue));
+end;
+
+class function TBitConverter.ToString(const AValue: THashLibByteArray;
+  AStartIndex: Int32): String;
+begin
+  result := ToString(AValue, AStartIndex, System.Length(AValue) - AStartIndex);
+end;
 
+class function TBitConverter.ToString(const AValue: THashLibByteArray;
+  AStartIndex, ALength: Int32): String;
+var
+  LIdx, LIndex, LCharArrayLength: Int32;
+  LCharArray: THashLibCharArray;
+  LByte: Byte;
+begin
+  result := '';
+
+  LCharArrayLength := ALength * 3;
+
+  System.SetLength(LCharArray, LCharArrayLength);
+  LIdx := 0;
+  LIndex := AStartIndex;
+  while LIdx < LCharArrayLength do
+  begin
+    LByte := AValue[LIndex];
+    System.Inc(LIndex);
+
+    LCharArray[LIdx] := GetHexValue(LByte shr 4);
+    LCharArray[LIdx + 1] := GetHexValue(LByte and 15);
+    LCharArray[LIdx + 2] := '-';
+
+    System.Inc(LIdx, 3);
+  end;
+  System.SetString(result, PChar(@LCharArray[System.Low(LCharArray)]),
+    System.Length(LCharArray) - 1);
 end;
 
 end.

+ 88 - 87
src/libraries/hashlib4pascal/HlpBits.pas

@@ -9,22 +9,22 @@ type
 
   public
 
-    class function ReverseBytesInt32(Value: Int32): Int32; static; inline;
-    class function ReverseBitsUInt8(Value: UInt8): UInt8; static; inline;
-    class function ReverseBytesUInt16(Value: UInt16): UInt16; static; inline;
-    class function ReverseBytesUInt32(Value: UInt32): UInt32; static; inline;
-    class function ReverseBytesUInt64(Value: UInt64): UInt64; static; inline;
+    class function ReverseBytesInt32(AValue: Int32): Int32; static; inline;
+    class function ReverseBitsUInt8(AValue: UInt8): UInt8; static; inline;
+    class function ReverseBytesUInt16(AValue: UInt16): UInt16; static; inline;
+    class function ReverseBytesUInt32(AValue: UInt32): UInt32; static; inline;
+    class function ReverseBytesUInt64(AValue: UInt64): UInt64; static; inline;
 
     /// <summary>
     /// Reverse a ByteArray.
     /// </summary>
     /// Implementation was found here <see cref="http://stackoverflow.com/a/12969282" />
-    /// <param name="Source">Pointer to Input Array.</param>
-    /// <param name="Dest">Pointer to Destination Array.</param>
-    /// <param name="Size">Size of the Array to Reverse.</param>
+    /// <param name="ASource">Pointer to Source Array.</param>
+    /// <param name="ADestination">Pointer to Destination Array.</param>
+    /// <param name="ASize">Size of the Array to Reverse.</param>
 
-    class procedure ReverseByteArray(Source, Dest: Pointer;
-      Size: Int64); static;
+    class procedure ReverseByteArray(ASource, ADestination: Pointer;
+      ASize: Int64); static;
 
     /// <summary>
     /// Calculates Arithmetic shift right.
@@ -52,16 +52,17 @@ type
     class function Asr64(AValue: Int64; AShiftBits: Byte): Int64;
       static; inline;
 
-    class function RotateLeft8(a_value: Byte; a_n: Int32): Byte; static; inline;
-    class function RotateLeft32(a_value: UInt32; a_n: Int32): UInt32;
+    class function RotateLeft8(AValue: Byte; ADistance: Int32): Byte;
       static; inline;
-    class function RotateLeft64(a_value: UInt64; a_n: Int32): UInt64;
+    class function RotateLeft32(AValue: UInt32; ADistance: Int32): UInt32;
       static; inline;
-    class function RotateRight8(a_value: Byte; a_n: Int32): Byte;
+    class function RotateLeft64(AValue: UInt64; ADistance: Int32): UInt64;
       static; inline;
-    class function RotateRight32(a_value: UInt32; a_n: Int32): UInt32;
+    class function RotateRight8(AValue: Byte; ADistance: Int32): Byte;
       static; inline;
-    class function RotateRight64(a_value: UInt64; a_n: Int32): UInt64;
+    class function RotateRight32(AValue: UInt32; ADistance: Int32): UInt32;
+      static; inline;
+    class function RotateRight64(AValue: UInt64; ADistance: Int32): UInt64;
       static; inline;
 
   end;
@@ -70,87 +71,87 @@ implementation
 
 { TBits }
 
-class procedure TBits.ReverseByteArray(Source, Dest: Pointer; Size: Int64);
+class procedure TBits.ReverseByteArray(ASource, ADestination: Pointer;
+  ASize: Int64);
 var
-  ptr_src, ptr_dest: PByte;
+  LPtrSource, LPtrDestination: PByte;
 begin
-  ptr_src := PByte(Source);
-  ptr_dest := PByte(Dest);
-  System.Inc(ptr_dest, Size - 1);
-  while Size > 0 do
+  LPtrSource := PByte(ASource);
+  LPtrDestination := PByte(ADestination);
+  System.Inc(LPtrDestination, ASize - 1);
+  while ASize > 0 do
   begin
-    ptr_dest^ := ptr_src^;
-    System.Inc(ptr_src);
-    System.Dec(ptr_dest);
-    System.Dec(Size);
+    LPtrDestination^ := LPtrSource^;
+    System.Inc(LPtrSource);
+    System.Dec(LPtrDestination);
+    System.Dec(ASize);
   end;
 end;
 
-class function TBits.ReverseBytesInt32(Value: Int32): Int32;
+class function TBits.ReverseBytesInt32(AValue: Int32): Int32;
 {$IFNDEF FPC}
 var
   i1, i2, i3, i4: Int32;
 {$ENDIF FPC}
 begin
 {$IFDEF FPC}
-  Result := SwapEndian(Value);
+  Result := SwapEndian(AValue);
 {$ELSE}
-  i1 := Value and $FF;
-  i2 := TBits.Asr32(Value, 8) and $FF;
-  i3 := TBits.Asr32(Value, 16) and $FF;
-  i4 := TBits.Asr32(Value, 24) and $FF;
+  i1 := AValue and $FF;
+  i2 := TBits.Asr32(AValue, 8) and $FF;
+  i3 := TBits.Asr32(AValue, 16) and $FF;
+  i4 := TBits.Asr32(AValue, 24) and $FF;
 
   Result := (i1 shl 24) or (i2 shl 16) or (i3 shl 8) or (i4 shl 0);
 {$ENDIF FPC}
 end;
 
-class function TBits.ReverseBitsUInt8(Value: UInt8): UInt8;
+class function TBits.ReverseBitsUInt8(AValue: UInt8): UInt8;
 begin
-  Value := ((Value shr 1) and $55) or ((Value shl 1) and $AA);
-  Value := ((Value shr 2) and $33) or ((Value shl 2) and $CC);
-  Value := ((Value shr 4) and $0F) or ((Value shl 4) and $F0);
-  Result := Value;
+  AValue := ((AValue shr 1) and $55) or ((AValue shl 1) and $AA);
+  AValue := ((AValue shr 2) and $33) or ((AValue shl 2) and $CC);
+  AValue := ((AValue shr 4) and $0F) or ((AValue shl 4) and $F0);
+  Result := AValue;
 end;
 
-class function TBits.ReverseBytesUInt16(Value: UInt16): UInt16;
+class function TBits.ReverseBytesUInt16(AValue: UInt16): UInt16;
 begin
 {$IFDEF FPC}
-  Result := SwapEndian(Value);
+  Result := SwapEndian(AValue);
 {$ELSE}
-  Result := UInt16((Value and UInt32($FF)) shl 8 or
-    (Value and UInt32($FF00)) shr 8);
+  Result := UInt16((AValue and UInt32($FF)) shl 8 or
+    (AValue and UInt32($FF00)) shr 8);
 {$ENDIF FPC}
 end;
 
-class function TBits.ReverseBytesUInt32(Value: UInt32): UInt32;
+class function TBits.ReverseBytesUInt32(AValue: UInt32): UInt32;
 begin
 {$IFDEF FPC}
-  Result := SwapEndian(Value);
+  Result := SwapEndian(AValue);
 {$ELSE}
-  Result := (Value and UInt32($000000FF)) shl 24 or (Value and UInt32($0000FF00)
-    ) shl 8 or (Value and UInt32($00FF0000)) shr 8 or
-    (Value and UInt32($FF000000)) shr 24;
+  Result := (AValue and UInt32($000000FF)) shl 24 or
+    (AValue and UInt32($0000FF00)) shl 8 or (AValue and UInt32($00FF0000))
+    shr 8 or (AValue and UInt32($FF000000)) shr 24;
 {$ENDIF FPC}
 end;
 
-class function TBits.ReverseBytesUInt64(Value: UInt64): UInt64;
+class function TBits.ReverseBytesUInt64(AValue: UInt64): UInt64;
 begin
 {$IFDEF FPC}
-  Result := SwapEndian(Value);
+  Result := SwapEndian(AValue);
 {$ELSE}
-  Result := (Value and UInt64($00000000000000FF)) shl 56 or
-    (Value and UInt64($000000000000FF00)) shl 40 or
-    (Value and UInt64($0000000000FF0000)) shl 24 or
-    (Value and UInt64($00000000FF000000)) shl 8 or
-    (Value and UInt64($000000FF00000000)) shr 8 or
-    (Value and UInt64($0000FF0000000000)) shr 24 or
-    (Value and UInt64($00FF000000000000)) shr 40 or
-    (Value and UInt64($FF00000000000000)) shr 56;
+  Result := (AValue and UInt64($00000000000000FF)) shl 56 or
+    (AValue and UInt64($000000000000FF00)) shl 40 or
+    (AValue and UInt64($0000000000FF0000)) shl 24 or
+    (AValue and UInt64($00000000FF000000)) shl 8 or
+    (AValue and UInt64($000000FF00000000)) shr 8 or
+    (AValue and UInt64($0000FF0000000000)) shr 24 or
+    (AValue and UInt64($00FF000000000000)) shr 40 or
+    (AValue and UInt64($FF00000000000000)) shr 56;
 {$ENDIF FPC}
 end;
 
 class function TBits.Asr32(AValue: Int32; AShiftBits: Byte): Int32;
-
 begin
 {$IFDEF FPC}
   Result := SarLongInt(AValue, AShiftBits);
@@ -174,89 +175,89 @@ begin
 {$ENDIF FPC}
 end;
 
-class function TBits.RotateLeft8(a_value: Byte; a_n: Int32): Byte;
+class function TBits.RotateLeft8(AValue: Byte; ADistance: Int32): Byte;
 begin
 {$IFDEF DEBUG}
-  System.Assert(a_n >= 0);
+  System.Assert(ADistance >= 0);
 {$ENDIF DEBUG}
 {$IFDEF FPC}
-  Result := RolByte(a_value, a_n);
+  Result := RolByte(AValue, ADistance);
 {$ELSE}
-  a_n := a_n and 7;
-  Result := (a_value shl a_n) or (a_value shr (8 - a_n));
+  ADistance := ADistance and 7;
+  Result := (AValue shl ADistance) or (AValue shr (8 - ADistance));
 {$ENDIF FPC}
 end;
 
-class function TBits.RotateLeft32(a_value: UInt32; a_n: Int32): UInt32;
+class function TBits.RotateLeft32(AValue: UInt32; ADistance: Int32): UInt32;
 begin
 {$IFDEF DEBUG}
-  System.Assert(a_n >= 0);
+  System.Assert(ADistance >= 0);
 {$ENDIF DEBUG}
 {$IFDEF FPC}
-  Result := RolDWord(a_value, a_n);
+  Result := RolDWord(AValue, ADistance);
 {$ELSE}
 {$IFNDEF SHIFT_OVERFLOW_BUG_FIXED}
-  a_n := a_n and 31;
+  ADistance := ADistance and 31;
 {$ENDIF SHIFT_OVERFLOW_BUG_FIXED}
-  Result := (a_value shl a_n) or (a_value shr (32 - a_n));
+  Result := (AValue shl ADistance) or (AValue shr (32 - ADistance));
 {$ENDIF FPC}
 end;
 
-class function TBits.RotateLeft64(a_value: UInt64; a_n: Int32): UInt64;
+class function TBits.RotateLeft64(AValue: UInt64; ADistance: Int32): UInt64;
 begin
 {$IFDEF DEBUG}
-  System.Assert(a_n >= 0);
+  System.Assert(ADistance >= 0);
 {$ENDIF DEBUG}
 {$IFDEF FPC}
-  Result := RolQWord(a_value, a_n);
+  Result := RolQWord(AValue, ADistance);
 {$ELSE}
 {$IFNDEF SHIFT_OVERFLOW_BUG_FIXED}
-  a_n := a_n and 63;
+  ADistance := ADistance and 63;
 {$ENDIF SHIFT_OVERFLOW_BUG_FIXED}
-  Result := (a_value shl a_n) or (a_value shr (64 - a_n));
+  Result := (AValue shl ADistance) or (AValue shr (64 - ADistance));
 {$ENDIF FPC}
 end;
 
-class function TBits.RotateRight8(a_value: Byte; a_n: Int32): Byte;
+class function TBits.RotateRight8(AValue: Byte; ADistance: Int32): Byte;
 begin
 {$IFDEF DEBUG}
-  System.Assert(a_n >= 0);
+  System.Assert(ADistance >= 0);
 {$ENDIF DEBUG}
 {$IFDEF FPC}
-  Result := RorByte(a_value, a_n);
+  Result := RorByte(AValue, ADistance);
 {$ELSE}
-  a_n := a_n and 7;
-  Result := (a_value shr a_n) or (a_value shl (8 - a_n));
+  ADistance := ADistance and 7;
+  Result := (AValue shr ADistance) or (AValue shl (8 - ADistance));
 {$ENDIF FPC}
 end;
 
-class function TBits.RotateRight32(a_value: UInt32; a_n: Int32): UInt32;
+class function TBits.RotateRight32(AValue: UInt32; ADistance: Int32): UInt32;
 begin
 {$IFDEF DEBUG}
-  System.Assert(a_n >= 0);
+  System.Assert(ADistance >= 0);
 {$ENDIF DEBUG}
 {$IFDEF FPC}
-  Result := RorDWord(a_value, a_n);
+  Result := RorDWord(AValue, ADistance);
 {$ELSE}
 {$IFNDEF SHIFT_OVERFLOW_BUG_FIXED}
-  a_n := a_n and 31;
+  ADistance := ADistance and 31;
 {$ENDIF SHIFT_OVERFLOW_BUG_FIXED}
-  Result := (a_value shr a_n) or (a_value shl (32 - a_n));
+  Result := (AValue shr ADistance) or (AValue shl (32 - ADistance));
 {$ENDIF FPC}
 end;
 
-class function TBits.RotateRight64(a_value: UInt64; a_n: Int32): UInt64;
+class function TBits.RotateRight64(AValue: UInt64; ADistance: Int32): UInt64;
 begin
 {$IFDEF DEBUG}
-  System.Assert(a_n >= 0);
+  System.Assert(ADistance >= 0);
 {$ENDIF DEBUG}
 {$IFDEF FPC}
-  Result := RorQWord(a_value, a_n);
+  Result := RorQWord(AValue, ADistance);
 {$ELSE}
 {$IFNDEF SHIFT_OVERFLOW_BUG_FIXED}
-  a_n := a_n and 63;
+  ADistance := ADistance and 63;
 {$ENDIF SHIFT_OVERFLOW_BUG_FIXED}
-  Result := (a_value shr a_n) or (a_value shl (64 - a_n));
+  Result := (AValue shr ADistance) or (AValue shl (64 - ADistance));
 {$ENDIF FPC}
 end;
 

+ 177 - 189
src/libraries/hashlib4pascal/HlpBlake2B.pas

@@ -1,19 +1,13 @@
 unit HlpBlake2B;
 
-
 {$I HashLib.inc}
 
 interface
 
 uses
-{$IFDEF HAS_UNITSCOPE}
-  System.SysUtils,
-{$ELSE}
   SysUtils,
-{$ENDIF HAS_UNITSCOPE}
 {$IFDEF DELPHI}
   HlpBitConverter,
-  HlpHashBuffer,
 {$ENDIF DELPHI}
   HlpBits,
   HlpHash,
@@ -31,6 +25,7 @@ uses
 
 resourcestring
   SInvalidConfigLength = 'Config Length Must Be 8 Words';
+  SConfigNil = 'Config Cannot Be Nil';
 
 type
   TBlake2B = class sealed(THash, ICryptoNotBuildIn, ITransformBlock)
@@ -71,22 +66,22 @@ type
       FDefaultConfig: IBlake2BConfig;
 
   var
-    F_m: array [0 .. 15] of UInt64;
-    FrawConfig, Fm_state: THashLibUInt64Array;
-    FKey, F_buf: THashLibByteArray;
+    FM: array [0 .. 15] of UInt64;
+    FRawConfig, FState: THashLibUInt64Array;
+    FKey, FBuffer: THashLibByteArray;
 {$IFNDEF USE_UNROLLED_VARIANT}
-    F_v: array [0 .. 15] of UInt64;
+    FV: array [0 .. 15] of UInt64;
 {$ENDIF USE_UNROLLED_VARIANT}
-    F_bufferFilled, FHashSize, FBlockSize: Int32;
-    F_counter0, F_counter1, F_finalizationFlag0, F_finalizationFlag1: UInt64;
-    FtreeConfig: IBlake2BTreeConfig;
+    FFilledBufferCount, FHashSize, FBlockSize: Int32;
+    FCounter0, FCounter1, FFinalizationFlag0, FFinalizationFlag1: UInt64;
+    FTreeConfig: IBlake2BTreeConfig;
 
     class constructor Blake2BConfig();
 
 {$IFNDEF USE_UNROLLED_VARIANT}
     procedure G(a, b, c, d, r, i: Int32); inline;
 {$ENDIF USE_UNROLLED_VARIANT}
-    procedure Compress(block: PByte; start: Int32);
+    procedure Compress(ABlock: PByte; AStart: Int32);
 
     procedure Finish(); inline;
 
@@ -96,12 +91,12 @@ type
 
   public
     constructor Create(); overload;
-    constructor Create(const config: IBlake2BConfig); overload;
-    constructor Create(const config: IBlake2BConfig;
-      const treeConfig: IBlake2BTreeConfig); overload;
+    constructor Create(const AConfig: IBlake2BConfig); overload;
+    constructor Create(const AConfig: IBlake2BConfig;
+      const ATreeConfig: IBlake2BTreeConfig); overload;
     procedure Initialize; override;
-    procedure TransformBytes(const a_data: THashLibByteArray;
-      a_index, a_data_length: Int32); override;
+    procedure TransformBytes(const AData: THashLibByteArray;
+      AIndex, ADataLength: Int32); override;
     function TransformFinal: IHashResult; override;
     function Clone(): IHash; override;
 
@@ -131,42 +126,42 @@ begin
   p0 := Sigma[p];
   p1 := Sigma[p + 1];
 
-  F_v[a] := F_v[a] + (F_v[b] + F_m[p0]);
-  F_v[d] := TBits.RotateRight64(F_v[d] xor F_v[a], 32);
-  F_v[c] := F_v[c] + F_v[d];
-  F_v[b] := TBits.RotateRight64(F_v[b] xor F_v[c], 24);
-  F_v[a] := F_v[a] + (F_v[b] + F_m[p1]);
-  F_v[d] := TBits.RotateRight64(F_v[d] xor F_v[a], 16);
-  F_v[c] := F_v[c] + F_v[d];
-  F_v[b] := TBits.RotateRight64(F_v[b] xor F_v[c], 63);
+  FV[a] := FV[a] + (FV[b] + FM[p0]);
+  FV[d] := TBits.RotateRight64(FV[d] xor FV[a], 32);
+  FV[c] := FV[c] + FV[d];
+  FV[b] := TBits.RotateRight64(FV[b] xor FV[c], 24);
+  FV[a] := FV[a] + (FV[b] + FM[p1]);
+  FV[d] := TBits.RotateRight64(FV[d] xor FV[a], 16);
+  FV[c] := FV[c] + FV[d];
+  FV[b] := TBits.RotateRight64(FV[b] xor FV[c], 63);
 end;
 
 {$ENDIF USE_UNROLLED_VARIANT}
 
 function TBlake2B.Clone(): IHash;
 var
-  HashInstance: TBlake2B;
+  LHashInstance: TBlake2B;
 begin
-  HashInstance := TBlake2B.Create(TBlake2BConfig.Create(FHashSize)
+  LHashInstance := TBlake2B.Create(TBlake2BConfig.Create(FHashSize)
     as IBlake2BConfig);
-  System.Move(F_m, HashInstance.F_m, System.SizeOf(F_m));
-  HashInstance.FrawConfig := System.Copy(FrawConfig);
-  HashInstance.Fm_state := System.Copy(Fm_state);
-  HashInstance.FKey := System.Copy(FKey);
-  HashInstance.F_buf := System.Copy(F_buf);
+  System.Move(FM, LHashInstance.FM, System.SizeOf(FM));
+  LHashInstance.FRawConfig := System.Copy(FRawConfig);
+  LHashInstance.FState := System.Copy(FState);
+  LHashInstance.FKey := System.Copy(FKey);
+  LHashInstance.FBuffer := System.Copy(FBuffer);
 {$IFNDEF USE_UNROLLED_VARIANT}
-  System.Move(F_v, HashInstance.F_v, System.SizeOf(F_v));
+  System.Move(FV, LHashInstance.FV, System.SizeOf(FV));
 {$ENDIF USE_UNROLLED_VARIANT}
-  HashInstance.F_bufferFilled := F_bufferFilled;
-  HashInstance.F_counter0 := F_counter0;
-  HashInstance.F_counter1 := F_counter1;
-  HashInstance.F_finalizationFlag0 := F_finalizationFlag0;
-  HashInstance.F_finalizationFlag1 := F_finalizationFlag1;
-  Result := HashInstance as IHash;
+  LHashInstance.FFilledBufferCount := FFilledBufferCount;
+  LHashInstance.FCounter0 := FCounter0;
+  LHashInstance.FCounter1 := FCounter1;
+  LHashInstance.FFinalizationFlag0 := FFinalizationFlag0;
+  LHashInstance.FFinalizationFlag1 := FFinalizationFlag1;
+  Result := LHashInstance as IHash;
   Result.BufferSize := BufferSize;
 end;
 
-procedure TBlake2B.Compress(block: PByte; start: Int32);
+procedure TBlake2B.Compress(ABlock: PByte; AStart: Int32);
 var
 {$IFDEF USE_UNROLLED_VARIANT}
   m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13, m14, m15, v0, v1,
@@ -177,43 +172,43 @@ var
 
 {$ENDIF USE_UNROLLED_VARIANT}
 begin
-  TConverters.le64_copy(block, start, @(F_m[0]), 0, FBlockSize);
+  TConverters.le64_copy(ABlock, AStart, @(FM[0]), 0, FBlockSize);
 
 {$IFDEF USE_UNROLLED_VARIANT}
-  m0 := F_m[0];
-  m1 := F_m[1];
-  m2 := F_m[2];
-  m3 := F_m[3];
-  m4 := F_m[4];
-  m5 := F_m[5];
-  m6 := F_m[6];
-  m7 := F_m[7];
-  m8 := F_m[8];
-  m9 := F_m[9];
-  m10 := F_m[10];
-  m11 := F_m[11];
-  m12 := F_m[12];
-  m13 := F_m[13];
-  m14 := F_m[14];
-  m15 := F_m[15];
-
-  v0 := Fm_state[0];
-  v1 := Fm_state[1];
-  v2 := Fm_state[2];
-  v3 := Fm_state[3];
-  v4 := Fm_state[4];
-  v5 := Fm_state[5];
-  v6 := Fm_state[6];
-  v7 := Fm_state[7];
+  m0 := FM[0];
+  m1 := FM[1];
+  m2 := FM[2];
+  m3 := FM[3];
+  m4 := FM[4];
+  m5 := FM[5];
+  m6 := FM[6];
+  m7 := FM[7];
+  m8 := FM[8];
+  m9 := FM[9];
+  m10 := FM[10];
+  m11 := FM[11];
+  m12 := FM[12];
+  m13 := FM[13];
+  m14 := FM[14];
+  m15 := FM[15];
+
+  v0 := FState[0];
+  v1 := FState[1];
+  v2 := FState[2];
+  v3 := FState[3];
+  v4 := FState[4];
+  v5 := FState[5];
+  v6 := FState[6];
+  v7 := FState[7];
 
   v8 := IV0;
   v9 := IV1;
   v10 := IV2;
   v11 := IV3;
-  v12 := IV4 xor F_counter0;
-  v13 := IV5 xor F_counter1;
-  v14 := IV6 xor F_finalizationFlag0;
-  v15 := IV7 xor F_finalizationFlag1;
+  v12 := IV4 xor FCounter0;
+  v13 := IV5 xor FCounter1;
+  v14 := IV6 xor FFinalizationFlag0;
+  v15 := IV7 xor FFinalizationFlag1;
 
   // Rounds
 
@@ -1574,35 +1569,35 @@ begin
   v4 := TBits.RotateRight64(v4, 63);
 
   // Finalization
-  Fm_state[0] := Fm_state[0] xor (v0 xor v8);
-  Fm_state[1] := Fm_state[1] xor (v1 xor v9);
-  Fm_state[2] := Fm_state[2] xor (v2 xor v10);
-  Fm_state[3] := Fm_state[3] xor (v3 xor v11);
-  Fm_state[4] := Fm_state[4] xor (v4 xor v12);
-  Fm_state[5] := Fm_state[5] xor (v5 xor v13);
-  Fm_state[6] := Fm_state[6] xor (v6 xor v14);
-  Fm_state[7] := Fm_state[7] xor (v7 xor v15);
+  FState[0] := FState[0] xor (v0 xor v8);
+  FState[1] := FState[1] xor (v1 xor v9);
+  FState[2] := FState[2] xor (v2 xor v10);
+  FState[3] := FState[3] xor (v3 xor v11);
+  FState[4] := FState[4] xor (v4 xor v12);
+  FState[5] := FState[5] xor (v5 xor v13);
+  FState[6] := FState[6] xor (v6 xor v14);
+  FState[7] := FState[7] xor (v7 xor v15);
 
 {$ELSE}
-  F_v[0] := Fm_state[0];
-  F_v[1] := Fm_state[1];
-  F_v[2] := Fm_state[2];
-  F_v[3] := Fm_state[3];
-  F_v[4] := Fm_state[4];
-  F_v[5] := Fm_state[5];
-  F_v[6] := Fm_state[6];
-  F_v[7] := Fm_state[7];
-
-  F_v[8] := IV0;
-  F_v[9] := IV1;
-  F_v[10] := IV2;
-  F_v[11] := IV3;
-  F_v[12] := IV4 xor F_counter0;
-  F_v[13] := IV5 xor F_counter1;
-
-  F_v[14] := IV6 xor F_finalizationFlag0;
-
-  F_v[15] := IV7 xor F_finalizationFlag1;
+  FV[0] := FState[0];
+  FV[1] := FState[1];
+  FV[2] := FState[2];
+  FV[3] := FState[3];
+  FV[4] := FState[4];
+  FV[5] := FState[5];
+  FV[6] := FState[6];
+  FV[7] := FState[7];
+
+  FV[8] := IV0;
+  FV[9] := IV1;
+  FV[10] := IV2;
+  FV[11] := IV3;
+  FV[12] := IV4 xor FCounter0;
+  FV[13] := IV5 xor FCounter1;
+
+  FV[14] := IV6 xor FFinalizationFlag0;
+
+  FV[15] := IV7 xor FFinalizationFlag1;
 
   for r := 0 to System.Pred(NumberOfRounds) do
 
@@ -1619,180 +1614,174 @@ begin
 
   for i := 0 to 7 do
   begin
-    Fm_state[i] := Fm_state[i] xor (F_v[i] xor F_v[i + 8]);
+    FState[i] := FState[i] xor (FV[i] xor FV[i + 8]);
   end;
 
 {$ENDIF USE_UNROLLED_VARIANT}
 end;
 
-constructor TBlake2B.Create(const config: IBlake2BConfig);
+constructor TBlake2B.Create(const AConfig: IBlake2BConfig);
 begin
-  Create(config, Nil);
+  Create(AConfig, Nil);
 end;
 
-constructor TBlake2B.Create(const config: IBlake2BConfig;
-  const treeConfig: IBlake2BTreeConfig);
+constructor TBlake2B.Create(const AConfig: IBlake2BConfig;
+  const ATreeConfig: IBlake2BTreeConfig);
 var
-  Lconfig: IBlake2BConfig;
+  LConfig: IBlake2BConfig;
 begin
-
-  Lconfig := config;
-  FtreeConfig := treeConfig;
+  LConfig := AConfig;
+  FTreeConfig := ATreeConfig;
   FBlockSize := BlockSizeInBytes;
 
-  if (Lconfig = Nil) then
+  if (LConfig = Nil) then
   begin
-    Lconfig := FDefaultConfig;
+    LConfig := FDefaultConfig;
   end;
 
-  FrawConfig := TBlake2BIvBuilder.ConfigB(Lconfig, FtreeConfig);
-  if ((Lconfig.Key <> Nil) and (System.Length(Lconfig.Key) <> 0)) then
+  FRawConfig := TBlake2BIvBuilder.ConfigB(LConfig, FTreeConfig);
+  if ((LConfig.Key <> Nil) and (System.Length(LConfig.Key) <> 0)) then
   begin
-
-    FKey := System.Copy(Lconfig.Key, System.Low(Lconfig.Key),
-      System.Length(Lconfig.Key));
-
+    FKey := System.Copy(LConfig.Key, System.Low(LConfig.Key),
+      System.Length(LConfig.Key));
     System.SetLength(FKey, FBlockSize);
-
   end;
-  FHashSize := Lconfig.HashSize;
 
-  System.SetLength(Fm_state, 8);
+  FHashSize := LConfig.HashSize;
 
-  Inherited Create(FHashSize, FBlockSize);
+  System.SetLength(FState, 8);
 
+  Inherited Create(FHashSize, FBlockSize);
 end;
 
 procedure TBlake2B.Finish;
 var
-  count: Int32;
+  LCount: Int32;
 begin
-
   // Last compression
+  FCounter0 := FCounter0 + UInt64(FFilledBufferCount);
 
-  F_counter0 := F_counter0 + UInt64(F_bufferFilled);
+  FFinalizationFlag0 := System.High(UInt64);
 
-  F_finalizationFlag0 := System.High(UInt64);
-
-  if (FtreeConfig.IsLastNode) then
+  if (FTreeConfig.IsLastNode) then
   begin
-    F_finalizationFlag1 := System.High(UInt64);
+    FFinalizationFlag1 := System.High(UInt64);
   end;
 
-  count := System.Length(F_buf) - F_bufferFilled;
+  LCount := System.Length(FBuffer) - FFilledBufferCount;
 
-  if count > 0 then
+  if LCount > 0 then
   begin
-    TArrayUtils.Fill(F_buf, F_bufferFilled, count + F_bufferFilled, Byte(0));
+    TArrayUtils.Fill(FBuffer, FFilledBufferCount,
+      LCount + FFilledBufferCount, Byte(0));
   end;
 
-  Compress(PByte(F_buf), 0);
-
+  Compress(PByte(FBuffer), 0);
 end;
 
 procedure TBlake2B.Initialize;
 var
-  i: Int32;
+  LIdx: Int32;
 begin
-  if (FrawConfig = Nil) then
-    raise EArgumentNilHashLibException.Create('config');
-  if (System.Length(FrawConfig) <> 8) then
+  if (FRawConfig = Nil) then
+  begin
+    raise EArgumentNilHashLibException.CreateRes(@SConfigNil);
+  end;
+  if (System.Length(FRawConfig) <> 8) then
   begin
     raise EArgumentHashLibException.CreateRes(@SInvalidConfigLength);
   end;
 
-  Fm_state[0] := IV0;
-  Fm_state[1] := IV1;
-  Fm_state[2] := IV2;
-  Fm_state[3] := IV3;
-  Fm_state[4] := IV4;
-  Fm_state[5] := IV5;
-  Fm_state[6] := IV6;
-  Fm_state[7] := IV7;
+  FState[0] := IV0;
+  FState[1] := IV1;
+  FState[2] := IV2;
+  FState[3] := IV3;
+  FState[4] := IV4;
+  FState[5] := IV5;
+  FState[6] := IV6;
+  FState[7] := IV7;
 
-  F_counter0 := 0;
-  F_counter1 := 0;
-  F_finalizationFlag0 := 0;
-  F_finalizationFlag1 := 0;
+  FCounter0 := 0;
+  FCounter1 := 0;
+  FFinalizationFlag0 := 0;
+  FFinalizationFlag1 := 0;
 
-  F_bufferFilled := 0;
+  FFilledBufferCount := 0;
 
-  System.SetLength(F_buf, BlockSizeInBytes);
+  System.SetLength(FBuffer, BlockSizeInBytes);
 
-  TArrayUtils.ZeroFill(F_buf);
+  TArrayUtils.ZeroFill(FBuffer);
 
-  System.FillChar(F_m, System.SizeOf(F_m), UInt64(0));
+  System.FillChar(FM, System.SizeOf(FM), UInt64(0));
 
 {$IFNDEF USE_UNROLLED_VARIANT}
-  System.FillChar(F_v, System.SizeOf(F_v), UInt64(0));
+  System.FillChar(FV, System.SizeOf(FV), UInt64(0));
 {$ENDIF USE_UNROLLED_VARIANT}
-  for i := 0 to 7 do
+  for LIdx := 0 to 7 do
   begin
-    Fm_state[i] := Fm_state[i] xor FrawConfig[i];
+    FState[LIdx] := FState[LIdx] xor FRawConfig[LIdx];
   end;
 
   if (FKey <> Nil) then
   begin
     TransformBytes(FKey, 0, System.Length(FKey));
   end;
-
 end;
 
-procedure TBlake2B.TransformBytes(const a_data: THashLibByteArray;
-  a_index, a_data_length: Int32);
+procedure TBlake2B.TransformBytes(const AData: THashLibByteArray;
+  AIndex, ADataLength: Int32);
 var
-  offset, bufferRemaining: Int32;
-
+  LOffset, LBufferRemaining: Int32;
 begin
-  offset := a_index;
-  bufferRemaining := BlockSizeInBytes - F_bufferFilled;
+  LOffset := AIndex;
+  LBufferRemaining := BlockSizeInBytes - FFilledBufferCount;
 
-  if ((F_bufferFilled > 0) and (a_data_length > bufferRemaining)) then
+  if ((FFilledBufferCount > 0) and (ADataLength > LBufferRemaining)) then
   begin
-
-    if bufferRemaining > 0 then
+    if LBufferRemaining > 0 then
     begin
-      System.Move(a_data[offset], F_buf[F_bufferFilled], bufferRemaining);
+      System.Move(AData[LOffset], FBuffer[FFilledBufferCount],
+        LBufferRemaining);
     end;
-    F_counter0 := F_counter0 + UInt64(BlockSizeInBytes);
-    if (F_counter0 = 0) then
+    FCounter0 := FCounter0 + UInt64(BlockSizeInBytes);
+    if (FCounter0 = 0) then
     begin
-      System.Inc(F_counter1);
+      System.Inc(FCounter1);
     end;
-    Compress(PByte(F_buf), 0);
-    offset := offset + bufferRemaining;
-    a_data_length := a_data_length - bufferRemaining;
-    F_bufferFilled := 0;
+    Compress(PByte(FBuffer), 0);
+    LOffset := LOffset + LBufferRemaining;
+    ADataLength := ADataLength - LBufferRemaining;
+    FFilledBufferCount := 0;
   end;
 
-  while (a_data_length > BlockSizeInBytes) do
+  while (ADataLength > BlockSizeInBytes) do
   begin
-    F_counter0 := F_counter0 + UInt64(BlockSizeInBytes);
-    if (F_counter0 = 0) then
+    FCounter0 := FCounter0 + UInt64(BlockSizeInBytes);
+    if (FCounter0 = 0) then
     begin
-      System.Inc(F_counter1);
+      System.Inc(FCounter1);
     end;
-    Compress(PByte(a_data), offset);
-    offset := offset + BlockSizeInBytes;
-    a_data_length := a_data_length - BlockSizeInBytes;
+    Compress(PByte(AData), LOffset);
+    LOffset := LOffset + BlockSizeInBytes;
+    ADataLength := ADataLength - BlockSizeInBytes;
   end;
 
-  if (a_data_length > 0) then
+  if (ADataLength > 0) then
   begin
-    System.Move(a_data[offset], F_buf[F_bufferFilled], a_data_length);
-    F_bufferFilled := F_bufferFilled + a_data_length;
+    System.Move(AData[LOffset], FBuffer[FFilledBufferCount], ADataLength);
+    FFilledBufferCount := FFilledBufferCount + ADataLength;
   end;
 end;
 
 function TBlake2B.TransformFinal: IHashResult;
 var
-  tempRes: THashLibByteArray;
+  LBuffer: THashLibByteArray;
 begin
   Finish();
-  System.SetLength(tempRes, FHashSize);
-  TConverters.le64_copy(PUInt64(Fm_state), 0, PByte(tempRes), 0,
-    System.Length(tempRes));
-  Result := THashResult.Create(tempRes);
+  System.SetLength(LBuffer, FHashSize);
+  TConverters.le64_copy(PUInt64(FState), 0, PByte(LBuffer), 0,
+    System.Length(LBuffer));
+  Result := THashResult.Create(LBuffer);
   Initialize();
 end;
 
@@ -1802,4 +1791,3 @@ begin
 end;
 
 end.
-

+ 16 - 16
src/libraries/hashlib4pascal/HlpBlake2BConfig.pas

@@ -35,16 +35,16 @@ type
     procedure ValidateSaltLength(const ASalt: THashLibByteArray); inline;
 
     function GetPersonalisation: THashLibByteArray; inline;
-    procedure SetPersonalisation(const value: THashLibByteArray); inline;
+    procedure SetPersonalisation(const AValue: THashLibByteArray); inline;
 
     function GetSalt: THashLibByteArray; inline;
-    procedure SetSalt(const value: THashLibByteArray); inline;
+    procedure SetSalt(const AValue: THashLibByteArray); inline;
 
     function GetKey: THashLibByteArray; inline;
-    procedure SetKey(const value: THashLibByteArray); inline;
+    procedure SetKey(const AValue: THashLibByteArray); inline;
 
     function GetHashSize: Int32; inline;
-    procedure SetHashSize(value: Int32); inline;
+    procedure SetHashSize(AValue: Int32); inline;
 
   public
     constructor Create(AHashSize: THashSize = THashSize.hsHashSize512);
@@ -137,28 +137,28 @@ begin
   result := FSalt;
 end;
 
-procedure TBlake2BConfig.SetHashSize(value: Int32);
+procedure TBlake2BConfig.SetHashSize(AValue: Int32);
 begin
-  ValidateHashSize(value);
-  FHashSize := value;
+  ValidateHashSize(AValue);
+  FHashSize := AValue;
 end;
 
-procedure TBlake2BConfig.SetKey(const value: THashLibByteArray);
+procedure TBlake2BConfig.SetKey(const AValue: THashLibByteArray);
 begin
-  ValidateKeyLength(value);
-  FKey := value;
+  ValidateKeyLength(AValue);
+  FKey := AValue;
 end;
 
-procedure TBlake2BConfig.SetPersonalisation(const value: THashLibByteArray);
+procedure TBlake2BConfig.SetPersonalisation(const AValue: THashLibByteArray);
 begin
-  ValidatePersonalisationLength(value);
-  FPersonalisation := value;
+  ValidatePersonalisationLength(AValue);
+  FPersonalisation := AValue;
 end;
 
-procedure TBlake2BConfig.SetSalt(const value: THashLibByteArray);
+procedure TBlake2BConfig.SetSalt(const AValue: THashLibByteArray);
 begin
-  ValidateSaltLength(value);
-  FSalt := value;
+  ValidateSaltLength(AValue);
+  FSalt := AValue;
 end;
 
 constructor TBlake2BConfig.Create(AHashSize: THashSize);

+ 43 - 40
src/libraries/hashlib4pascal/HlpBlake2BIvBuilder.pas

@@ -5,6 +5,9 @@ unit HlpBlake2BIvBuilder;
 interface
 
 uses
+{$IFDEF DELPHI}
+  HlpBitConverter,
+{$ENDIF DELPHI}
   HlpConverters,
   HlpBlake2BTreeConfig,
   HlpIBlake2BConfig,
@@ -29,14 +32,14 @@ type
 
       FSequentialTreeConfig: IBlake2BTreeConfig;
 
-    class procedure VerifyConfigB(const config: IBlake2BConfig;
-      const treeConfig: IBlake2BTreeConfig; isSequential: Boolean); static;
+    class procedure VerifyConfigB(const AConfig: IBlake2BConfig;
+      const ATreeConfig: IBlake2BTreeConfig; AIsSequential: Boolean); static;
 
     class constructor Blake2BIvBuilder();
 
   public
-    class function ConfigB(const config: IBlake2BConfig;
-      var treeConfig: IBlake2BTreeConfig): THashLibUInt64Array; static;
+    class function ConfigB(const AConfig: IBlake2BConfig;
+      var ATreeConfig: IBlake2BTreeConfig): THashLibUInt64Array; static;
 
   end;
 
@@ -44,38 +47,38 @@ implementation
 
 { TBlake2BIvBuilder }
 
-class procedure TBlake2BIvBuilder.VerifyConfigB(const config: IBlake2BConfig;
-  const treeConfig: IBlake2BTreeConfig; isSequential: Boolean);
+class procedure TBlake2BIvBuilder.VerifyConfigB(const AConfig: IBlake2BConfig;
+  const ATreeConfig: IBlake2BTreeConfig; AIsSequential: Boolean);
 begin
 
   // digest length
-  if ((config.HashSize <= 0) or (config.HashSize > 64)) then
+  if ((AConfig.HashSize <= 0) or (AConfig.HashSize > 64)) then
   begin
     raise EArgumentOutOfRangeHashLibException.CreateRes(@SInvalidHashSize);
   end;
 
   // Key length
-  if (config.Key <> Nil) then
+  if (AConfig.Key <> Nil) then
   begin
-    if (System.Length(config.Key) > 64) then
+    if (System.Length(AConfig.Key) > 64) then
     begin
       raise EArgumentOutOfRangeHashLibException.CreateRes(@SInvalidKeyLength);
     end;
   end;
 
   // Salt length
-  if (config.Salt <> Nil) then
+  if (AConfig.Salt <> Nil) then
   begin
-    if (System.Length(config.Salt) <> 16) then
+    if (System.Length(AConfig.Salt) <> 16) then
     begin
       raise EArgumentOutOfRangeHashLibException.CreateRes(@SInvalidSaltLength);
     end;
   end;
 
   // Personalisation length
-  if (config.Personalisation <> Nil) then
+  if (AConfig.Personalisation <> Nil) then
   begin
-    if (System.Length(config.Personalisation) <> 16) then
+    if (System.Length(AConfig.Personalisation) <> 16) then
     begin
       raise EArgumentOutOfRangeHashLibException.CreateRes
         (@SInvalidPersonalisationLength);
@@ -83,16 +86,16 @@ begin
   end;
 
   // Tree InnerHashSize
-  if (treeConfig <> Nil) then
+  if (ATreeConfig <> Nil) then
   begin
 
-    if ((not isSequential) and ((treeConfig.InnerHashSize <= 0))) then
+    if ((not AIsSequential) and ((ATreeConfig.InnerHashSize <= 0))) then
     begin
       raise EArgumentOutOfRangeHashLibException.Create
         ('treeConfig.TreeIntermediateHashSize');
     end;
 
-    if (treeConfig.InnerHashSize > 64) then
+    if (ATreeConfig.InnerHashSize > 64) then
     begin
       raise EArgumentOutOfRangeHashLibException.CreateRes
         (@STreeIncorrectInnerHashSize);
@@ -113,49 +116,49 @@ begin
   FSequentialTreeConfig.IsLastNode := False;
 end;
 
-class function TBlake2BIvBuilder.ConfigB(const config: IBlake2BConfig;
-  var treeConfig: IBlake2BTreeConfig): THashLibUInt64Array;
+class function TBlake2BIvBuilder.ConfigB(const AConfig: IBlake2BConfig;
+  var ATreeConfig: IBlake2BTreeConfig): THashLibUInt64Array;
 var
-  isSequential: Boolean;
-  tempBuffer: THashLibByteArray;
+  LIsSequential: Boolean;
+  LBuffer: THashLibByteArray;
 begin
-  isSequential := treeConfig = Nil;
-  if (isSequential) then
+  LIsSequential := ATreeConfig = Nil;
+  if (LIsSequential) then
   begin
-    treeConfig := FSequentialTreeConfig;
+    ATreeConfig := FSequentialTreeConfig;
   end;
 
-  VerifyConfigB(config, treeConfig, isSequential);
+  VerifyConfigB(AConfig, ATreeConfig, LIsSequential);
 
-  System.SetLength(tempBuffer, 64);
+  System.SetLength(LBuffer, 64);
 
-  tempBuffer[0] := config.HashSize;
-  tempBuffer[1] := System.Length(config.Key);
+  LBuffer[0] := AConfig.HashSize;
+  LBuffer[1] := System.Length(AConfig.Key);
 
-  if treeConfig <> Nil then
+  if ATreeConfig <> Nil then
   begin
-    tempBuffer[2] := treeConfig.FanOut;
-    tempBuffer[3] := treeConfig.MaxDepth;
-    TConverters.ReadUInt32AsBytesLE(treeConfig.LeafSize, tempBuffer, 4);
-    TConverters.ReadUInt64AsBytesLE(treeConfig.NodeOffset, tempBuffer, 8);
-    tempBuffer[16] := treeConfig.NodeDepth;
-    tempBuffer[17] := treeConfig.InnerHashSize;
+    LBuffer[2] := ATreeConfig.FanOut;
+    LBuffer[3] := ATreeConfig.MaxDepth;
+    TConverters.ReadUInt32AsBytesLE(ATreeConfig.LeafSize, LBuffer, 4);
+    TConverters.ReadUInt64AsBytesLE(ATreeConfig.NodeOffset, LBuffer, 8);
+    LBuffer[16] := ATreeConfig.NodeDepth;
+    LBuffer[17] := ATreeConfig.InnerHashSize;
   end;
 
-  if config.Salt <> Nil then
+  if AConfig.Salt <> Nil then
   begin
-    System.Move(config.Salt[0], tempBuffer[32], 16 * System.SizeOf(Byte));
+    System.Move(AConfig.Salt[0], LBuffer[32], 16 * System.SizeOf(Byte));
   end;
 
-  if config.Personalisation <> Nil then
+  if AConfig.Personalisation <> Nil then
   begin
-    System.Move(config.Personalisation[0], tempBuffer[48],
+    System.Move(AConfig.Personalisation[0], LBuffer[48],
       16 * System.SizeOf(Byte));
   end;
 
   System.SetLength(Result, 8);
-  TConverters.le64_copy(PByte(tempBuffer), 0, PUInt64(Result), 0,
-    System.Length(tempBuffer) * System.SizeOf(Byte));
+  TConverters.le64_copy(PByte(LBuffer), 0, PUInt64(Result), 0,
+    System.Length(LBuffer) * System.SizeOf(Byte));
 end;
 
 end.

+ 26 - 26
src/libraries/hashlib4pascal/HlpBlake2BTreeConfig.pas

@@ -23,7 +23,7 @@ type
   TBlake2BTreeConfig = class sealed(TInterfacedObject, IBlake2BTreeConfig)
 
   strict private
-
+  var
     FFanOut, FMaxDepth, FNodeDepth, FInnerHashSize: Byte;
     FLeafSize: UInt32;
     FNodeOffset: UInt64;
@@ -35,25 +35,25 @@ type
     procedure ValidateNodeDepth(ANodeDepth: Byte); inline;
 
     function GetFanOut: Byte; inline;
-    procedure SetFanOut(value: Byte); inline;
+    procedure SetFanOut(AValue: Byte); inline;
 
     function GetMaxDepth: Byte; inline;
-    procedure SetMaxDepth(value: Byte); inline;
+    procedure SetMaxDepth(AValue: Byte); inline;
 
     function GetNodeDepth: Byte; inline;
-    procedure SetNodeDepth(value: Byte); inline;
+    procedure SetNodeDepth(AValue: Byte); inline;
 
     function GetInnerHashSize: Byte; inline;
-    procedure SetInnerHashSize(value: Byte); inline;
+    procedure SetInnerHashSize(AValue: Byte); inline;
 
     function GetLeafSize: UInt32; inline;
-    procedure SetLeafSize(value: UInt32); inline;
+    procedure SetLeafSize(AValue: UInt32); inline;
 
     function GetNodeOffset: UInt64; inline;
-    procedure SetNodeOffset(value: UInt64); inline;
+    procedure SetNodeOffset(AValue: UInt64); inline;
 
     function GetIsLastNode: Boolean; inline;
-    procedure SetIsLastNode(value: Boolean); inline;
+    procedure SetIsLastNode(AValue: Boolean); inline;
 
   public
     constructor Create();
@@ -148,43 +148,43 @@ begin
   result := FNodeOffset;
 end;
 
-procedure TBlake2BTreeConfig.SetFanOut(value: Byte);
+procedure TBlake2BTreeConfig.SetFanOut(AValue: Byte);
 begin
-  ValidateFanOut(value);
-  FFanOut := value;
+  ValidateFanOut(AValue);
+  FFanOut := AValue;
 end;
 
-procedure TBlake2BTreeConfig.SetInnerHashSize(value: Byte);
+procedure TBlake2BTreeConfig.SetInnerHashSize(AValue: Byte);
 begin
-  ValidateInnerHashSize(value);
-  FInnerHashSize := value;
+  ValidateInnerHashSize(AValue);
+  FInnerHashSize := AValue;
 end;
 
-procedure TBlake2BTreeConfig.SetIsLastNode(value: Boolean);
+procedure TBlake2BTreeConfig.SetIsLastNode(AValue: Boolean);
 begin
-  FIsLastNode := value;
+  FIsLastNode := AValue;
 end;
 
-procedure TBlake2BTreeConfig.SetLeafSize(value: UInt32);
+procedure TBlake2BTreeConfig.SetLeafSize(AValue: UInt32);
 begin
-  FLeafSize := value;
+  FLeafSize := AValue;
 end;
 
-procedure TBlake2BTreeConfig.SetMaxDepth(value: Byte);
+procedure TBlake2BTreeConfig.SetMaxDepth(AValue: Byte);
 begin
-  ValidateMaxDepth(value);
-  FMaxDepth := value;
+  ValidateMaxDepth(AValue);
+  FMaxDepth := AValue;
 end;
 
-procedure TBlake2BTreeConfig.SetNodeDepth(value: Byte);
+procedure TBlake2BTreeConfig.SetNodeDepth(AValue: Byte);
 begin
-  ValidateNodeDepth(value);
-  FNodeDepth := value;
+  ValidateNodeDepth(AValue);
+  FNodeDepth := AValue;
 end;
 
-procedure TBlake2BTreeConfig.SetNodeOffset(value: UInt64);
+procedure TBlake2BTreeConfig.SetNodeOffset(AValue: UInt64);
 begin
-  FNodeOffset := value;
+  FNodeOffset := AValue;
 end;
 
 constructor TBlake2BTreeConfig.Create;

+ 177 - 190
src/libraries/hashlib4pascal/HlpBlake2S.pas

@@ -1,19 +1,13 @@
 unit HlpBlake2S;
 
-
 {$I HashLib.inc}
 
 interface
 
 uses
-{$IFDEF HAS_UNITSCOPE}
-  System.SysUtils,
-{$ELSE}
   SysUtils,
-{$ENDIF HAS_UNITSCOPE}
 {$IFDEF DELPHI}
   HlpBitConverter,
-  HlpHashBuffer,
 {$ENDIF DELPHI}
   HlpBits,
   HlpHash,
@@ -31,6 +25,7 @@ uses
 
 resourcestring
   SInvalidConfigLength = 'Config Length Must Be 8 Words';
+  SConfigNil = 'Config Cannot Be Nil';
 
 type
   TBlake2S = class sealed(THash, ICryptoNotBuildIn, ITransformBlock)
@@ -71,22 +66,22 @@ type
       FDefaultConfig: IBlake2SConfig;
 
   var
-    F_m: array [0 .. 15] of UInt32;
-    FrawConfig, Fm_state: THashLibUInt32Array;
-    FKey, F_buf: THashLibByteArray;
+    FM: array [0 .. 15] of UInt32;
+    FRawConfig, FState: THashLibUInt32Array;
+    FKey, FBuffer: THashLibByteArray;
 {$IFNDEF USE_UNROLLED_VARIANT}
-    F_v: array [0 .. 15] of UInt32;
+    FV: array [0 .. 15] of UInt32;
 {$ENDIF USE_UNROLLED_VARIANT}
-    F_bufferFilled, FHashSize, FBlockSize: Int32;
-    F_counter0, F_counter1, F_finalizationFlag0, F_finalizationFlag1: UInt32;
-    FtreeConfig: IBlake2STreeConfig;
+    FFilledBufferCount, FHashSize, FBlockSize: Int32;
+    FCounter0, FCounter1, FFinalizationFlag0, FFinalizationFlag1: UInt32;
+    FTreeConfig: IBlake2STreeConfig;
 
     class constructor Blake2SConfig();
 
 {$IFNDEF USE_UNROLLED_VARIANT}
     procedure G(a, b, c, d, r, i: Int32); inline;
 {$ENDIF USE_UNROLLED_VARIANT}
-    procedure Compress(block: PByte; start: Int32);
+    procedure Compress(ABlock: PByte; AStart: Int32);
 
     procedure Finish(); inline;
 
@@ -96,12 +91,12 @@ type
 
   public
     constructor Create(); overload;
-    constructor Create(const config: IBlake2SConfig); overload;
-    constructor Create(const config: IBlake2SConfig;
-      const treeConfig: IBlake2STreeConfig); overload;
+    constructor Create(const AConfig: IBlake2SConfig); overload;
+    constructor Create(const AConfig: IBlake2SConfig;
+      const ATreeConfig: IBlake2STreeConfig); overload;
     procedure Initialize; override;
-    procedure TransformBytes(const a_data: THashLibByteArray;
-      a_index, a_data_length: Int32); override;
+    procedure TransformBytes(const AData: THashLibByteArray;
+      AIndex, ADataLength: Int32); override;
     function TransformFinal: IHashResult; override;
     function Clone(): IHash; override;
 
@@ -125,43 +120,42 @@ end;
 
 procedure TBlake2S.G(a, b, c, d, r, i: Int32);
 begin
-
-  F_v[a] := F_v[a] + (F_v[b] + F_m[Sigma[r][2 * i + 0]]);
-  F_v[d] := TBits.RotateRight32(F_v[d] xor F_v[a], 16);
-  F_v[c] := F_v[c] + F_v[d];
-  F_v[b] := TBits.RotateRight32(F_v[b] xor F_v[c], 12);
-  F_v[a] := F_v[a] + (F_v[b] + F_m[Sigma[r][2 * i + 1]]);
-  F_v[d] := TBits.RotateRight32(F_v[d] xor F_v[a], 8);
-  F_v[c] := F_v[c] + F_v[d];
-  F_v[b] := TBits.RotateRight32(F_v[b] xor F_v[c], 7);
+  FV[a] := FV[a] + (FV[b] + FM[Sigma[r][2 * i + 0]]);
+  FV[d] := TBits.RotateRight32(FV[d] xor FV[a], 16);
+  FV[c] := FV[c] + FV[d];
+  FV[b] := TBits.RotateRight32(FV[b] xor FV[c], 12);
+  FV[a] := FV[a] + (FV[b] + FM[Sigma[r][2 * i + 1]]);
+  FV[d] := TBits.RotateRight32(FV[d] xor FV[a], 8);
+  FV[c] := FV[c] + FV[d];
+  FV[b] := TBits.RotateRight32(FV[b] xor FV[c], 7);
 end;
 
 {$ENDIF USE_UNROLLED_VARIANT}
 
 function TBlake2S.Clone(): IHash;
 var
-  HashInstance: TBlake2S;
+  LHashInstance: TBlake2S;
 begin
-  HashInstance := TBlake2S.Create(TBlake2SConfig.Create(FHashSize)
+  LHashInstance := TBlake2S.Create(TBlake2SConfig.Create(FHashSize)
     as IBlake2SConfig);
-  System.Move(F_m, HashInstance.F_m, System.SizeOf(F_m));
-  HashInstance.FrawConfig := System.Copy(FrawConfig);
-  HashInstance.Fm_state := System.Copy(Fm_state);
-  HashInstance.FKey := System.Copy(FKey);
-  HashInstance.F_buf := System.Copy(F_buf);
+  System.Move(FM, LHashInstance.FM, System.SizeOf(FM));
+  LHashInstance.FRawConfig := System.Copy(FRawConfig);
+  LHashInstance.FState := System.Copy(FState);
+  LHashInstance.FKey := System.Copy(FKey);
+  LHashInstance.FBuffer := System.Copy(FBuffer);
 {$IFNDEF USE_UNROLLED_VARIANT}
-  System.Move(F_v, HashInstance.F_v, System.SizeOf(F_v));
+  System.Move(FV, LHashInstance.FV, System.SizeOf(FV));
 {$ENDIF USE_UNROLLED_VARIANT}
-  HashInstance.F_bufferFilled := F_bufferFilled;
-  HashInstance.F_counter0 := F_counter0;
-  HashInstance.F_counter1 := F_counter1;
-  HashInstance.F_finalizationFlag0 := F_finalizationFlag0;
-  HashInstance.F_finalizationFlag1 := F_finalizationFlag1;
-  Result := HashInstance as IHash;
+  LHashInstance.FFilledBufferCount := FFilledBufferCount;
+  LHashInstance.FCounter0 := FCounter0;
+  LHashInstance.FCounter1 := FCounter1;
+  LHashInstance.FFinalizationFlag0 := FFinalizationFlag0;
+  LHashInstance.FFinalizationFlag1 := FFinalizationFlag1;
+  Result := LHashInstance as IHash;
   Result.BufferSize := BufferSize;
 end;
 
-procedure TBlake2S.Compress(block: PByte; start: Int32);
+procedure TBlake2S.Compress(ABlock: PByte; AStart: Int32);
 var
 {$IFDEF USE_UNROLLED_VARIANT}
   m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13, m14, m15, v0, v1,
@@ -172,43 +166,43 @@ var
 
 {$ENDIF USE_UNROLLED_VARIANT}
 begin
-  TConverters.le32_copy(block, start, @(F_m[0]), 0, FBlockSize);
+  TConverters.le32_copy(ABlock, AStart, @(FM[0]), 0, FBlockSize);
 
 {$IFDEF USE_UNROLLED_VARIANT}
-  m0 := F_m[0];
-  m1 := F_m[1];
-  m2 := F_m[2];
-  m3 := F_m[3];
-  m4 := F_m[4];
-  m5 := F_m[5];
-  m6 := F_m[6];
-  m7 := F_m[7];
-  m8 := F_m[8];
-  m9 := F_m[9];
-  m10 := F_m[10];
-  m11 := F_m[11];
-  m12 := F_m[12];
-  m13 := F_m[13];
-  m14 := F_m[14];
-  m15 := F_m[15];
-
-  v0 := Fm_state[0];
-  v1 := Fm_state[1];
-  v2 := Fm_state[2];
-  v3 := Fm_state[3];
-  v4 := Fm_state[4];
-  v5 := Fm_state[5];
-  v6 := Fm_state[6];
-  v7 := Fm_state[7];
+  m0 := FM[0];
+  m1 := FM[1];
+  m2 := FM[2];
+  m3 := FM[3];
+  m4 := FM[4];
+  m5 := FM[5];
+  m6 := FM[6];
+  m7 := FM[7];
+  m8 := FM[8];
+  m9 := FM[9];
+  m10 := FM[10];
+  m11 := FM[11];
+  m12 := FM[12];
+  m13 := FM[13];
+  m14 := FM[14];
+  m15 := FM[15];
+
+  v0 := FState[0];
+  v1 := FState[1];
+  v2 := FState[2];
+  v3 := FState[3];
+  v4 := FState[4];
+  v5 := FState[5];
+  v6 := FState[6];
+  v7 := FState[7];
 
   v8 := IV0;
   v9 := IV1;
   v10 := IV2;
   v11 := IV3;
-  v12 := IV4 xor F_counter0;
-  v13 := IV5 xor F_counter1;
-  v14 := IV6 xor F_finalizationFlag0;
-  v15 := IV7 xor F_finalizationFlag1;
+  v12 := IV4 xor FCounter0;
+  v13 := IV5 xor FCounter1;
+  v14 := IV6 xor FFinalizationFlag0;
+  v15 := IV7 xor FFinalizationFlag1;
 
   // Rounds
   // *
@@ -1354,35 +1348,35 @@ begin
   // */
   // Finalization
 
-  Fm_state[0] := Fm_state[0] xor (v0 xor v8);
-  Fm_state[1] := Fm_state[1] xor (v1 xor v9);
-  Fm_state[2] := Fm_state[2] xor (v2 xor v10);
-  Fm_state[3] := Fm_state[3] xor (v3 xor v11);
-  Fm_state[4] := Fm_state[4] xor (v4 xor v12);
-  Fm_state[5] := Fm_state[5] xor (v5 xor v13);
-  Fm_state[6] := Fm_state[6] xor (v6 xor v14);
-  Fm_state[7] := Fm_state[7] xor (v7 xor v15);
+  FState[0] := FState[0] xor (v0 xor v8);
+  FState[1] := FState[1] xor (v1 xor v9);
+  FState[2] := FState[2] xor (v2 xor v10);
+  FState[3] := FState[3] xor (v3 xor v11);
+  FState[4] := FState[4] xor (v4 xor v12);
+  FState[5] := FState[5] xor (v5 xor v13);
+  FState[6] := FState[6] xor (v6 xor v14);
+  FState[7] := FState[7] xor (v7 xor v15);
 
 {$ELSE}
-  F_v[0] := Fm_state[0];
-  F_v[1] := Fm_state[1];
-  F_v[2] := Fm_state[2];
-  F_v[3] := Fm_state[3];
-  F_v[4] := Fm_state[4];
-  F_v[5] := Fm_state[5];
-  F_v[6] := Fm_state[6];
-  F_v[7] := Fm_state[7];
-
-  F_v[8] := IV0;
-  F_v[9] := IV1;
-  F_v[10] := IV2;
-  F_v[11] := IV3;
-  F_v[12] := IV4 xor F_counter0;
-  F_v[13] := IV5 xor F_counter1;
-
-  F_v[14] := IV6 xor F_finalizationFlag0;
-
-  F_v[15] := IV7 xor F_finalizationFlag1;
+  FV[0] := FState[0];
+  FV[1] := FState[1];
+  FV[2] := FState[2];
+  FV[3] := FState[3];
+  FV[4] := FState[4];
+  FV[5] := FState[5];
+  FV[6] := FState[6];
+  FV[7] := FState[7];
+
+  FV[8] := IV0;
+  FV[9] := IV1;
+  FV[10] := IV2;
+  FV[11] := IV3;
+  FV[12] := IV4 xor FCounter0;
+  FV[13] := IV5 xor FCounter1;
+
+  FV[14] := IV6 xor FFinalizationFlag0;
+
+  FV[15] := IV7 xor FFinalizationFlag1;
 
   for r := 0 to System.Pred(NumberOfRounds) do
 
@@ -1400,180 +1394,174 @@ begin
 
   for i := 0 to 7 do
   begin
-    Fm_state[i] := Fm_state[i] xor (F_v[i] xor F_v[i + 8]);
+    FState[i] := FState[i] xor (FV[i] xor FV[i + 8]);
   end;
 
 {$ENDIF USE_UNROLLED_VARIANT}
 end;
 
-constructor TBlake2S.Create(const config: IBlake2SConfig);
+constructor TBlake2S.Create(const AConfig: IBlake2SConfig);
 begin
-  Create(config, Nil);
+  Create(AConfig, Nil);
 end;
 
-constructor TBlake2S.Create(const config: IBlake2SConfig;
-  const treeConfig: IBlake2STreeConfig);
+constructor TBlake2S.Create(const AConfig: IBlake2SConfig;
+  const ATreeConfig: IBlake2STreeConfig);
 var
-  Lconfig: IBlake2SConfig;
+  LConfig: IBlake2SConfig;
 begin
-
-  Lconfig := config;
-  FtreeConfig := treeConfig;
+  LConfig := AConfig;
+  FTreeConfig := ATreeConfig;
   FBlockSize := BlockSizeInBytes;
 
-  if (Lconfig = Nil) then
+  if (LConfig = Nil) then
   begin
-    Lconfig := FDefaultConfig;
+    LConfig := FDefaultConfig;
   end;
 
-  FrawConfig := TBlake2SIvBuilder.ConfigS(Lconfig, FtreeConfig);
-  if ((Lconfig.Key <> Nil) and (System.Length(Lconfig.Key) <> 0)) then
+  FRawConfig := TBlake2SIvBuilder.ConfigS(LConfig, FTreeConfig);
+  if ((LConfig.Key <> Nil) and (System.Length(LConfig.Key) <> 0)) then
   begin
-
-    FKey := System.Copy(Lconfig.Key, System.Low(Lconfig.Key),
-      System.Length(Lconfig.Key));
-
+    FKey := System.Copy(LConfig.Key, System.Low(LConfig.Key),
+      System.Length(LConfig.Key));
     System.SetLength(FKey, FBlockSize);
-
   end;
-  FHashSize := Lconfig.HashSize;
 
-  System.SetLength(Fm_state, 8);
+  FHashSize := LConfig.HashSize;
 
-  Inherited Create(FHashSize, FBlockSize);
+  System.SetLength(FState, 8);
 
+  Inherited Create(FHashSize, FBlockSize);
 end;
 
 procedure TBlake2S.Finish;
 var
-  count: Int32;
+  LCount: Int32;
 begin
-
   // Last compression
+  FCounter0 := FCounter0 + UInt32(FFilledBufferCount);
 
-  F_counter0 := F_counter0 + UInt32(F_bufferFilled);
+  FFinalizationFlag0 := System.High(UInt32);
 
-  F_finalizationFlag0 := System.High(UInt32);
-
-  if (FtreeConfig.IsLastNode) then
+  if (FTreeConfig.IsLastNode) then
   begin
-    F_finalizationFlag1 := System.High(UInt32);
+    FFinalizationFlag1 := System.High(UInt32);
   end;
 
-  count := System.Length(F_buf) - F_bufferFilled;
+  LCount := System.Length(FBuffer) - FFilledBufferCount;
 
-  if count > 0 then
+  if LCount > 0 then
   begin
-    TArrayUtils.Fill(F_buf, F_bufferFilled, count + F_bufferFilled, Byte(0));
+    TArrayUtils.Fill(FBuffer, FFilledBufferCount,
+      LCount + FFilledBufferCount, Byte(0));
   end;
 
-  Compress(PByte(F_buf), 0);
-
+  Compress(PByte(FBuffer), 0);
 end;
 
 procedure TBlake2S.Initialize;
 var
-  i: Int32;
+  LIdx: Int32;
 begin
-  if (FrawConfig = Nil) then
-    raise EArgumentNilHashLibException.Create('config');
-  if (System.Length(FrawConfig) <> 8) then
+  if (FRawConfig = Nil) then
+  begin
+    raise EArgumentNilHashLibException.CreateRes(@SConfigNil);
+  end;
+  if (System.Length(FRawConfig) <> 8) then
   begin
     raise EArgumentHashLibException.CreateRes(@SInvalidConfigLength);
   end;
 
-  Fm_state[0] := IV0;
-  Fm_state[1] := IV1;
-  Fm_state[2] := IV2;
-  Fm_state[3] := IV3;
-  Fm_state[4] := IV4;
-  Fm_state[5] := IV5;
-  Fm_state[6] := IV6;
-  Fm_state[7] := IV7;
+  FState[0] := IV0;
+  FState[1] := IV1;
+  FState[2] := IV2;
+  FState[3] := IV3;
+  FState[4] := IV4;
+  FState[5] := IV5;
+  FState[6] := IV6;
+  FState[7] := IV7;
 
-  F_counter0 := 0;
-  F_counter1 := 0;
-  F_finalizationFlag0 := 0;
-  F_finalizationFlag1 := 0;
+  FCounter0 := 0;
+  FCounter1 := 0;
+  FFinalizationFlag0 := 0;
+  FFinalizationFlag1 := 0;
 
-  F_bufferFilled := 0;
+  FFilledBufferCount := 0;
 
-  System.SetLength(F_buf, BlockSizeInBytes);
+  System.SetLength(FBuffer, BlockSizeInBytes);
 
-  TArrayUtils.ZeroFill(F_buf);
+  TArrayUtils.ZeroFill(FBuffer);
 
-  System.FillChar(F_m, System.SizeOf(F_m), UInt32(0));
+  System.FillChar(FM, System.SizeOf(FM), UInt32(0));
 
 {$IFNDEF USE_UNROLLED_VARIANT}
-  System.FillChar(F_v, System.SizeOf(F_v), UInt32(0));
+  System.FillChar(FV, System.SizeOf(FV), UInt32(0));
 {$ENDIF USE_UNROLLED_VARIANT}
-  for i := 0 to 7 do
+  for LIdx := 0 to 7 do
   begin
-    Fm_state[i] := Fm_state[i] xor FrawConfig[i];
+    FState[LIdx] := FState[LIdx] xor FRawConfig[LIdx];
   end;
 
   if (FKey <> Nil) then
   begin
     TransformBytes(FKey, 0, System.Length(FKey));
   end;
-
 end;
 
-procedure TBlake2S.TransformBytes(const a_data: THashLibByteArray;
-  a_index, a_data_length: Int32);
+procedure TBlake2S.TransformBytes(const AData: THashLibByteArray;
+  AIndex, ADataLength: Int32);
 var
-  offset, bufferRemaining: Int32;
-
+  LOffset, LBufferRemaining: Int32;
 begin
-  offset := a_index;
-  bufferRemaining := BlockSizeInBytes - F_bufferFilled;
+  LOffset := AIndex;
+  LBufferRemaining := BlockSizeInBytes - FFilledBufferCount;
 
-  if ((F_bufferFilled > 0) and (a_data_length > bufferRemaining)) then
+  if ((FFilledBufferCount > 0) and (ADataLength > LBufferRemaining)) then
   begin
-
-    if bufferRemaining > 0 then
+    if LBufferRemaining > 0 then
     begin
-      System.Move(a_data[offset], F_buf[F_bufferFilled], bufferRemaining);
+      System.Move(AData[LOffset], FBuffer[FFilledBufferCount],
+        LBufferRemaining);
     end;
-    F_counter0 := F_counter0 + UInt32(BlockSizeInBytes);
-    if (F_counter0 = 0) then
+    FCounter0 := FCounter0 + UInt32(BlockSizeInBytes);
+    if (FCounter0 = 0) then
     begin
-      System.Inc(F_counter1);
+      System.Inc(FCounter1);
     end;
-    Compress(PByte(F_buf), 0);
-    offset := offset + bufferRemaining;
-    a_data_length := a_data_length - bufferRemaining;
-    F_bufferFilled := 0;
+    Compress(PByte(FBuffer), 0);
+    LOffset := LOffset + LBufferRemaining;
+    ADataLength := ADataLength - LBufferRemaining;
+    FFilledBufferCount := 0;
   end;
 
-  while (a_data_length > BlockSizeInBytes) do
+  while (ADataLength > BlockSizeInBytes) do
   begin
-    F_counter0 := F_counter0 + UInt32(BlockSizeInBytes);
-    if (F_counter0 = 0) then
+    FCounter0 := FCounter0 + UInt32(BlockSizeInBytes);
+    if (FCounter0 = 0) then
     begin
-      System.Inc(F_counter1);
+      System.Inc(FCounter1);
     end;
-    Compress(PByte(a_data), offset);
-    offset := offset + BlockSizeInBytes;
-    a_data_length := a_data_length - BlockSizeInBytes;
+    Compress(PByte(AData), LOffset);
+    LOffset := LOffset + BlockSizeInBytes;
+    ADataLength := ADataLength - BlockSizeInBytes;
   end;
 
-  if (a_data_length > 0) then
+  if (ADataLength > 0) then
   begin
-    System.Move(a_data[offset], F_buf[F_bufferFilled], a_data_length);
-    F_bufferFilled := F_bufferFilled + a_data_length;
+    System.Move(AData[LOffset], FBuffer[FFilledBufferCount], ADataLength);
+    FFilledBufferCount := FFilledBufferCount + ADataLength;
   end;
 end;
 
 function TBlake2S.TransformFinal: IHashResult;
 var
-  tempRes: THashLibByteArray;
+  LBuffer: THashLibByteArray;
 begin
   Finish();
-  System.SetLength(tempRes, FHashSize);
-  TConverters.le32_copy(PCardinal(Fm_state), 0, PByte(tempRes), 0,
-    System.Length(tempRes));
-  Result := THashResult.Create(tempRes);
+  System.SetLength(LBuffer, FHashSize);
+  TConverters.le32_copy(PCardinal(FState), 0, PByte(LBuffer), 0,
+    System.Length(LBuffer));
+  Result := THashResult.Create(LBuffer);
   Initialize();
 end;
 
@@ -1583,4 +1571,3 @@ begin
 end;
 
 end.
-

+ 16 - 16
src/libraries/hashlib4pascal/HlpBlake2SConfig.pas

@@ -35,16 +35,16 @@ type
     procedure ValidateSaltLength(const ASalt: THashLibByteArray); inline;
 
     function GetPersonalisation: THashLibByteArray; inline;
-    procedure SetPersonalisation(const value: THashLibByteArray); inline;
+    procedure SetPersonalisation(const AValue: THashLibByteArray); inline;
 
     function GetSalt: THashLibByteArray; inline;
-    procedure SetSalt(const value: THashLibByteArray); inline;
+    procedure SetSalt(const AValue: THashLibByteArray); inline;
 
     function GetKey: THashLibByteArray; inline;
-    procedure SetKey(const value: THashLibByteArray); inline;
+    procedure SetKey(const AValue: THashLibByteArray); inline;
 
     function GetHashSize: Int32; inline;
-    procedure SetHashSize(value: Int32); inline;
+    procedure SetHashSize(AValue: Int32); inline;
 
   public
     constructor Create(AHashSize: THashSize = THashSize.hsHashSize256);
@@ -137,28 +137,28 @@ begin
   result := FSalt;
 end;
 
-procedure TBlake2SConfig.SetHashSize(value: Int32);
+procedure TBlake2SConfig.SetHashSize(AValue: Int32);
 begin
-  ValidateHashSize(value);
-  FHashSize := value;
+  ValidateHashSize(AValue);
+  FHashSize := AValue;
 end;
 
-procedure TBlake2SConfig.SetKey(const value: THashLibByteArray);
+procedure TBlake2SConfig.SetKey(const AValue: THashLibByteArray);
 begin
-  ValidateKeyLength(value);
-  FKey := value;
+  ValidateKeyLength(AValue);
+  FKey := AValue;
 end;
 
-procedure TBlake2SConfig.SetPersonalisation(const value: THashLibByteArray);
+procedure TBlake2SConfig.SetPersonalisation(const AValue: THashLibByteArray);
 begin
-  ValidatePersonalisationLength(value);
-  FPersonalisation := value;
+  ValidatePersonalisationLength(AValue);
+  FPersonalisation := AValue;
 end;
 
-procedure TBlake2SConfig.SetSalt(const value: THashLibByteArray);
+procedure TBlake2SConfig.SetSalt(const AValue: THashLibByteArray);
 begin
-  ValidateSaltLength(value);
-  FSalt := value;
+  ValidateSaltLength(AValue);
+  FSalt := AValue;
 end;
 
 constructor TBlake2SConfig.Create(AHashSize: THashSize);

+ 48 - 45
src/libraries/hashlib4pascal/HlpBlake2SIvBuilder.pas

@@ -5,6 +5,9 @@ unit HlpBlake2SIvBuilder;
 interface
 
 uses
+{$IFDEF DELPHI}
+  HlpBitConverter,
+{$ENDIF DELPHI}
   HlpConverters,
   HlpBlake2STreeConfig,
   HlpIBlake2SConfig,
@@ -28,14 +31,14 @@ type
 
       FSequentialTreeConfig: IBlake2STreeConfig;
 
-    class procedure VerifyConfigS(const config: IBlake2SConfig;
-      const treeConfig: IBlake2STreeConfig; isSequential: Boolean); static;
+    class procedure VerifyConfigS(const AConfig: IBlake2SConfig;
+      const ATreeConfig: IBlake2STreeConfig; AIsSequential: Boolean); static;
 
     class constructor Blake2SIvBuilder();
 
   public
-    class function ConfigS(const config: IBlake2SConfig;
-      var treeConfig: IBlake2STreeConfig): THashLibUInt32Array; static;
+    class function ConfigS(const AConfig: IBlake2SConfig;
+      var ATreeConfig: IBlake2STreeConfig): THashLibUInt32Array; static;
 
   end;
 
@@ -43,38 +46,38 @@ implementation
 
 { TBlake2SIvBuilder }
 
-class procedure TBlake2SIvBuilder.VerifyConfigS(const config: IBlake2SConfig;
-  const treeConfig: IBlake2STreeConfig; isSequential: Boolean);
+class procedure TBlake2SIvBuilder.VerifyConfigS(const AConfig: IBlake2SConfig;
+  const ATreeConfig: IBlake2STreeConfig; AIsSequential: Boolean);
 begin
 
   // digest length
-  if ((config.HashSize <= 0) or (config.HashSize > 32)) then
+  if ((AConfig.HashSize <= 0) or (AConfig.HashSize > 32)) then
   begin
     raise EArgumentOutOfRangeHashLibException.CreateRes(@SInvalidHashSize);
   end;
 
   // Key length
-  if (config.Key <> Nil) then
+  if (AConfig.Key <> Nil) then
   begin
-    if (System.Length(config.Key) > 32) then
+    if (System.Length(AConfig.Key) > 32) then
     begin
       raise EArgumentOutOfRangeHashLibException.CreateRes(@SInvalidKeyLength);
     end;
   end;
 
   // Salt length
-  if (config.Salt <> Nil) then
+  if (AConfig.Salt <> Nil) then
   begin
-    if (System.Length(config.Salt) <> 8) then
+    if (System.Length(AConfig.Salt) <> 8) then
     begin
       raise EArgumentOutOfRangeHashLibException.CreateRes(@SInvalidSaltLength);
     end;
   end;
 
   // Personalisation length
-  if (config.Personalisation <> Nil) then
+  if (AConfig.Personalisation <> Nil) then
   begin
-    if (System.Length(config.Personalisation) <> 8) then
+    if (System.Length(AConfig.Personalisation) <> 8) then
     begin
       raise EArgumentOutOfRangeHashLibException.CreateRes
         (@SInvalidPersonalisationLength);
@@ -82,16 +85,16 @@ begin
   end;
 
   // Tree InnerHashSize
-  if (treeConfig <> Nil) then
+  if (ATreeConfig <> Nil) then
   begin
 
-    if ((not isSequential) and ((treeConfig.InnerHashSize <= 0))) then
+    if ((not AIsSequential) and ((ATreeConfig.InnerHashSize <= 0))) then
     begin
       raise EArgumentOutOfRangeHashLibException.Create
         ('treeConfig.TreeIntermediateHashSize');
     end;
 
-    if (treeConfig.InnerHashSize > 32) then
+    if (ATreeConfig.InnerHashSize > 32) then
     begin
       raise EArgumentOutOfRangeHashLibException.CreateRes
         (@STreeIncorrectInnerHashSize);
@@ -112,54 +115,54 @@ begin
   FSequentialTreeConfig.IsLastNode := False;
 end;
 
-class function TBlake2SIvBuilder.ConfigS(const config: IBlake2SConfig;
-  var treeConfig: IBlake2STreeConfig): THashLibUInt32Array;
+class function TBlake2SIvBuilder.ConfigS(const AConfig: IBlake2SConfig;
+  var ATreeConfig: IBlake2STreeConfig): THashLibUInt32Array;
 var
-  isSequential: Boolean;
-  tempBuffer: THashLibByteArray;
+  LIsSequential: Boolean;
+  LBuffer: THashLibByteArray;
 begin
-  isSequential := treeConfig = Nil;
-  if (isSequential) then
+  LIsSequential := ATreeConfig = Nil;
+  if (LIsSequential) then
   begin
-    treeConfig := FSequentialTreeConfig;
+    ATreeConfig := FSequentialTreeConfig;
   end;
 
-  VerifyConfigS(config, treeConfig, isSequential);
+  VerifyConfigS(AConfig, ATreeConfig, LIsSequential);
 
-  System.SetLength(tempBuffer, 32);
+  System.SetLength(LBuffer, 32);
 
-  tempBuffer[0] := config.HashSize;
-  tempBuffer[1] := System.Length(config.Key);
+  LBuffer[0] := AConfig.HashSize;
+  LBuffer[1] := System.Length(AConfig.Key);
 
-  if treeConfig <> Nil then
+  if ATreeConfig <> Nil then
   begin
-    tempBuffer[2] := treeConfig.FanOut;
-    tempBuffer[3] := treeConfig.MaxDepth;
-    TConverters.ReadUInt32AsBytesLE(treeConfig.LeafSize, tempBuffer, 4);
-    tempBuffer[8] := Byte(treeConfig.NodeOffset);
-    tempBuffer[9] := Byte(treeConfig.NodeOffset shr 8);
-    tempBuffer[10] := Byte(treeConfig.NodeOffset shr 16);
-    tempBuffer[11] := Byte(treeConfig.NodeOffset shr 24);
-    tempBuffer[12] := Byte(treeConfig.NodeOffset shr 32);
-    tempBuffer[13] := Byte(treeConfig.NodeOffset shr 40);
-    tempBuffer[14] := treeConfig.NodeDepth;
-    tempBuffer[15] := treeConfig.InnerHashSize;
+    LBuffer[2] := ATreeConfig.FanOut;
+    LBuffer[3] := ATreeConfig.MaxDepth;
+    TConverters.ReadUInt32AsBytesLE(ATreeConfig.LeafSize, LBuffer, 4);
+    LBuffer[8] := Byte(ATreeConfig.NodeOffset);
+    LBuffer[9] := Byte(ATreeConfig.NodeOffset shr 8);
+    LBuffer[10] := Byte(ATreeConfig.NodeOffset shr 16);
+    LBuffer[11] := Byte(ATreeConfig.NodeOffset shr 24);
+    LBuffer[12] := Byte(ATreeConfig.NodeOffset shr 32);
+    LBuffer[13] := Byte(ATreeConfig.NodeOffset shr 40);
+    LBuffer[14] := ATreeConfig.NodeDepth;
+    LBuffer[15] := ATreeConfig.InnerHashSize;
   end;
 
-  if config.Salt <> Nil then
+  if AConfig.Salt <> Nil then
   begin
-    System.Move(config.Salt[0], tempBuffer[16], 8 * System.SizeOf(Byte));
+    System.Move(AConfig.Salt[0], LBuffer[16], 8 * System.SizeOf(Byte));
   end;
 
-  if config.Personalisation <> Nil then
+  if AConfig.Personalisation <> Nil then
   begin
-    System.Move(config.Personalisation[0], tempBuffer[24],
+    System.Move(AConfig.Personalisation[0], LBuffer[24],
       8 * System.SizeOf(Byte));
   end;
 
   System.SetLength(Result, 8);
-  TConverters.le32_copy(PByte(tempBuffer), 0, PCardinal(Result), 0,
-    System.Length(tempBuffer) * System.SizeOf(Byte));
+  TConverters.le32_copy(PByte(LBuffer), 0, PCardinal(Result), 0,
+    System.Length(LBuffer) * System.SizeOf(Byte));
 end;
 
 end.

+ 27 - 27
src/libraries/hashlib4pascal/HlpBlake2STreeConfig.pas

@@ -25,7 +25,7 @@ type
   TBlake2STreeConfig = class sealed(TInterfacedObject, IBlake2STreeConfig)
 
   strict private
-
+  var
     FFanOut, FMaxDepth, FNodeDepth, FInnerHashSize: Byte;
     FLeafSize: UInt32;
     FNodeOffset: UInt64;
@@ -38,25 +38,25 @@ type
     procedure ValidateNodeOffset(ANodeOffset: UInt64); inline;
 
     function GetFanOut: Byte; inline;
-    procedure SetFanOut(value: Byte); inline;
+    procedure SetFanOut(AValue: Byte); inline;
 
     function GetMaxDepth: Byte; inline;
-    procedure SetMaxDepth(value: Byte); inline;
+    procedure SetMaxDepth(AValue: Byte); inline;
 
     function GetNodeDepth: Byte; inline;
-    procedure SetNodeDepth(value: Byte); inline;
+    procedure SetNodeDepth(AValue: Byte); inline;
 
     function GetInnerHashSize: Byte; inline;
-    procedure SetInnerHashSize(value: Byte); inline;
+    procedure SetInnerHashSize(AValue: Byte); inline;
 
     function GetLeafSize: UInt32; inline;
-    procedure SetLeafSize(value: UInt32); inline;
+    procedure SetLeafSize(AValue: UInt32); inline;
 
     function GetNodeOffset: UInt64; inline;
-    procedure SetNodeOffset(value: UInt64); inline;
+    procedure SetNodeOffset(AValue: UInt64); inline;
 
     function GetIsLastNode: Boolean; inline;
-    procedure SetIsLastNode(value: Boolean); inline;
+    procedure SetIsLastNode(AValue: Boolean); inline;
 
   public
     constructor Create();
@@ -160,44 +160,44 @@ begin
   result := FNodeOffset;
 end;
 
-procedure TBlake2STreeConfig.SetFanOut(value: Byte);
+procedure TBlake2STreeConfig.SetFanOut(AValue: Byte);
 begin
-  ValidateFanOut(value);
-  FFanOut := value;
+  ValidateFanOut(AValue);
+  FFanOut := AValue;
 end;
 
-procedure TBlake2STreeConfig.SetInnerHashSize(value: Byte);
+procedure TBlake2STreeConfig.SetInnerHashSize(AValue: Byte);
 begin
-  ValidateInnerHashSize(value);
-  FInnerHashSize := value;
+  ValidateInnerHashSize(AValue);
+  FInnerHashSize := AValue;
 end;
 
-procedure TBlake2STreeConfig.SetIsLastNode(value: Boolean);
+procedure TBlake2STreeConfig.SetIsLastNode(AValue: Boolean);
 begin
-  FIsLastNode := value;
+  FIsLastNode := AValue;
 end;
 
-procedure TBlake2STreeConfig.SetLeafSize(value: UInt32);
+procedure TBlake2STreeConfig.SetLeafSize(AValue: UInt32);
 begin
-  FLeafSize := value;
+  FLeafSize := AValue;
 end;
 
-procedure TBlake2STreeConfig.SetMaxDepth(value: Byte);
+procedure TBlake2STreeConfig.SetMaxDepth(AValue: Byte);
 begin
-  ValidateMaxDepth(value);
-  FMaxDepth := value;
+  ValidateMaxDepth(AValue);
+  FMaxDepth := AValue;
 end;
 
-procedure TBlake2STreeConfig.SetNodeDepth(value: Byte);
+procedure TBlake2STreeConfig.SetNodeDepth(AValue: Byte);
 begin
-  ValidateNodeDepth(value);
-  FNodeDepth := value;
+  ValidateNodeDepth(AValue);
+  FNodeDepth := AValue;
 end;
 
-procedure TBlake2STreeConfig.SetNodeOffset(value: UInt64);
+procedure TBlake2STreeConfig.SetNodeOffset(AValue: UInt64);
 begin
-  ValidateNodeOffset(value);
-  FNodeOffset := value;
+  ValidateNodeOffset(AValue);
+  FNodeOffset := AValue;
 end;
 
 constructor TBlake2STreeConfig.Create;

+ 142 - 155
src/libraries/hashlib4pascal/HlpCRC.pas

@@ -1,6 +1,5 @@
 unit HlpCRC;
 
-
 // A vast majority if not all of the parameters for these CRC standards
 // were gotten from http://reveng.sourceforge.net/crc-catalogue/.
 
@@ -9,13 +8,8 @@ unit HlpCRC;
 interface
 
 uses
-{$IFDEF HAS_UNITSCOPE}
-  System.SysUtils,
-  System.TypInfo,
-{$ELSE}
   SysUtils,
   TypInfo,
-{$ENDIF HAS_UNITSCOPE}
   HlpHashLibTypes,
   HlpHash,
   HlpIHash,
@@ -547,49 +541,49 @@ type
   TCRC = class sealed(THash, IChecksum, ICRC, ITransformBlock)
 
   strict private
-
+  var
     FNames: THashLibStringArray;
     FWidth: Int32;
-    FPolynomial, FInitial, FOutputXor, FCheckValue, Fm_CRCMask,
-      Fm_CRCHighBitMask, Fm_hash: UInt64;
+    FPolynomial, FInitialValue, FOutputXor, FCheckValue, FCRCMask,
+      FCRCHighBitMask, FHash: UInt64;
     FIsInputReflected, FIsOutputReflected, FIsTableGenerated: Boolean;
 
-    Fm_CRCTable: THashLibUInt64Array;
+    FCRCTable: THashLibUInt64Array;
 
   const
     Delta = Int32(7);
 
     function GetNames: THashLibStringArray; inline;
-    procedure SetNames(const value: THashLibStringArray); inline;
+    procedure SetNames(const AValue: THashLibStringArray); inline;
     function GetWidth: Int32; inline;
-    procedure SetWidth(value: Int32); inline;
+    procedure SetWidth(AValue: Int32); inline;
     function GetPolynomial: UInt64; inline;
-    procedure SetPolynomial(value: UInt64); inline;
-    function GetInitial: UInt64; inline;
-    procedure SetInitial(value: UInt64); inline;
+    procedure SetPolynomial(AValue: UInt64); inline;
+    function GetInitialValue: UInt64; inline;
+    procedure SetInitialValue(AValue: UInt64); inline;
     function GetIsInputReflected: Boolean; inline;
-    procedure SetIsInputReflected(value: Boolean); inline;
+    procedure SetIsInputReflected(AValue: Boolean); inline;
     function GetIsOutputReflected: Boolean; inline;
-    procedure SetIsOutputReflected(value: Boolean); inline;
+    procedure SetIsOutputReflected(AValue: Boolean); inline;
     function GetOutputXor: UInt64; inline;
-    procedure SetOutputXor(value: UInt64); inline;
+    procedure SetOutputXor(AValue: UInt64); inline;
     function GetCheckValue: UInt64; inline;
-    procedure SetCheckValue(value: UInt64); inline;
+    procedure SetCheckValue(AValue: UInt64); inline;
 
     procedure GenerateTable();
     // tables work only for CRCs with width > 7
-    procedure CalculateCRCbyTable(a_data: PByte; a_data_length, a_index: Int32);
+    procedure CalculateCRCbyTable(AData: PByte; ADataLength, AIndex: Int32);
     // fast bit by bit algorithm without augmented zero bytes.
     // does not use lookup table, suited for polynomial orders between 1...32.
-    procedure CalculateCRCdirect(a_data: PByte; a_data_length, a_index: Int32);
+    procedure CalculateCRCdirect(AData: PByte; ADataLength, AIndex: Int32);
 
-    // reflects the lower 'width' bits of 'value'
-    class function Reflect(a_value: UInt64; a_width: Int32): UInt64; static;
+    // reflects the lower 'width' LBits of 'value'
+    class function Reflect(AValue: UInt64; AWidth: Int32): UInt64; static;
 
     property Names: THashLibStringArray read GetNames write SetNames;
     property Width: Int32 read GetWidth write SetWidth;
     property Polynomial: UInt64 read GetPolynomial write SetPolynomial;
-    property Initial: UInt64 read GetInitial write SetInitial;
+    property InitialValue: UInt64 read GetInitialValue write SetInitialValue;
     property IsInputReflected: Boolean read GetIsInputReflected
       write SetIsInputReflected;
     property IsOutputReflected: Boolean read GetIsOutputReflected
@@ -607,13 +601,13 @@ type
       AOutputXor, ACheckValue: UInt64; const ANames: THashLibStringArray);
 
     procedure Initialize(); override;
-    procedure TransformBytes(const a_data: THashLibByteArray;
-      a_index, a_length: Int32); override;
+    procedure TransformBytes(const AData: THashLibByteArray;
+      AIndex, ALength: Int32); override;
     function TransformFinal(): IHashResult; override;
 
     function Clone(): IHash; override;
 
-    class function CreateCRCObject(a_value: TCRCStandard): ICRC; static;
+    class function CreateCRCObject(AValue: TCRCStandard): ICRC; static;
 
   end;
 
@@ -626,9 +620,9 @@ begin
   result := FCheckValue;
 end;
 
-function TCRC.GetInitial: UInt64;
+function TCRC.GetInitialValue: UInt64;
 begin
-  result := FInitial;
+  result := FInitialValue;
 end;
 
 function TCRC.GetNames: THashLibStringArray;
@@ -661,44 +655,44 @@ begin
   result := FOutputXor;
 end;
 
-procedure TCRC.SetCheckValue(value: UInt64);
+procedure TCRC.SetCheckValue(AValue: UInt64);
 begin
-  FCheckValue := value;
+  FCheckValue := AValue;
 end;
 
-procedure TCRC.SetInitial(value: UInt64);
+procedure TCRC.SetInitialValue(AValue: UInt64);
 begin
-  FInitial := value;
+  FInitialValue := AValue;
 end;
 
-procedure TCRC.SetNames(const value: THashLibStringArray);
+procedure TCRC.SetNames(const AValue: THashLibStringArray);
 begin
-  FNames := value;
+  FNames := AValue;
 end;
 
-procedure TCRC.SetPolynomial(value: UInt64);
+procedure TCRC.SetPolynomial(AValue: UInt64);
 begin
-  FPolynomial := value;
+  FPolynomial := AValue;
 end;
 
-procedure TCRC.SetIsInputReflected(value: Boolean);
+procedure TCRC.SetIsInputReflected(AValue: Boolean);
 begin
-  FIsInputReflected := value;
+  FIsInputReflected := AValue;
 end;
 
-procedure TCRC.SetIsOutputReflected(value: Boolean);
+procedure TCRC.SetIsOutputReflected(AValue: Boolean);
 begin
-  FIsOutputReflected := value;
+  FIsOutputReflected := AValue;
 end;
 
-procedure TCRC.SetWidth(value: Int32);
+procedure TCRC.SetWidth(AValue: Int32);
 begin
-  FWidth := value;
+  FWidth := AValue;
 end;
 
-procedure TCRC.SetOutputXor(value: UInt64);
+procedure TCRC.SetOutputXor(AValue: UInt64);
 begin
-  FOutputXor := value;
+  FOutputXor := AValue;
 end;
 
 function TCRC.GetName: String;
@@ -706,89 +700,84 @@ begin
   result := Format('T%s', [(Self as ICRC).Names[0]]);
 end;
 
-procedure TCRC.CalculateCRCbyTable(a_data: PByte;
-  a_data_length, a_index: Int32);
+procedure TCRC.CalculateCRCbyTable(AData: PByte; ADataLength, AIndex: Int32);
 var
-  &Length, i: Int32;
-  tmp: UInt64;
+  LLength, LIndex: Int32;
+  LTemp: UInt64;
 begin
-
-  &Length := a_data_length;
-  i := a_index;
-  tmp := Fm_hash;
+  LLength := ADataLength;
+  LIndex := AIndex;
+  LTemp := FHash;
 
   if (IsInputReflected) then
   begin
-    while Length > 0 do
+    while LLength > 0 do
     begin
-      tmp := (tmp shr 8) xor Fm_CRCTable[Byte(tmp xor a_data[i])];
-      System.Inc(i);
-      System.Dec(Length);
+      LTemp := (LTemp shr 8) xor FCRCTable[Byte(LTemp xor AData[LIndex])];
+      System.Inc(LIndex);
+      System.Dec(LLength);
     end;
-
   end
   else
   begin
-
-    while Length > 0 do
+    while LLength > 0 do
     begin
-      tmp := (tmp shl 8) xor Fm_CRCTable
-        [Byte((tmp shr (Width - 8)) xor a_data[i])];
-      System.Inc(i);
-      System.Dec(Length);
+      LTemp := (LTemp shl 8) xor FCRCTable
+        [Byte((LTemp shr (Width - 8)) xor AData[LIndex])];
+      System.Inc(LIndex);
+      System.Dec(LLength);
     end;
-
   end;
 
-  Fm_hash := tmp;
-
+  FHash := LTemp;
 end;
 
-procedure TCRC.CalculateCRCdirect(a_data: PByte; a_data_length, a_index: Int32);
+procedure TCRC.CalculateCRCdirect(AData: PByte; ADataLength, AIndex: Int32);
 var
-  &Length, i: Int32;
-  c, bit, j: UInt64;
+  LLength, LIdx: Int32;
+  LTemp, LBit, LJdx: UInt64;
 begin
 
-  &Length := a_data_length;
-  i := a_index;
-  while Length > 0 do
+  LLength := ADataLength;
+  LIdx := AIndex;
+  while LLength > 0 do
   begin
-    c := UInt64(a_data[i]);
+    LTemp := UInt64(AData[LIdx]);
     if (IsInputReflected) then
     begin
-      c := Reflect(c, 8);
+      LTemp := Reflect(LTemp, 8);
     end;
 
-    j := $80;
-    while j > 0 do
+    LJdx := $80;
+    while LJdx > 0 do
     begin
-      bit := Fm_hash and Fm_CRCHighBitMask;
-      Fm_hash := Fm_hash shl 1;
-      if ((c and j) > 0) then
-        bit := bit xor Fm_CRCHighBitMask;
-      if (bit > 0) then
-        Fm_hash := Fm_hash xor Polynomial;
-      j := j shr 1;
+      LBit := FHash and FCRCHighBitMask;
+      FHash := FHash shl 1;
+      if ((LTemp and LJdx) > 0) then
+        LBit := LBit xor FCRCHighBitMask;
+      if (LBit > 0) then
+        FHash := FHash xor Polynomial;
+      LJdx := LJdx shr 1;
     end;
-    System.Inc(i);
-    System.Dec(Length);
+    System.Inc(LIdx);
+    System.Dec(LLength);
   end;
 
 end;
 
 function TCRC.Clone(): IHash;
 var
-  HashInstance: TCRC;
+  LHashInstance: TCRC;
 begin
-  HashInstance := TCRC.Create(Width, Polynomial, Initial, IsInputReflected,
-    IsOutputReflected, OutputXor, CheckValue, System.Copy(Names));
-  HashInstance.Fm_CRCMask := Fm_CRCMask;
-  HashInstance.Fm_CRCHighBitMask := Fm_CRCHighBitMask;
-  HashInstance.Fm_hash := Fm_hash;
-  HashInstance.FIsTableGenerated := FIsTableGenerated;
-  HashInstance.Fm_CRCTable := System.Copy(Fm_CRCTable);
-  result := HashInstance as IHash;
+  LHashInstance := TCRC.Create(Width, Polynomial, InitialValue,
+    IsInputReflected, IsOutputReflected, OutputXor, CheckValue,
+    System.Copy(Names));
+  LHashInstance.FCRCMask := FCRCMask;
+  LHashInstance.FCRCHighBitMask := FCRCHighBitMask;
+  LHashInstance.FHash := FHash;
+  LHashInstance.FIsTableGenerated := FIsTableGenerated;
+  LHashInstance.FCRCTable := System.Copy(FCRCTable);
+  result := LHashInstance as IHash;
   result.BufferSize := BufferSize;
 end;
 
@@ -837,7 +826,7 @@ begin
   Names := ANames;
   Width := AWidth;
   Polynomial := APolynomial;
-  Initial := AInitial;
+  InitialValue := AInitial;
   IsInputReflected := AIsInputReflected;
   IsOutputReflected := AIsOutputReflected;
   OutputXor := AOutputXor;
@@ -847,9 +836,9 @@ end;
 
 {$REGION 'CRC Standards Implementation'}
 
-class function TCRC.CreateCRCObject(a_value: TCRCStandard): ICRC;
+class function TCRC.CreateCRCObject(AValue: TCRCStandard): ICRC;
 begin
-  case a_value of
+  case AValue of
 
     TCRCStandard.CRC3_GSM:
       result := TCRC.Create(3, $3, $0, False, False, $7, $4,
@@ -1268,7 +1257,7 @@ begin
 
   else
     raise EArgumentInvalidHashLibException.CreateResFmt(@SUnSupportedCRCType,
-      [GetEnumName(TypeInfo(TCRCStandard), Ord(a_value))]);
+      [GetEnumName(TypeInfo(TCRCStandard), Ord(AValue))]);
 
   end;
 end;
@@ -1277,37 +1266,37 @@ end;
 
 procedure TCRC.GenerateTable;
 var
-  bit, crc: UInt64;
-  i, j: Int32;
+  LBit, LCRC: UInt64;
+  LIdx, LJdx: Int32;
 begin
-  System.SetLength(Fm_CRCTable, 256);
-  i := 0;
-  while i < 256 do
+  System.SetLength(FCRCTable, 256);
+  LIdx := 0;
+  while LIdx < 256 do
   begin
-    crc := UInt64(i);
+    LCRC := UInt64(LIdx);
     if (IsInputReflected) then
     begin
-      crc := Reflect(crc, 8);
+      LCRC := Reflect(LCRC, 8);
     end;
-    crc := crc shl (Width - 8);
-    j := 0;
-    while j < 8 do
+    LCRC := LCRC shl (Width - 8);
+    LJdx := 0;
+    while LJdx < 8 do
     begin
 
-      bit := crc and Fm_CRCHighBitMask;
-      crc := crc shl 1;
-      if (bit <> 0) then
-        crc := (crc xor Polynomial);
-      System.Inc(j);
+      LBit := LCRC and FCRCHighBitMask;
+      LCRC := LCRC shl 1;
+      if (LBit <> 0) then
+        LCRC := (LCRC xor Polynomial);
+      System.Inc(LJdx);
     end;
 
     if (IsInputReflected) then
     begin
-      crc := Reflect(crc, Width);
+      LCRC := Reflect(LCRC, Width);
     end;
-    crc := crc and Fm_CRCMask;
-    Fm_CRCTable[i] := crc;
-    System.Inc(i);
+    LCRC := LCRC and FCRCMask;
+    FCRCTable[LIdx] := LCRC;
+    System.Inc(LIdx);
   end;
 
   FIsTableGenerated := True;
@@ -1316,9 +1305,9 @@ end;
 procedure TCRC.Initialize;
 begin
   // initialize some bitmasks
-  Fm_CRCMask := (((UInt64(1) shl (Width - 1)) - 1) shl 1) or 1;
-  Fm_CRCHighBitMask := UInt64(1) shl (Width - 1);
-  Fm_hash := Initial;
+  FCRCMask := (((UInt64(1) shl (Width - 1)) - 1) shl 1) or 1;
+  FCRCHighBitMask := UInt64(1) shl (Width - 1);
+  FHash := InitialValue;
 
   if (Width > Delta) then // then use table
   begin
@@ -1329,58 +1318,57 @@ begin
     end;
 
     if (IsInputReflected) then
-      Fm_hash := Reflect(Fm_hash, Width);
+      FHash := Reflect(FHash, Width);
 
   end;
 
 end;
 
-class function TCRC.Reflect(a_value: UInt64; a_width: Int32): UInt64;
+class function TCRC.Reflect(AValue: UInt64; AWidth: Int32): UInt64;
 var
-  j, i: UInt64;
+  LIdx, LJdx: UInt64;
 begin
-  j := 1;
+  LJdx := 1;
   result := 0;
-  i := UInt64(1) shl (a_width - 1);
-  while i <> 0 do
+  LIdx := UInt64(1) shl (AWidth - 1);
+  while LIdx <> 0 do
   begin
-
-    if ((a_value and i) <> 0) then
+    if ((AValue and LIdx) <> 0) then
     begin
-      result := result or j;
+      result := result or LJdx;
     end;
-    j := j shl 1;
-    i := i shr 1;
+    LJdx := LJdx shl 1;
+    LIdx := LIdx shr 1;
   end;
 end;
 
-procedure TCRC.TransformBytes(const a_data: THashLibByteArray;
-  a_index, a_length: Int32);
+procedure TCRC.TransformBytes(const AData: THashLibByteArray;
+  AIndex, ALength: Int32);
 var
-  i: Int32;
-  ptr_a_data: PByte;
+  LIdx: Int32;
+  PtrAData: PByte;
 begin
 {$IFDEF DEBUG}
-  System.Assert(a_index >= 0);
-  System.Assert(a_length >= 0);
-  System.Assert(a_index + a_length <= System.Length(a_data));
+  System.Assert(AIndex >= 0);
+  System.Assert(ALength >= 0);
+  System.Assert(AIndex + ALength <= System.Length(AData));
 {$ENDIF DEBUG}
 
-  // table driven CRC reportedly only works for 8, 16, 24, 32 bits
-  // HOWEVER, it seems to work for everything > 7 bits, so use it
+  // table driven CRC reportedly only works for 8, 16, 24, 32 LBits
+  // HOWEVER, it seems to work for everything > 7 LBits, so use it
   // accordingly
 
-  i := a_index;
+  LIdx := AIndex;
 
-  ptr_a_data := PByte(a_data);
+  PtrAData := PByte(AData);
 
   if (Width > Delta) then
   begin
-    CalculateCRCbyTable(ptr_a_data, a_length, i);
+    CalculateCRCbyTable(PtrAData, ALength, LIdx);
   end
   else
   begin
-    CalculateCRCdirect(ptr_a_data, a_length, i);
+    CalculateCRCdirect(PtrAData, ALength, LIdx);
   end;
 
 end;
@@ -1398,23 +1386,23 @@ begin
   begin
     if (IsInputReflected xor IsOutputReflected) then
     begin
-      Fm_hash := Reflect(Fm_hash, Width);
+      FHash := Reflect(FHash, Width);
     end;
   end
   else
   begin
     if (IsOutputReflected) then
     begin
-      Fm_hash := Reflect(Fm_hash, Width);
+      FHash := Reflect(FHash, Width);
     end;
   end;
 
-  Fm_hash := Fm_hash xor OutputXor;
-  Fm_hash := Fm_hash and Fm_CRCMask;
+  FHash := FHash xor OutputXor;
+  FHash := FHash and FCRCMask;
 
   if Width = 21 then // special case
   begin
-    LUInt32 := UInt32(Fm_hash);
+    LUInt32 := UInt32(FHash);
 
     result := THashResult.Create(LUInt32);
 
@@ -1426,27 +1414,27 @@ begin
   case Width shr 3 of
     0:
       begin
-        LUInt8 := UInt8(Fm_hash);
+        LUInt8 := UInt8(FHash);
         result := THashResult.Create(LUInt8);
 
       end;
 
     1 .. 2:
       begin
-        LUInt16 := UInt16(Fm_hash);
+        LUInt16 := UInt16(FHash);
 
         result := THashResult.Create(LUInt16);
       end;
 
     3 .. 4:
       begin
-        LUInt32 := UInt32(Fm_hash);
+        LUInt32 := UInt32(FHash);
 
         result := THashResult.Create(LUInt32);
       end
   else
     begin
-      LUInt64 := (Fm_hash);
+      LUInt64 := (FHash);
 
       result := THashResult.Create(LUInt64);
     end;
@@ -1457,4 +1445,3 @@ begin
 end;
 
 end.
-

+ 13 - 11
src/libraries/hashlib4pascal/HlpCRC16.pas

@@ -31,12 +31,13 @@ type
     FCRCAlgorithm: ICRC;
 
   public
-    constructor Create(_poly, _Init: UInt64; _refIn, _refOut: Boolean;
-      _XorOut, _check: UInt64; const _Names: THashLibStringArray);
+    constructor Create(APolynomial, AInitial: UInt64;
+      AIsInputReflected, AIsOutputReflected: Boolean;
+      AOutputXor, ACheckValue: UInt64; const ANames: THashLibStringArray);
 
     procedure Initialize(); override;
-    procedure TransformBytes(const a_data: THashLibByteArray;
-      a_index, a_length: Int32); override;
+    procedure TransformBytes(const AData: THashLibByteArray;
+      AIndex, ALength: Int32); override;
     function TransformFinal(): IHashResult; override;
 
   end;
@@ -52,12 +53,13 @@ implementation
 
 { TCRC16 }
 
-constructor TCRC16.Create(_poly, _Init: UInt64; _refIn, _refOut: Boolean;
-  _XorOut, _check: UInt64; const _Names: THashLibStringArray);
+constructor TCRC16.Create(APolynomial, AInitial: UInt64;
+  AIsInputReflected, AIsOutputReflected: Boolean;
+  AOutputXor, ACheckValue: UInt64; const ANames: THashLibStringArray);
 begin
   Inherited Create(2, 1);
-  FCRCAlgorithm := TCRC.Create(16, _poly, _Init, _refIn, _refOut, _XorOut,
-    _check, _Names);
+  FCRCAlgorithm := TCRC.Create(16, APolynomial, AInitial, AIsInputReflected,
+    AIsOutputReflected, AOutputXor, ACheckValue, ANames);
 end;
 
 procedure TCRC16.Initialize;
@@ -65,10 +67,10 @@ begin
   FCRCAlgorithm.Initialize;
 end;
 
-procedure TCRC16.TransformBytes(const a_data: THashLibByteArray;
-  a_index, a_length: Int32);
+procedure TCRC16.TransformBytes(const AData: THashLibByteArray;
+  AIndex, ALength: Int32);
 begin
-  FCRCAlgorithm.TransformBytes(a_data, a_index, a_length);
+  FCRCAlgorithm.TransformBytes(AData, AIndex, ALength);
 end;
 
 function TCRC16.TransformFinal: IHashResult;

+ 13 - 11
src/libraries/hashlib4pascal/HlpCRC32.pas

@@ -35,12 +35,13 @@ type
 
   public
 
-    constructor Create(_poly, _Init: UInt64; _refIn, _refOut: Boolean;
-      _XorOut, _check: UInt64; const _Names: THashLibStringArray);
+    constructor Create(APolynomial, AInitial: UInt64;
+      AIsInputReflected, AIsOutputReflected: Boolean;
+      AOutputXor, ACheckValue: UInt64; const ANames: THashLibStringArray);
 
     procedure Initialize(); override;
-    procedure TransformBytes(const a_data: THashLibByteArray;
-      a_index, a_length: Int32); override;
+    procedure TransformBytes(const AData: THashLibByteArray;
+      AIndex, ALength: Int32); override;
     function TransformFinal(): IHashResult; override;
     function Clone(): IHash; override;
 
@@ -69,12 +70,13 @@ begin
   Result := FCRCAlgorithm.Clone();
 end;
 
-constructor TCRC32.Create(_poly, _Init: UInt64; _refIn, _refOut: Boolean;
-  _XorOut, _check: UInt64; const _Names: THashLibStringArray);
+constructor TCRC32.Create(APolynomial, AInitial: UInt64;
+  AIsInputReflected, AIsOutputReflected: Boolean;
+  AOutputXor, ACheckValue: UInt64; const ANames: THashLibStringArray);
 begin
   Inherited Create(4, 1);
-  FCRCAlgorithm := TCRC.Create(32, _poly, _Init, _refIn, _refOut, _XorOut,
-    _check, _Names);
+  FCRCAlgorithm := TCRC.Create(32, APolynomial, AInitial, AIsInputReflected,
+    AIsOutputReflected, AOutputXor, ACheckValue, ANames);
 end;
 
 procedure TCRC32.Initialize;
@@ -82,10 +84,10 @@ begin
   FCRCAlgorithm.Initialize;
 end;
 
-procedure TCRC32.TransformBytes(const a_data: THashLibByteArray;
-  a_index, a_length: Int32);
+procedure TCRC32.TransformBytes(const AData: THashLibByteArray;
+  AIndex, ALength: Int32);
 begin
-  FCRCAlgorithm.TransformBytes(a_data, a_index, a_length);
+  FCRCAlgorithm.TransformBytes(AData, AIndex, ALength);
 end;
 
 function TCRC32.TransformFinal: IHashResult;

+ 18 - 19
src/libraries/hashlib4pascal/HlpCRC32Fast.pas

@@ -50,8 +50,8 @@ type
 
   public
     constructor Create();
-    procedure TransformBytes(const a_data: THashLibByteArray;
-      a_index, a_length: Int32); override;
+    procedure TransformBytes(const AData: THashLibByteArray;
+      AIndex, ALength: Int32); override;
     function Clone(): IHash; override;
 
   end;
@@ -70,8 +70,8 @@ type
 
   public
     constructor Create();
-    procedure TransformBytes(const a_data: THashLibByteArray;
-      a_index, a_length: Int32); override;
+    procedure TransformBytes(const AData: THashLibByteArray;
+      AIndex, ALength: Int32); override;
     function Clone(): IHash; override;
 
   end;
@@ -187,11 +187,11 @@ end;
 
 function TCRC32_PKZIP.Clone(): IHash;
 var
-  HashInstance: TCRC32_PKZIP;
+  LHashInstance: TCRC32_PKZIP;
 begin
-  HashInstance := TCRC32_PKZIP.Create();
-  HashInstance.FCurrentCRC := FCurrentCRC;
-  Result := HashInstance as IHash;
+  LHashInstance := TCRC32_PKZIP.Create();
+  LHashInstance.FCurrentCRC := FCurrentCRC;
+  Result := LHashInstance as IHash;
   Result.BufferSize := BufferSize;
 end;
 
@@ -200,10 +200,10 @@ begin
   Inherited Create();
 end;
 
-procedure TCRC32_PKZIP.TransformBytes(const a_data: THashLibByteArray;
-  a_index, a_length: Int32);
+procedure TCRC32_PKZIP.TransformBytes(const AData: THashLibByteArray;
+  AIndex, ALength: Int32);
 begin
-  LocalCRCCompute(FCRC32_PKZIP_Table, a_data, a_index, a_length);
+  LocalCRCCompute(FCRC32_PKZIP_Table, AData, AIndex, ALength);
 end;
 
 class constructor TCRC32_PKZIP.CRC32_PKZIP();
@@ -215,11 +215,11 @@ end;
 
 function TCRC32_CASTAGNOLI.Clone(): IHash;
 var
-  HashInstance: TCRC32_CASTAGNOLI;
+  LHashInstance: TCRC32_CASTAGNOLI;
 begin
-  HashInstance := TCRC32_CASTAGNOLI.Create();
-  HashInstance.FCurrentCRC := FCurrentCRC;
-  Result := HashInstance as IHash;
+  LHashInstance := TCRC32_CASTAGNOLI.Create();
+  LHashInstance.FCurrentCRC := FCurrentCRC;
+  Result := LHashInstance as IHash;
   Result.BufferSize := BufferSize;
 end;
 
@@ -228,10 +228,10 @@ begin
   Inherited Create();
 end;
 
-procedure TCRC32_CASTAGNOLI.TransformBytes(const a_data: THashLibByteArray;
-  a_index, a_length: Int32);
+procedure TCRC32_CASTAGNOLI.TransformBytes(const AData: THashLibByteArray;
+  AIndex, ALength: Int32);
 begin
-  LocalCRCCompute(FCRC32_CASTAGNOLI_Table, a_data, a_index, a_length);
+  LocalCRCCompute(FCRC32_CASTAGNOLI_Table, AData, AIndex, ALength);
 end;
 
 class constructor TCRC32_CASTAGNOLI.CRC32_CASTAGNOLI();
@@ -240,4 +240,3 @@ begin
 end;
 
 end.
-

+ 13 - 11
src/libraries/hashlib4pascal/HlpCRC64.pas

@@ -32,12 +32,13 @@ type
     FCRCAlgorithm: ICRC;
 
   public
-    constructor Create(_poly, _Init: UInt64; _refIn, _refOut: Boolean;
-      _XorOut, _check: UInt64; const _Names: THashLibStringArray);
+    constructor Create(APolynomial, AInitial: UInt64;
+      AIsInputReflected, AIsOutputReflected: Boolean;
+      AOutputXor, ACheckValue: UInt64; const ANames: THashLibStringArray);
 
     procedure Initialize(); override;
-    procedure TransformBytes(const a_data: THashLibByteArray;
-      a_index, a_length: Int32); override;
+    procedure TransformBytes(const AData: THashLibByteArray;
+      AIndex, ALength: Int32); override;
     function TransformFinal(): IHashResult; override;
     function Clone(): IHash; override;
 
@@ -59,12 +60,13 @@ begin
   result := FCRCAlgorithm.Clone();
 end;
 
-constructor TCRC64.Create(_poly, _Init: UInt64; _refIn, _refOut: Boolean;
-  _XorOut, _check: UInt64; const _Names: THashLibStringArray);
+constructor TCRC64.Create(APolynomial, AInitial: UInt64;
+  AIsInputReflected, AIsOutputReflected: Boolean;
+  AOutputXor, ACheckValue: UInt64; const ANames: THashLibStringArray);
 begin
   Inherited Create(8, 1);
-  FCRCAlgorithm := TCRC.Create(64, _poly, _Init, _refIn, _refOut, _XorOut,
-    _check, _Names);
+  FCRCAlgorithm := TCRC.Create(64, APolynomial, AInitial, AIsInputReflected,
+    AIsOutputReflected, AOutputXor, ACheckValue, ANames);
 end;
 
 procedure TCRC64.Initialize;
@@ -72,10 +74,10 @@ begin
   FCRCAlgorithm.Initialize;
 end;
 
-procedure TCRC64.TransformBytes(const a_data: THashLibByteArray;
-  a_index, a_length: Int32);
+procedure TCRC64.TransformBytes(const AData: THashLibByteArray;
+  AIndex, ALength: Int32);
 begin
-  FCRCAlgorithm.TransformBytes(a_data, a_index, a_length);
+  FCRCAlgorithm.TransformBytes(AData, AIndex, ALength);
 end;
 
 function TCRC64.TransformFinal: IHashResult;

+ 283 - 247
src/libraries/hashlib4pascal/HlpConverters.pas

@@ -5,15 +5,9 @@ unit HlpConverters;
 interface
 
 uses
-{$IFDEF HAS_UNITSCOPE}
-  System.Classes,
-  System.StrUtils,
-  System.SysUtils,
-{$ELSE}
   Classes,
   StrUtils,
   SysUtils,
-{$ENDIF HAS_UNITSCOPE}
   HlpHashLibTypes,
   HlpBits,
   HlpBitConverter;
@@ -25,76 +19,84 @@ type
   TConverters = class sealed(TObject)
 
   strict private
-    class function SplitString(const S: String; Delimiter: Char)
+    class function SplitString(const AInput: String; ADelimiter: Char)
       : THashLibStringArray; static;
 
 {$IFDEF DEBUG}
-    class procedure Check(const a_in: THashLibByteArray;
-      a_in_size, a_out_size: Int32); overload; static;
+    class procedure Check(const AInput: THashLibByteArray;
+      AInputSize, AOutputSize: Int32); overload; static;
 {$ENDIF DEBUG}
-    class procedure swap_copy_str_to_u32(src: Pointer; src_index: Int32;
-      dest: Pointer; dest_index: Int32; length: Int32); static;
+    class procedure swap_copy_str_to_u32(ASource: Pointer; ASourceIndex: Int32;
+      ADestination: Pointer; ADestinationIndex: Int32; ASize: Int32); static;
 
-    class procedure swap_copy_str_to_u64(src: Pointer; src_index: Int32;
-      dest: Pointer; dest_index: Int32; length: Int32); static;
+    class procedure swap_copy_str_to_u64(ASource: Pointer; ASourceIndex: Int32;
+      ADestination: Pointer; ADestinationIndex: Int32; ASize: Int32); static;
 
   public
 
-    class function be2me_32(x: UInt32): UInt32; static; inline;
+    class function be2me_32(AInput: UInt32): UInt32; static; inline;
 
-    class function be2me_64(x: UInt64): UInt64; static; inline;
+    class function be2me_64(AInput: UInt64): UInt64; static; inline;
 
-    class function le2me_32(x: UInt32): UInt32; static; inline;
+    class function le2me_32(AInput: UInt32): UInt32; static; inline;
 
-    class function le2me_64(x: UInt64): UInt64; static; inline;
+    class function le2me_64(AInput: UInt64): UInt64; static; inline;
 
-    class procedure be32_copy(src: Pointer; src_index: Int32; dest: Pointer;
-      dest_index: Int32; length: Int32); static; inline;
+    class procedure be32_copy(ASource: Pointer; ASourceIndex: Int32;
+      ADestination: Pointer; ADestinationIndex: Int32; ASize: Int32);
+      static; inline;
 
-    class procedure le32_copy(src: Pointer; src_index: Int32; dest: Pointer;
-      dest_index: Int32; length: Int32); static; inline;
+    class procedure le32_copy(ASource: Pointer; ASourceIndex: Int32;
+      ADestination: Pointer; ADestinationIndex: Int32; ASize: Int32);
+      static; inline;
 
-    class procedure be64_copy(src: Pointer; src_index: Int32; dest: Pointer;
-      dest_index: Int32; length: Int32); static; inline;
+    class procedure be64_copy(ASource: Pointer; ASourceIndex: Int32;
+      ADestination: Pointer; ADestinationIndex: Int32; ASize: Int32);
+      static; inline;
 
-    class procedure le64_copy(src: Pointer; src_index: Int32; dest: Pointer;
-      dest_index: Int32; length: Int32); static; inline;
+    class procedure le64_copy(ASource: Pointer; ASourceIndex: Int32;
+      ADestination: Pointer; ADestinationIndex: Int32; ASize: Int32);
+      static; inline;
 
-    class function ReadBytesAsUInt32LE(a_in: PByte; a_index: Int32): UInt32;
+    class function ReadBytesAsUInt32LE(AInput: PByte; AIndex: Int32): UInt32;
       static; inline;
 
-    class function ReadBytesAsUInt64LE(a_in: PByte; a_index: Int32): UInt64;
+    class function ReadBytesAsUInt64LE(AInput: PByte; AIndex: Int32): UInt64;
       static; inline;
 
-    class function ReadUInt32AsBytesLE(a_in: UInt32): THashLibByteArray;
+    class function ReadUInt32AsBytesLE(AInput: UInt32): THashLibByteArray;
       overload; static; inline;
 
-    class function ReadUInt64AsBytesLE(a_in: UInt64): THashLibByteArray;
+    class function ReadUInt64AsBytesLE(AInput: UInt64): THashLibByteArray;
       overload; static; inline;
 
-    class procedure ReadUInt32AsBytesLE(a_in: UInt32;
-      const a_out: THashLibByteArray; a_index: Int32); overload; static; inline;
+    class procedure ReadUInt32AsBytesLE(AInput: UInt32;
+      const AOutput: THashLibByteArray; AIndex: Int32); overload;
+      static; inline;
 
-    class procedure ReadUInt32AsBytesBE(a_in: UInt32;
-      const a_out: THashLibByteArray; a_index: Int32); overload; static; inline;
+    class procedure ReadUInt32AsBytesBE(AInput: UInt32;
+      const AOutput: THashLibByteArray; AIndex: Int32); overload;
+      static; inline;
 
-    class procedure ReadUInt64AsBytesLE(a_in: UInt64;
-      const a_out: THashLibByteArray; a_index: Int32); overload; static; inline;
+    class procedure ReadUInt64AsBytesLE(AInput: UInt64;
+      const AOutput: THashLibByteArray; AIndex: Int32); overload;
+      static; inline;
 
-    class procedure ReadUInt64AsBytesBE(a_in: UInt64;
-      const a_out: THashLibByteArray; a_index: Int32); overload; static; inline;
+    class procedure ReadUInt64AsBytesBE(AInput: UInt64;
+      const AOutput: THashLibByteArray; AIndex: Int32); overload;
+      static; inline;
 
-    class function ConvertStringToBytes(const a_in: String;
-      const a_encoding: TEncoding): THashLibByteArray; overload; static;
+    class function ConvertStringToBytes(const AInput: String;
+      const AEncoding: TEncoding): THashLibByteArray; overload; static;
 
-    class function ConvertBytesToString(const a_in: THashLibByteArray;
-      const a_encoding: TEncoding): String; overload; static;
+    class function ConvertBytesToString(const AInput: THashLibByteArray;
+      const AEncoding: TEncoding): String; overload; static;
 
-    class function ConvertHexStringToBytes(const a_in: String)
+    class function ConvertHexStringToBytes(const AInput: String)
       : THashLibByteArray; static; inline;
 
-    class function ConvertBytesToHexString(const a_in: THashLibByteArray;
-      a_group: Boolean): String; static;
+    class function ConvertBytesToHexString(const AInput: THashLibByteArray;
+      AGroup: Boolean): String; static;
 
   end;
 
@@ -104,400 +106,434 @@ implementation
 
 {$IFDEF DEBUG}
 
-class procedure TConverters.Check(const a_in: THashLibByteArray;
-  a_in_size, a_out_size: Int32);
+class procedure TConverters.Check(const AInput: THashLibByteArray;
+  AInputSize, AOutputSize: Int32);
 begin
-  System.Assert(((System.length(a_in) * a_in_size) mod a_out_size) = 0);
+  System.Assert(((System.length(AInput) * AInputSize) mod AOutputSize) = 0);
 end;
 
 {$ENDIF DEBUG}
 
-class procedure TConverters.swap_copy_str_to_u32(src: Pointer; src_index: Int32;
-  dest: Pointer; dest_index: Int32; length: Int32);
+class procedure TConverters.swap_copy_str_to_u32(ASource: Pointer;
+  ASourceIndex: Int32; ADestination: Pointer; ADestinationIndex: Int32;
+  ASize: Int32);
 var
-  lsrc, ldest, lend: PCardinal;
-  lbsrc: PByte;
-  lLength: Int32;
+  LPtrSourceStart, LPtrDestinationStart, LPtrSourceEnd: PCardinal;
+  LPtrByteSourceStart: PByte;
+  LLength: Int32;
 begin
   // if all pointers and length are 32-bits aligned
-  if ((Int32(PByte(dest) - PByte(0)) or (PByte(src) - PByte(0)) or src_index or
-    dest_index or length) and 3) = 0 then
+  if ((Int32(PByte(ADestination) - PByte(0)) or (PByte(ASource) - PByte(0)) or
+    ASourceIndex or ADestinationIndex or ASize) and 3) = 0 then
   begin
     // copy memory as 32-bit words
-    lsrc := PCardinal(PByte(src) + src_index);
-    lend := PCardinal((PByte(src) + src_index) + length);
-    ldest := PCardinal(PByte(dest) + dest_index);
-    while lsrc < lend do
+    LPtrSourceStart := PCardinal(PByte(ASource) + ASourceIndex);
+    LPtrSourceEnd := PCardinal((PByte(ASource) + ASourceIndex) + ASize);
+    LPtrDestinationStart := PCardinal(PByte(ADestination) + ADestinationIndex);
+    while LPtrSourceStart < LPtrSourceEnd do
     begin
-      ldest^ := TBits.ReverseBytesUInt32(lsrc^);
-      System.Inc(ldest);
-      System.Inc(lsrc);
+      LPtrDestinationStart^ := TBits.ReverseBytesUInt32(LPtrSourceStart^);
+      System.Inc(LPtrDestinationStart);
+      System.Inc(LPtrSourceStart);
     end;
   end
   else
   begin
-    lbsrc := (PByte(src) + src_index);
-
-    lLength := length + dest_index;
-    while dest_index < lLength do
+    LPtrByteSourceStart := (PByte(ASource) + ASourceIndex);
+    LLength := ASize + ADestinationIndex;
+    while ADestinationIndex < LLength do
     begin
-
-      PByte(dest)[dest_index xor 3] := lbsrc^;
-
-      System.Inc(lbsrc);
-      System.Inc(dest_index);
+      PByte(ADestination)[ADestinationIndex xor 3] := LPtrByteSourceStart^;
+      System.Inc(LPtrByteSourceStart);
+      System.Inc(ADestinationIndex);
     end;
-
   end;
 end;
 
-class procedure TConverters.swap_copy_str_to_u64(src: Pointer; src_index: Int32;
-  dest: Pointer; dest_index: Int32; length: Int32);
+class procedure TConverters.swap_copy_str_to_u64(ASource: Pointer;
+  ASourceIndex: Int32; ADestination: Pointer; ADestinationIndex: Int32;
+  ASize: Int32);
 var
-  lsrc, ldest, lend: PUInt64;
-  lbsrc: PByte;
-  lLength: Int32;
+  LPtrSourceStart, LPtrDestinationStart, LPtrSourceEnd: PUInt64;
+  LPtrByteSourceStart: PByte;
+  LLength: Int32;
 begin
   // if all pointers and length are 64-bits aligned
-  if ((Int32(PByte(dest) - PByte(0)) or (PByte(src) - PByte(0)) or src_index or
-    dest_index or length) and 7) = 0 then
+  if ((Int32(PByte(ADestination) - PByte(0)) or (PByte(ASource) - PByte(0)) or
+    ASourceIndex or ADestinationIndex or ASize) and 7) = 0 then
   begin
     // copy aligned memory block as 64-bit integers
-    lsrc := PUInt64(PByte(src) + src_index);
-    lend := PUInt64((PByte(src) + src_index) + length);
-    ldest := PUInt64(PByte(dest) + dest_index);
-    while lsrc < lend do
+    LPtrSourceStart := PUInt64(PByte(ASource) + ASourceIndex);
+    LPtrSourceEnd := PUInt64((PByte(ASource) + ASourceIndex) + ASize);
+    LPtrDestinationStart := PUInt64(PByte(ADestination) + ADestinationIndex);
+    while LPtrSourceStart < LPtrSourceEnd do
     begin
-      ldest^ := TBits.ReverseBytesUInt64(lsrc^);
-      System.Inc(ldest);
-      System.Inc(lsrc);
+      LPtrDestinationStart^ := TBits.ReverseBytesUInt64(LPtrSourceStart^);
+      System.Inc(LPtrDestinationStart);
+      System.Inc(LPtrSourceStart);
     end;
   end
   else
   begin
-    lbsrc := (PByte(src) + src_index);
-
-    lLength := length + dest_index;
-    while dest_index < lLength do
+    LPtrByteSourceStart := (PByte(ASource) + ASourceIndex);
+    LLength := ASize + ADestinationIndex;
+    while ADestinationIndex < LLength do
     begin
-
-      PByte(dest)[dest_index xor 7] := lbsrc^;
-
-      System.Inc(lbsrc);
-      System.Inc(dest_index);
+      PByte(ADestination)[ADestinationIndex xor 7] := LPtrByteSourceStart^;
+      System.Inc(LPtrByteSourceStart);
+      System.Inc(ADestinationIndex);
     end;
-
   end;
 end;
 
-class function TConverters.be2me_32(x: UInt32): UInt32;
+class function TConverters.be2me_32(AInput: UInt32): UInt32;
 begin
   if TBitConverter.IsLittleEndian then
-    result := TBits.ReverseBytesUInt32(x)
+  begin
+    result := TBits.ReverseBytesUInt32(AInput)
+  end
   else
-    result := x;
+  begin
+    result := AInput;
+  end;
 end;
 
-class function TConverters.be2me_64(x: UInt64): UInt64;
+class function TConverters.be2me_64(AInput: UInt64): UInt64;
 begin
   if TBitConverter.IsLittleEndian then
-    result := TBits.ReverseBytesUInt64(x)
+  begin
+    result := TBits.ReverseBytesUInt64(AInput)
+  end
   else
-    result := x;
+  begin
+    result := AInput;
+  end;
 end;
 
-class procedure TConverters.be32_copy(src: Pointer; src_index: Int32;
-  dest: Pointer; dest_index: Int32; length: Int32);
+class procedure TConverters.be32_copy(ASource: Pointer; ASourceIndex: Int32;
+  ADestination: Pointer; ADestinationIndex: Int32; ASize: Int32);
 begin
   if TBitConverter.IsLittleEndian then
-    swap_copy_str_to_u32(src, src_index, dest, dest_index, length)
+  begin
+    swap_copy_str_to_u32(ASource, ASourceIndex, ADestination,
+      ADestinationIndex, ASize)
+  end
   else
-    System.Move(Pointer(PByte(src) + src_index)^,
-      Pointer(PByte(dest) + dest_index)^, length);
+  begin
+    System.Move(Pointer(PByte(ASource) + ASourceIndex)^,
+      Pointer(PByte(ADestination) + ADestinationIndex)^, ASize);
+  end;
 end;
 
-class procedure TConverters.be64_copy(src: Pointer; src_index: Int32;
-  dest: Pointer; dest_index: Int32; length: Int32);
+class procedure TConverters.be64_copy(ASource: Pointer; ASourceIndex: Int32;
+  ADestination: Pointer; ADestinationIndex: Int32; ASize: Int32);
 begin
   if TBitConverter.IsLittleEndian then
-    swap_copy_str_to_u64(src, src_index, dest, dest_index, length)
+  begin
+    swap_copy_str_to_u64(ASource, ASourceIndex, ADestination,
+      ADestinationIndex, ASize)
+  end
   else
-    System.Move(Pointer(PByte(src) + src_index)^,
-      Pointer(PByte(dest) + dest_index)^, length);
+  begin
+    System.Move(Pointer(PByte(ASource) + ASourceIndex)^,
+      Pointer(PByte(ADestination) + ADestinationIndex)^, ASize);
+  end;
 end;
 
-class function TConverters.le2me_32(x: UInt32): UInt32;
+class function TConverters.le2me_32(AInput: UInt32): UInt32;
 begin
   if not TBitConverter.IsLittleEndian then
-    result := TBits.ReverseBytesUInt32(x)
+  begin
+    result := TBits.ReverseBytesUInt32(AInput)
+  end
   else
-    result := x;
+  begin
+    result := AInput;
+  end;
 end;
 
-class function TConverters.le2me_64(x: UInt64): UInt64;
+class function TConverters.le2me_64(AInput: UInt64): UInt64;
 begin
   if not TBitConverter.IsLittleEndian then
-    result := TBits.ReverseBytesUInt64(x)
+  begin
+    result := TBits.ReverseBytesUInt64(AInput)
+  end
   else
-    result := x;
+  begin
+    result := AInput;
+  end;
 end;
 
-class procedure TConverters.le32_copy(src: Pointer; src_index: Int32;
-  dest: Pointer; dest_index: Int32; length: Int32);
+class procedure TConverters.le32_copy(ASource: Pointer; ASourceIndex: Int32;
+  ADestination: Pointer; ADestinationIndex: Int32; ASize: Int32);
 begin
   if TBitConverter.IsLittleEndian then
-    System.Move(Pointer(PByte(src) + src_index)^,
-      Pointer(PByte(dest) + dest_index)^, length)
+  begin
+    System.Move(Pointer(PByte(ASource) + ASourceIndex)^,
+      Pointer(PByte(ADestination) + ADestinationIndex)^, ASize)
+  end
   else
-    swap_copy_str_to_u32(src, src_index, dest, dest_index, length);
+  begin
+    swap_copy_str_to_u32(ASource, ASourceIndex, ADestination,
+      ADestinationIndex, ASize);
+  end;
 end;
 
-class procedure TConverters.le64_copy(src: Pointer; src_index: Int32;
-  dest: Pointer; dest_index: Int32; length: Int32);
+class procedure TConverters.le64_copy(ASource: Pointer; ASourceIndex: Int32;
+  ADestination: Pointer; ADestinationIndex: Int32; ASize: Int32);
 begin
   if TBitConverter.IsLittleEndian then
-    System.Move(Pointer(PByte(src) + src_index)^,
-      Pointer(PByte(dest) + dest_index)^, length)
+  begin
+    System.Move(Pointer(PByte(ASource) + ASourceIndex)^,
+      Pointer(PByte(ADestination) + ADestinationIndex)^, ASize)
+  end
   else
-    swap_copy_str_to_u64(src, src_index, dest, dest_index, length);
+  begin
+    swap_copy_str_to_u64(ASource, ASourceIndex, ADestination,
+      ADestinationIndex, ASize);
+  end;
 end;
 
-class function TConverters.ReadBytesAsUInt32LE(a_in: PByte;
-  a_index: Int32): UInt32;
+class function TConverters.ReadBytesAsUInt32LE(AInput: PByte;
+  AIndex: Int32): UInt32;
 begin
 {$IFDEF FPC}
 {$IFDEF FPC_REQUIRES_PROPER_ALIGNMENT}
-  System.Move(a_in[a_index], result, System.SizeOf(UInt32));
+  System.Move(AInput[AIndex], result, System.SizeOf(UInt32));
 {$ELSE}
-  result := PCardinal(a_in + a_index)^;
+  result := PCardinal(AInput + AIndex)^;
 {$ENDIF FPC_REQUIRES_PROPER_ALIGNMENT}
 {$ELSE}
   // Delphi does not handle unaligned memory access on ARM Devices properly.
-  System.Move(a_in[a_index], result, System.SizeOf(UInt32));
+  System.Move(AInput[AIndex], result, System.SizeOf(UInt32));
 {$ENDIF FPC}
   result := le2me_32(result);
 end;
 
-class function TConverters.ReadBytesAsUInt64LE(a_in: PByte;
-  a_index: Int32): UInt64;
+class function TConverters.ReadBytesAsUInt64LE(AInput: PByte;
+  AIndex: Int32): UInt64;
 begin
 {$IFDEF FPC}
 {$IFDEF FPC_REQUIRES_PROPER_ALIGNMENT}
-  System.Move(a_in[a_index], result, System.SizeOf(UInt64));
+  System.Move(AInput[AIndex], result, System.SizeOf(UInt64));
 {$ELSE}
-  result := PUInt64(a_in + a_index)^;
+  result := PUInt64(AInput + AIndex)^;
 {$ENDIF FPC_REQUIRES_PROPER_ALIGNMENT}
 {$ELSE}
   // Delphi does not handle unaligned memory access on ARM Devices properly.
-  System.Move(a_in[a_index], result, System.SizeOf(UInt64));
+  System.Move(AInput[AIndex], result, System.SizeOf(UInt64));
 {$ENDIF FPC}
   result := le2me_64(result);
 end;
 
-class function TConverters.ReadUInt32AsBytesLE(a_in: UInt32): THashLibByteArray;
+class function TConverters.ReadUInt32AsBytesLE(AInput: UInt32)
+  : THashLibByteArray;
 begin
-  result := THashLibByteArray.Create(Byte(a_in), Byte(a_in shr 8),
-    Byte(a_in shr 16), Byte(a_in shr 24));
+  result := THashLibByteArray.Create(Byte(AInput), Byte(AInput shr 8),
+    Byte(AInput shr 16), Byte(AInput shr 24));
 end;
 
-class function TConverters.ReadUInt64AsBytesLE(a_in: UInt64): THashLibByteArray;
+class function TConverters.ReadUInt64AsBytesLE(AInput: UInt64)
+  : THashLibByteArray;
 begin
-  result := THashLibByteArray.Create(Byte(a_in), Byte(a_in shr 8),
-    Byte(a_in shr 16), Byte(a_in shr 24), Byte(a_in shr 32), Byte(a_in shr 40),
-    Byte(a_in shr 48), Byte(a_in shr 56));
+  result := THashLibByteArray.Create(Byte(AInput), Byte(AInput shr 8),
+    Byte(AInput shr 16), Byte(AInput shr 24), Byte(AInput shr 32),
+    Byte(AInput shr 40), Byte(AInput shr 48), Byte(AInput shr 56));
 end;
 
-class procedure TConverters.ReadUInt32AsBytesLE(a_in: UInt32;
-  const a_out: THashLibByteArray; a_index: Int32);
+class procedure TConverters.ReadUInt32AsBytesLE(AInput: UInt32;
+  const AOutput: THashLibByteArray; AIndex: Int32);
 begin
-  a_out[a_index] := Byte(a_in);
-  a_out[a_index + 1] := Byte(a_in shr 8);
-  a_out[a_index + 2] := Byte(a_in shr 16);
-  a_out[a_index + 3] := Byte(a_in shr 24);
+  AOutput[AIndex] := Byte(AInput);
+  AOutput[AIndex + 1] := Byte(AInput shr 8);
+  AOutput[AIndex + 2] := Byte(AInput shr 16);
+  AOutput[AIndex + 3] := Byte(AInput shr 24);
 end;
 
-class procedure TConverters.ReadUInt32AsBytesBE(a_in: UInt32;
-  const a_out: THashLibByteArray; a_index: Int32);
+class procedure TConverters.ReadUInt32AsBytesBE(AInput: UInt32;
+  const AOutput: THashLibByteArray; AIndex: Int32);
 begin
-  a_out[a_index] := Byte(a_in shr 24);
-  a_out[a_index + 1] := Byte(a_in shr 16);
-  a_out[a_index + 2] := Byte(a_in shr 8);
-  a_out[a_index + 3] := Byte(a_in);
+  AOutput[AIndex] := Byte(AInput shr 24);
+  AOutput[AIndex + 1] := Byte(AInput shr 16);
+  AOutput[AIndex + 2] := Byte(AInput shr 8);
+  AOutput[AIndex + 3] := Byte(AInput);
 end;
 
-class procedure TConverters.ReadUInt64AsBytesLE(a_in: UInt64;
-  const a_out: THashLibByteArray; a_index: Int32);
+class procedure TConverters.ReadUInt64AsBytesLE(AInput: UInt64;
+  const AOutput: THashLibByteArray; AIndex: Int32);
 begin
-  a_out[a_index] := Byte(a_in);
-  a_out[a_index + 1] := Byte(a_in shr 8);
-  a_out[a_index + 2] := Byte(a_in shr 16);
-  a_out[a_index + 3] := Byte(a_in shr 24);
-  a_out[a_index + 4] := Byte(a_in shr 32);
-  a_out[a_index + 5] := Byte(a_in shr 40);
-  a_out[a_index + 6] := Byte(a_in shr 48);
-  a_out[a_index + 7] := Byte(a_in shr 56);
+  AOutput[AIndex] := Byte(AInput);
+  AOutput[AIndex + 1] := Byte(AInput shr 8);
+  AOutput[AIndex + 2] := Byte(AInput shr 16);
+  AOutput[AIndex + 3] := Byte(AInput shr 24);
+  AOutput[AIndex + 4] := Byte(AInput shr 32);
+  AOutput[AIndex + 5] := Byte(AInput shr 40);
+  AOutput[AIndex + 6] := Byte(AInput shr 48);
+  AOutput[AIndex + 7] := Byte(AInput shr 56);
 end;
 
-class procedure TConverters.ReadUInt64AsBytesBE(a_in: UInt64;
-  const a_out: THashLibByteArray; a_index: Int32);
+class procedure TConverters.ReadUInt64AsBytesBE(AInput: UInt64;
+  const AOutput: THashLibByteArray; AIndex: Int32);
 begin
-  a_out[a_index] := Byte(a_in shr 56);
-  a_out[a_index + 1] := Byte(a_in shr 48);
-  a_out[a_index + 2] := Byte(a_in shr 40);
-  a_out[a_index + 3] := Byte(a_in shr 32);
-  a_out[a_index + 4] := Byte(a_in shr 24);
-  a_out[a_index + 5] := Byte(a_in shr 16);
-  a_out[a_index + 6] := Byte(a_in shr 8);
-  a_out[a_index + 7] := Byte(a_in);
+  AOutput[AIndex] := Byte(AInput shr 56);
+  AOutput[AIndex + 1] := Byte(AInput shr 48);
+  AOutput[AIndex + 2] := Byte(AInput shr 40);
+  AOutput[AIndex + 3] := Byte(AInput shr 32);
+  AOutput[AIndex + 4] := Byte(AInput shr 24);
+  AOutput[AIndex + 5] := Byte(AInput shr 16);
+  AOutput[AIndex + 6] := Byte(AInput shr 8);
+  AOutput[AIndex + 7] := Byte(AInput);
 end;
 
-class function TConverters.ConvertBytesToHexString
-  (const a_in: THashLibByteArray; a_group: Boolean): String;
+class function TConverters.ConvertBytesToHexString(const AInput
+  : THashLibByteArray; AGroup: Boolean): String;
 var
-  I: Int32;
-  hex, workstring: String;
-  ar: THashLibStringArray;
+  LIdx: Int32;
+  LHexString, LWorkString: String;
+  LTempArray: THashLibStringArray;
 begin
+  LHexString := UpperCase(TBitConverter.ToString(AInput));
 
-  hex := UpperCase(TBitConverter.ToString(a_in));
-
-  if System.length(a_in) = 1 then
+  if System.length(AInput) = 1 then
   begin
-    result := hex;
+    result := LHexString;
     Exit;
   end;
 
-  if System.length(a_in) = 2 then
+  if System.length(AInput) = 2 then
   begin
-    result := StringReplace(hex, '-', '', [rfIgnoreCase, rfReplaceAll]);
+    result := StringReplace(LHexString, '-', '', [rfIgnoreCase, rfReplaceAll]);
     Exit;
   end;
 
-  if (a_group) then
+  if (AGroup) then
   begin
 {$IFDEF DEBUG}
-    Check(a_in, 1, 4);
+    Check(AInput, 1, 4);
 {$ENDIF DEBUG}
-    workstring := UpperCase(TBitConverter.ToString(a_in));
+    LWorkString := UpperCase(TBitConverter.ToString(AInput));
 
-    ar := TConverters.SplitString(workstring, '-');
-    hex := '';
-    I := 0;
+    LTempArray := TConverters.SplitString(LWorkString, '-');
+    LHexString := '';
+    LIdx := 0;
 
-    while I < (System.length(ar) shr 2) do
+    while LIdx < (System.length(LTempArray) shr 2) do
     begin
-      if (I <> 0) then
-        hex := hex + '-';
-      hex := hex + ar[I * 4] + ar[I * 4 + 1] + ar[I * 4 + 2] + ar[I * 4 + 3];
-
-      System.Inc(I);
+      if (LIdx <> 0) then
+      begin
+        LHexString := LHexString + '-';
+      end;
+      LHexString := LHexString + LTempArray[LIdx * 4] + LTempArray[LIdx * 4 + 1]
+        + LTempArray[LIdx * 4 + 2] + LTempArray[LIdx * 4 + 3];
+      System.Inc(LIdx);
     end;
-
   end
   else
   begin
-    hex := StringReplace(hex, '-', '', [rfIgnoreCase, rfReplaceAll]);
+    LHexString := StringReplace(LHexString, '-', '',
+      [rfIgnoreCase, rfReplaceAll]);
   end;
-  result := hex;
+  result := LHexString;
 end;
 
-class function TConverters.ConvertHexStringToBytes(const a_in: String)
+class function TConverters.ConvertHexStringToBytes(const AInput: String)
   : THashLibByteArray;
 var
-  l_in: String;
+  LInput: String;
 begin
-  l_in := a_in;
-  l_in := StringReplace(l_in, '-', '', [rfIgnoreCase, rfReplaceAll]);
+  LInput := AInput;
+  LInput := StringReplace(LInput, '-', '', [rfIgnoreCase, rfReplaceAll]);
 
 {$IFDEF DEBUG}
-  System.Assert(System.length(l_in) and 1 = 0);
+  System.Assert(System.length(LInput) and 1 = 0);
 {$ENDIF DEBUG}
-  System.SetLength(result, System.length(l_in) shr 1);
+  System.SetLength(result, System.length(LInput) shr 1);
 
 {$IFNDEF NEXTGEN}
-  HexToBin(PChar(l_in), @result[0], System.length(result));
+  HexToBin(PChar(LInput), @result[0], System.length(result));
 {$ELSE}
-  HexToBin(PChar(l_in), 0, result, 0, System.length(l_in));
+  HexToBin(PChar(LInput), 0, result, 0, System.length(LInput));
 {$ENDIF !NEXTGEN}
 end;
 
-class function TConverters.ConvertStringToBytes(const a_in: String;
-  const a_encoding: TEncoding): THashLibByteArray;
+class function TConverters.ConvertStringToBytes(const AInput: String;
+  const AEncoding: TEncoding): THashLibByteArray;
 begin
-
-  if a_encoding = Nil then
+  if AEncoding = Nil then
   begin
     raise EArgumentNilHashLibException.CreateRes(@SEncodingInstanceNil);
   end;
 
 {$IFDEF FPC}
-  result := a_encoding.GetBytes(UnicodeString(a_in));
+  result := AEncoding.GetBytes(UnicodeString(AInput));
 {$ELSE}
-  result := a_encoding.GetBytes(a_in);
+  result := AEncoding.GetBytes(AInput);
 {$ENDIF FPC}
 end;
 
-class function TConverters.ConvertBytesToString(const a_in: THashLibByteArray;
-  const a_encoding: TEncoding): String;
+class function TConverters.ConvertBytesToString(const AInput: THashLibByteArray;
+  const AEncoding: TEncoding): String;
 begin
-
-  if a_encoding = Nil then
+  if AEncoding = Nil then
   begin
     raise EArgumentNilHashLibException.CreateRes(@SEncodingInstanceNil);
   end;
 
 {$IFDEF FPC}
-  result := String(a_encoding.GetString(a_in));
+  result := String(AEncoding.GetString(AInput));
 {$ELSE}
-  result := a_encoding.GetString(a_in);
+  result := AEncoding.GetString(AInput);
 {$ENDIF FPC}
 end;
 
-class function TConverters.SplitString(const S: String; Delimiter: Char)
+class function TConverters.SplitString(const AInput: String; ADelimiter: Char)
   : THashLibStringArray;
 var
-  PosStart, PosDel, SplitPoints, I, LowPoint, HighPoint, Len: Int32;
+  LPosStart, LPosSkip, LSplitPoints, LIdx, LLowIndex, LHighIndex,
+    LLength: Int32;
 begin
   result := Nil;
-  if S <> '' then
+  if AInput <> '' then
   begin
     { Determine the length of the resulting array }
-    SplitPoints := 0;
+    LSplitPoints := 0;
 {$IFDEF DELPHIXE3_UP}
-    LowPoint := System.Low(S);
-    HighPoint := System.High(S);
+    LLowIndex := System.Low(AInput);
+    LHighIndex := System.High(AInput);
 {$ELSE}
-    LowPoint := 1;
-    HighPoint := System.length(S);
+    LLowIndex := 1;
+    LHighIndex := System.length(AInput);
 {$ENDIF DELPHIXE3_UP}
-    for I := LowPoint to HighPoint do
+    for LIdx := LLowIndex to LHighIndex do
     begin
-      if (Delimiter = S[I]) then
-        System.Inc(SplitPoints);
+      if (ADelimiter = AInput[LIdx]) then
+      begin
+        System.Inc(LSplitPoints);
+      end;
     end;
 
-    System.SetLength(result, SplitPoints + 1);
+    System.SetLength(result, LSplitPoints + 1);
 
     { Split the string and fill the resulting array }
 
-    I := 0;
-    Len := System.length(Delimiter);
+    LIdx := 0;
+    LLength := System.length(ADelimiter);
 {$IFDEF DELPHIXE3_UP}
-    PosStart := System.Low(S);
-    HighPoint := System.High(S);
+    LPosStart := System.Low(AInput);
+    LHighIndex := System.High(AInput);
 {$ELSE}
-    PosStart := 1;
-    HighPoint := System.length(S);
+    LPosStart := 1;
+    LHighIndex := System.length(AInput);
 {$ENDIF DELPHIXE3_UP}
-    PosDel := System.Pos(Delimiter, S);
-    while PosDel > 0 do
+    LPosSkip := System.Pos(ADelimiter, AInput);
+    while LPosSkip > 0 do
     begin
-      result[I] := System.Copy(S, PosStart, PosDel - PosStart);
-      PosStart := PosDel + Len;
-      PosDel := PosEx(Delimiter, S, PosStart);
-      System.Inc(I);
+      result[LIdx] := System.Copy(AInput, LPosStart, LPosSkip - LPosStart);
+      LPosStart := LPosSkip + LLength;
+      LPosSkip := PosEx(ADelimiter, AInput, LPosStart);
+      System.Inc(LIdx);
     end;
-    result[I] := System.Copy(S, PosStart, HighPoint);
+    result[LIdx] := System.Copy(AInput, LPosStart, LHighIndex);
   end;
 end;
 

+ 12 - 14
src/libraries/hashlib4pascal/HlpDEK.pas

@@ -21,7 +21,7 @@ type
   TDEK = class sealed(TMultipleTransformNonBlock, IHash32, ITransformBlock)
 
   strict protected
-    function ComputeAggregatedBytes(const a_data: THashLibByteArray)
+    function ComputeAggregatedBytes(const AData: THashLibByteArray)
       : IHashResult; override;
   public
     constructor Create();
@@ -40,29 +40,27 @@ end;
 
 function TDEK.Clone(): IHash;
 var
-  HashInstance: TDEK;
+  LHashInstance: TDEK;
 begin
-  HashInstance := TDEK.Create();
+  LHashInstance := TDEK.Create();
   FBuffer.Position := 0;
-  HashInstance.FBuffer.CopyFrom(FBuffer, FBuffer.Size);
-  result := HashInstance as IHash;
+  LHashInstance.FBuffer.CopyFrom(FBuffer, FBuffer.Size);
+  result := LHashInstance as IHash;
   result.BufferSize := BufferSize;
 end;
 
-function TDEK.ComputeAggregatedBytes(const a_data: THashLibByteArray)
+function TDEK.ComputeAggregatedBytes(const AData: THashLibByteArray)
   : IHashResult;
 var
-  hash: UInt32;
-  i: Int32;
+  LHash: UInt32;
+  LIdx: Int32;
 begin
-  hash := UInt32(System.Length(a_data));
-  for i := 0 to System.Length(a_data) - 1 do
+  LHash := UInt32(System.Length(AData));
+  for LIdx := 0 to System.Length(AData) - 1 do
   begin
-
-    hash := TBits.RotateLeft32(hash, 5) xor a_data[i];
+    LHash := TBits.RotateLeft32(LHash, 5) xor AData[LIdx];
   end;
-
-  result := THashResult.Create(hash);
+  result := THashResult.Create(LHash);
 end;
 
 end.

+ 21 - 23
src/libraries/hashlib4pascal/HlpDJB.pas

@@ -15,14 +15,14 @@ uses
 type
   TDJB = class sealed(THash, IHash32, ITransformBlock)
   strict private
-
-    Fm_hash: UInt32;
+  var
+    FHash: UInt32;
 
   public
     constructor Create();
     procedure Initialize(); override;
-    procedure TransformBytes(const a_data: THashLibByteArray;
-      a_index, a_length: Int32); override;
+    procedure TransformBytes(const AData: THashLibByteArray;
+      AIndex, ALength: Int32); override;
     function TransformFinal(): IHashResult; override;
     function Clone(): IHash; override;
   end;
@@ -33,48 +33,46 @@ implementation
 
 function TDJB.Clone(): IHash;
 var
-  HashInstance: TDJB;
+  LHashInstance: TDJB;
 begin
-  HashInstance := TDJB.Create();
-  HashInstance.Fm_hash := Fm_hash;
-  result := HashInstance as IHash;
+  LHashInstance := TDJB.Create();
+  LHashInstance.FHash := FHash;
+  result := LHashInstance as IHash;
   result.BufferSize := BufferSize;
 end;
 
 constructor TDJB.Create;
 begin
   Inherited Create(4, 1);
-
 end;
 
 procedure TDJB.Initialize;
 begin
-  Fm_hash := 5381;
+  FHash := 5381;
 end;
 
-procedure TDJB.TransformBytes(const a_data: THashLibByteArray;
-  a_index, a_length: Int32);
+procedure TDJB.TransformBytes(const AData: THashLibByteArray;
+  AIndex, ALength: Int32);
 var
-  i: Int32;
+  LIdx: Int32;
 begin
 {$IFDEF DEBUG}
-  System.Assert(a_index >= 0);
-  System.Assert(a_length >= 0);
-  System.Assert(a_index + a_length <= System.Length(a_data));
+  System.Assert(AIndex >= 0);
+  System.Assert(ALength >= 0);
+  System.Assert(AIndex + ALength <= System.Length(AData));
 {$ENDIF DEBUG}
-  i := a_index;
-  while a_length > 0 do
+  LIdx := AIndex;
+  while ALength > 0 do
   begin
-    Fm_hash := ((Fm_hash shl 5) + Fm_hash) + a_data[i];
-    System.Inc(i);
-    System.Dec(a_length);
+    FHash := ((FHash shl 5) + FHash) + AData[LIdx];
+    System.Inc(LIdx);
+    System.Dec(ALength);
   end;
-
 end;
 
 function TDJB.TransformFinal: IHashResult;
 begin
-  result := THashResult.Create(Fm_hash);
+  result := THashResult.Create(FHash);
   Initialize();
 end;
 

+ 28 - 27
src/libraries/hashlib4pascal/HlpELF.pas

@@ -15,14 +15,14 @@ uses
 type
   TELF = class sealed(THash, IHash32, ITransformBlock)
   strict private
-
-    Fm_hash: UInt32;
+  var
+    FHash: UInt32;
 
   public
     constructor Create();
     procedure Initialize(); override;
-    procedure TransformBytes(const a_data: THashLibByteArray;
-      a_index, a_length: Int32); override;
+    procedure TransformBytes(const AData: THashLibByteArray;
+      AIndex, ALength: Int32); override;
     function TransformFinal(): IHashResult; override;
     function Clone(): IHash; override;
   end;
@@ -33,11 +33,11 @@ implementation
 
 function TELF.Clone(): IHash;
 var
-  HashInstance: TELF;
+  LHashInstance: TELF;
 begin
-  HashInstance := TELF.Create();
-  HashInstance.Fm_hash := Fm_hash;
-  result := HashInstance as IHash;
+  LHashInstance := TELF.Create();
+  LHashInstance.FHash := FHash;
+  result := LHashInstance as IHash;
   result.BufferSize := BufferSize;
 end;
 
@@ -48,39 +48,40 @@ end;
 
 procedure TELF.Initialize;
 begin
-  Fm_hash := 0;
+  FHash := 0;
 end;
 
-procedure TELF.TransformBytes(const a_data: THashLibByteArray;
-  a_index, a_length: Int32);
+procedure TELF.TransformBytes(const AData: THashLibByteArray;
+  AIndex, ALength: Int32);
 var
-  i: Int32;
-  g: UInt32;
+  LIdx: Int32;
+  LG: UInt32;
 begin
 {$IFDEF DEBUG}
-  System.Assert(a_index >= 0);
-  System.Assert(a_length >= 0);
-  System.Assert(a_index + a_length <= System.Length(a_data));
+  System.Assert(AIndex >= 0);
+  System.Assert(ALength >= 0);
+  System.Assert(AIndex + ALength <= System.Length(AData));
 {$ENDIF DEBUG}
-  i := a_index;
-  while a_length > 0 do
+  LIdx := AIndex;
+  while ALength > 0 do
   begin
-    Fm_hash := (Fm_hash shl 4) + a_data[i];
-    g := Fm_hash and $F0000000;
+    FHash := (FHash shl 4) + AData[LIdx];
+    LG := FHash and $F0000000;
 
-    if (g <> 0) then
-      Fm_hash := Fm_hash xor (g shr 24);
+    if (LG <> 0) then
+    begin
+      FHash := FHash xor (LG shr 24);
+    end;
 
-    Fm_hash := Fm_hash and (not g);
-    System.Inc(i);
-    System.Dec(a_length);
+    FHash := FHash and (not LG);
+    System.Inc(LIdx);
+    System.Dec(ALength);
   end;
-
 end;
 
 function TELF.TransformFinal: IHashResult;
 begin
-  result := THashResult.Create(Fm_hash);
+  result := THashResult.Create(FHash);
   Initialize();
 end;
 

+ 21 - 23
src/libraries/hashlib4pascal/HlpFNV.pas

@@ -15,14 +15,14 @@ uses
 type
   TFNV = class sealed(THash, IHash32, ITransformBlock)
   strict private
-
-    Fm_hash: UInt32;
+  var
+    FHash: UInt32;
 
   public
     constructor Create();
     procedure Initialize(); override;
-    procedure TransformBytes(const a_data: THashLibByteArray;
-      a_index, a_length: Int32); override;
+    procedure TransformBytes(const AData: THashLibByteArray;
+      AIndex, ALength: Int32); override;
     function TransformFinal(): IHashResult; override;
     function Clone(): IHash; override;
   end;
@@ -33,48 +33,46 @@ implementation
 
 function TFNV.Clone(): IHash;
 var
-  HashInstance: TFNV;
+  LHashInstance: TFNV;
 begin
-  HashInstance := TFNV.Create();
-  HashInstance.Fm_hash := Fm_hash;
-  result := HashInstance as IHash;
+  LHashInstance := TFNV.Create();
+  LHashInstance.FHash := FHash;
+  result := LHashInstance as IHash;
   result.BufferSize := BufferSize;
 end;
 
 constructor TFNV.Create;
 begin
   Inherited Create(4, 1);
-
 end;
 
 procedure TFNV.Initialize;
 begin
-  Fm_hash := 0;
+  FHash := 0;
 end;
 
-procedure TFNV.TransformBytes(const a_data: THashLibByteArray;
-  a_index, a_length: Int32);
+procedure TFNV.TransformBytes(const AData: THashLibByteArray;
+  AIndex, ALength: Int32);
 var
-  i: Int32;
+  LIdx: Int32;
 begin
 {$IFDEF DEBUG}
-  System.Assert(a_index >= 0);
-  System.Assert(a_length >= 0);
-  System.Assert(a_index + a_length <= System.Length(a_data));
+  System.Assert(AIndex >= 0);
+  System.Assert(ALength >= 0);
+  System.Assert(AIndex + ALength <= System.Length(AData));
 {$ENDIF DEBUG}
-  i := a_index;
-  while a_length > 0 do
+  LIdx := AIndex;
+  while ALength > 0 do
   begin
-    Fm_hash := (Fm_hash * 16777619) xor a_data[i];
-    System.Inc(i);
-    System.Dec(a_length);
+    FHash := (FHash * 16777619) xor AData[LIdx];
+    System.Inc(LIdx);
+    System.Dec(ALength);
   end;
-
 end;
 
 function TFNV.TransformFinal: IHashResult;
 begin
-  result := THashResult.Create(Fm_hash);
+  result := THashResult.Create(FHash);
   Initialize();
 end;
 

+ 21 - 23
src/libraries/hashlib4pascal/HlpFNV1a.pas

@@ -15,14 +15,14 @@ uses
 type
   TFNV1a = class sealed(THash, IHash32, ITransformBlock)
   strict private
-
-    Fm_hash: UInt32;
+  var
+    FHash: UInt32;
 
   public
     constructor Create();
     procedure Initialize(); override;
-    procedure TransformBytes(const a_data: THashLibByteArray;
-      a_index, a_length: Int32); override;
+    procedure TransformBytes(const AData: THashLibByteArray;
+      AIndex, ALength: Int32); override;
     function TransformFinal(): IHashResult; override;
     function Clone(): IHash; override;
   end;
@@ -33,48 +33,46 @@ implementation
 
 function TFNV1a.Clone(): IHash;
 var
-  HashInstance: TFNV1a;
+  LHashInstance: TFNV1a;
 begin
-  HashInstance := TFNV1a.Create();
-  HashInstance.Fm_hash := Fm_hash;
-  result := HashInstance as IHash;
+  LHashInstance := TFNV1a.Create();
+  LHashInstance.FHash := FHash;
+  result := LHashInstance as IHash;
   result.BufferSize := BufferSize;
 end;
 
 constructor TFNV1a.Create;
 begin
   Inherited Create(4, 1);
-
 end;
 
 procedure TFNV1a.Initialize;
 begin
-  Fm_hash := 2166136261;
+  FHash := 2166136261;
 end;
 
-procedure TFNV1a.TransformBytes(const a_data: THashLibByteArray;
-  a_index, a_length: Int32);
+procedure TFNV1a.TransformBytes(const AData: THashLibByteArray;
+  AIndex, ALength: Int32);
 var
-  i: Int32;
+  LIdx: Int32;
 begin
 {$IFDEF DEBUG}
-  System.Assert(a_index >= 0);
-  System.Assert(a_length >= 0);
-  System.Assert(a_index + a_length <= System.Length(a_data));
+  System.Assert(AIndex >= 0);
+  System.Assert(ALength >= 0);
+  System.Assert(AIndex + ALength <= System.Length(AData));
 {$ENDIF DEBUG}
-  i := a_index;
-  while a_length > 0 do
+  LIdx := AIndex;
+  while ALength > 0 do
   begin
-    Fm_hash := (Fm_hash xor a_data[i]) * 16777619;
-    System.Inc(i);
-    System.Dec(a_length);
+    FHash := (FHash xor AData[LIdx]) * 16777619;
+    System.Inc(LIdx);
+    System.Dec(ALength);
   end;
-
 end;
 
 function TFNV1a.TransformFinal: IHashResult;
 begin
-  result := THashResult.Create(Fm_hash);
+  result := THashResult.Create(FHash);
   Initialize();
 end;
 

+ 21 - 22
src/libraries/hashlib4pascal/HlpFNV1a64.pas

@@ -15,14 +15,14 @@ uses
 type
   TFNV1a64 = class sealed(THash, IHash64, ITransformBlock)
   strict private
-
-    Fm_hash: UInt64;
+  var
+    FHash: UInt64;
 
   public
     constructor Create();
     procedure Initialize(); override;
-    procedure TransformBytes(const a_data: THashLibByteArray;
-      a_index, a_length: Int32); override;
+    procedure TransformBytes(const AData: THashLibByteArray;
+      AIndex, ALength: Int32); override;
     function TransformFinal(): IHashResult; override;
     function Clone(): IHash; override;
   end;
@@ -33,48 +33,47 @@ implementation
 
 function TFNV1a64.Clone(): IHash;
 var
-  HashInstance: TFNV1a64;
+  LHashInstance: TFNV1a64;
 begin
-  HashInstance := TFNV1a64.Create();
-  HashInstance.Fm_hash := Fm_hash;
-  result := HashInstance as IHash;
+  LHashInstance := TFNV1a64.Create();
+  LHashInstance.FHash := FHash;
+  result := LHashInstance as IHash;
   result.BufferSize := BufferSize;
 end;
 
 constructor TFNV1a64.Create;
 begin
   Inherited Create(8, 1);
-
 end;
 
 procedure TFNV1a64.Initialize;
 begin
-  Fm_hash := 14695981039346656037;
+  FHash := 14695981039346656037;
 end;
 
-procedure TFNV1a64.TransformBytes(const a_data: THashLibByteArray;
-  a_index, a_length: Int32);
+procedure TFNV1a64.TransformBytes(const AData: THashLibByteArray;
+  AIndex, ALength: Int32);
 var
-  i: Int32;
+  LIdx: Int32;
 begin
 {$IFDEF DEBUG}
-  System.Assert(a_index >= 0);
-  System.Assert(a_length >= 0);
-  System.Assert(a_index + a_length <= System.Length(a_data));
+  System.Assert(AIndex >= 0);
+  System.Assert(ALength >= 0);
+  System.Assert(AIndex + ALength <= System.Length(AData));
 {$ENDIF DEBUG}
-  i := a_index;
-  while a_length > 0 do
+  LIdx := AIndex;
+  while ALength > 0 do
   begin
-    Fm_hash := (Fm_hash xor a_data[i]) * UInt64(1099511628211);
-    System.Inc(i);
-    System.Dec(a_length);
+    FHash := (FHash xor AData[LIdx]) * UInt64(1099511628211);
+    System.Inc(LIdx);
+    System.Dec(ALength);
   end;
 
 end;
 
 function TFNV1a64.TransformFinal: IHashResult;
 begin
-  result := THashResult.Create(Fm_hash);
+  result := THashResult.Create(FHash);
   Initialize();
 end;
 

+ 21 - 22
src/libraries/hashlib4pascal/HlpFNV64.pas

@@ -15,14 +15,14 @@ uses
 type
   TFNV64 = class sealed(THash, IHash64, ITransformBlock)
   strict private
-
-    Fm_hash: UInt64;
+  var
+    FHash: UInt64;
 
   public
     constructor Create();
     procedure Initialize(); override;
-    procedure TransformBytes(const a_data: THashLibByteArray;
-      a_index, a_length: Int32); override;
+    procedure TransformBytes(const AData: THashLibByteArray;
+      AIndex, ALength: Int32); override;
     function TransformFinal(): IHashResult; override;
     function Clone(): IHash; override;
   end;
@@ -33,48 +33,47 @@ implementation
 
 function TFNV64.Clone(): IHash;
 var
-  HashInstance: TFNV64;
+  LHashInstance: TFNV64;
 begin
-  HashInstance := TFNV64.Create();
-  HashInstance.Fm_hash := Fm_hash;
-  result := HashInstance as IHash;
+  LHashInstance := TFNV64.Create();
+  LHashInstance.FHash := FHash;
+  result := LHashInstance as IHash;
   result.BufferSize := BufferSize;
 end;
 
 constructor TFNV64.Create;
 begin
   Inherited Create(8, 1);
-
 end;
 
 procedure TFNV64.Initialize;
 begin
-  Fm_hash := 0;
+  FHash := 0;
 end;
 
-procedure TFNV64.TransformBytes(const a_data: THashLibByteArray;
-  a_index, a_length: Int32);
+procedure TFNV64.TransformBytes(const AData: THashLibByteArray;
+  AIndex, ALength: Int32);
 var
-  i: Int32;
+  LIdx: Int32;
 begin
 {$IFDEF DEBUG}
-  System.Assert(a_index >= 0);
-  System.Assert(a_length >= 0);
-  System.Assert(a_index + a_length <= System.Length(a_data));
+  System.Assert(AIndex >= 0);
+  System.Assert(ALength >= 0);
+  System.Assert(AIndex + ALength <= System.Length(AData));
 {$ENDIF DEBUG}
-  i := a_index;
-  while a_length > 0 do
+  LIdx := AIndex;
+  while ALength > 0 do
   begin
-    Fm_hash := UInt64(Fm_hash * UInt64(1099511628211)) xor a_data[i];
-    System.Inc(i);
-    System.Dec(a_length);
+    FHash := UInt64(FHash * UInt64(1099511628211)) xor AData[LIdx];
+    System.Inc(LIdx);
+    System.Dec(ALength);
   end;
 
 end;
 
 function TFNV64.TransformFinal: IHashResult;
 begin
-  result := THashResult.Create(Fm_hash);
+  result := THashResult.Create(FHash);
   Initialize();
 end;
 

+ 107 - 106
src/libraries/hashlib4pascal/HlpGOST3411_2012.pas

@@ -22,30 +22,30 @@ type
     FC: THashLibMatrixByteArray;
     FT: THashLibMatrixUInt64Array;
 
-    procedure InternalUpdate(input: Byte); inline;
+    procedure InternalUpdate(AInput: Byte); inline;
     procedure xor512(const A, B: THashLibByteArray); inline;
-    procedure E(const K, a_m: THashLibByteArray);
+    procedure E(const K, M: THashLibByteArray);
     procedure F(const V: THashLibByteArray);
-    procedure g_N(const a_h, a_N, a_m: THashLibByteArray); inline;
-    procedure addMod512(const A: THashLibByteArray; num: Int32); overload;
-    procedure addMod512(const A, B: THashLibByteArray); overload;
-    procedure reverse(const src, dst: THashLibByteArray);
+    procedure GN(const AH, AN, AM: THashLibByteArray); inline;
+    procedure AddMod512(const A: THashLibByteArray; Num: Int32); overload;
+    procedure AddMod512(const A, B: THashLibByteArray); overload;
+    procedure Reverse(const ASource, ADestination: THashLibByteArray);
 
     class constructor GOST3411_2012();
 
   strict protected
 
   var
-    FIV, FN, FSigma, FKi, Fm, Fh, Ftmp, Fblock: THashLibByteArray;
+    FIV, FN, FSigma, FKi, FM, FH, FTemp, FBlock: THashLibByteArray;
 
-    FbOff: Int32;
+    FBOff: Int32;
 
-    constructor Create(a_hash_size: Int32; const IV: THashLibByteArray);
+    constructor Create(AHashSize: Int32; const IV: THashLibByteArray);
 
   public
     procedure Initialize; override;
-    procedure TransformBytes(const a_data: THashLibByteArray;
-      a_index, a_data_length: Int32); override;
+    procedure TransformBytes(const AData: THashLibByteArray;
+      AIndex, ADataLength: Int32); override;
     function TransformFinal: IHashResult; override;
 
   end;
@@ -93,14 +93,14 @@ begin
   end;
 end;
 
-procedure TGOST3411_2012.addMod512(const A: THashLibByteArray; num: Int32);
+procedure TGOST3411_2012.AddMod512(const A: THashLibByteArray; Num: Int32);
 var
   c, i: Int32;
 begin
-  c := (A[63] and $FF) + (num and $FF);
+  c := (A[63] and $FF) + (Num and $FF);
   A[63] := Byte(c);
 
-  c := (A[62] and $FF) + ((TBits.Asr32(num, 8)) and $FF) + (TBits.Asr32(c, 8));
+  c := (A[62] and $FF) + ((TBits.Asr32(Num, 8)) and $FF) + (TBits.Asr32(c, 8));
   A[62] := Byte(c);
 
   i := 61;
@@ -114,7 +114,7 @@ begin
 
 end;
 
-procedure TGOST3411_2012.addMod512(const A, B: THashLibByteArray);
+procedure TGOST3411_2012.AddMod512(const A, B: THashLibByteArray);
 var
   i, c: Int32;
 begin
@@ -129,33 +129,33 @@ begin
   end;
 end;
 
-constructor TGOST3411_2012.Create(a_hash_size: Int32;
+constructor TGOST3411_2012.Create(AHashSize: Int32;
   const IV: THashLibByteArray);
 begin
-  Inherited Create(a_hash_size, 64);
+  Inherited Create(AHashSize, 64);
   System.SetLength(FIV, 64);
   System.SetLength(FN, 64);
   System.SetLength(FSigma, 64);
   System.SetLength(FKi, 64);
-  System.SetLength(Fm, 64);
-  System.SetLength(Fh, 64);
+  System.SetLength(FM, 64);
+  System.SetLength(FH, 64);
 
   // Temporary buffers
-  System.SetLength(Ftmp, 64);
-  System.SetLength(Fblock, 64);
+  System.SetLength(FTemp, 64);
+  System.SetLength(FBlock, 64);
 
-  FbOff := 64;
+  FBOff := 64;
 
   System.Move(IV[0], FIV[0], 64 * System.SizeOf(Byte));
-  System.Move(IV[0], Fh[0], 64 * System.SizeOf(Byte));
+  System.Move(IV[0], FH[0], 64 * System.SizeOf(Byte));
 end;
 
-procedure TGOST3411_2012.E(const K, a_m: THashLibByteArray);
+procedure TGOST3411_2012.E(const K, M: THashLibByteArray);
 var
   i: Int32;
 begin
   System.Move(K[0], FKi[0], 64 * System.SizeOf(Byte));
-  xor512(K, a_m);
+  xor512(K, M);
   F(K);
   for i := 0 to System.Pred(11) do
   begin
@@ -1515,78 +1515,79 @@ begin
 {$ENDREGION}
 end;
 
-procedure TGOST3411_2012.g_N(const a_h, a_N, a_m: THashLibByteArray);
+procedure TGOST3411_2012.GN(const AH, AN, AM: THashLibByteArray);
 begin
-  System.Move(a_h[0], Ftmp[0], 64 * System.SizeOf(Byte));
+  System.Move(AH[0], FTemp[0], 64 * System.SizeOf(Byte));
 
-  xor512(a_h, a_N);
-  F(a_h);
+  xor512(AH, AN);
+  F(AH);
 
-  E(a_h, a_m);
-  xor512(a_h, Ftmp);
-  xor512(a_h, a_m);
+  E(AH, AM);
+  xor512(AH, FTemp);
+  xor512(AH, AM);
 end;
 
 procedure TGOST3411_2012.Initialize;
 begin
-  FbOff := 64;
+  FBOff := 64;
   TArrayUtils.ZeroFill(FN);
   TArrayUtils.ZeroFill(FSigma);
 
-  System.Move(FIV[0], Fh[0], 64 * System.SizeOf(Byte));
+  System.Move(FIV[0], FH[0], 64 * System.SizeOf(Byte));
 
-  TArrayUtils.ZeroFill(Fblock);
+  TArrayUtils.ZeroFill(FBlock);
 end;
 
-procedure TGOST3411_2012.InternalUpdate(input: Byte);
+procedure TGOST3411_2012.InternalUpdate(AInput: Byte);
 begin
-  System.Dec(FbOff);
-  Fblock[FbOff] := input;
-  if (FbOff = 0) then
+  System.Dec(FBOff);
+  FBlock[FBOff] := AInput;
+  if (FBOff = 0) then
   begin
-    g_N(Fh, FN, Fblock);
-    addMod512(FN, 512);
-    addMod512(FSigma, Fblock);
-    FbOff := 64;
+    GN(FH, FN, FBlock);
+    AddMod512(FN, 512);
+    AddMod512(FSigma, FBlock);
+    FBOff := 64;
   end;
 end;
 
-procedure TGOST3411_2012.reverse(const src, dst: THashLibByteArray);
+procedure TGOST3411_2012.Reverse(const ASource, ADestination
+  : THashLibByteArray);
 var
   len, i: Int32;
 begin
-  len := System.Length(src);
+  len := System.Length(ASource);
   for i := 0 to System.Pred(len) do
   begin
-    dst[len - 1 - i] := src[i];
+    ADestination[len - 1 - i] := ASource[i];
   end;
 end;
 
-procedure TGOST3411_2012.TransformBytes(const a_data: THashLibByteArray;
-  a_index, a_data_length: Int32);
+procedure TGOST3411_2012.TransformBytes(const AData: THashLibByteArray;
+  AIndex, ADataLength: Int32);
 begin
-  while ((FbOff <> 64) and (a_data_length > 0)) do
+  while ((FBOff <> 64) and (ADataLength > 0)) do
   begin
-    InternalUpdate(a_data[a_index]);
-    System.Inc(a_index);
-    System.Dec(a_data_length);
+    InternalUpdate(AData[AIndex]);
+    System.Inc(AIndex);
+    System.Dec(ADataLength);
   end;
-  while (a_data_length >= 64) do
+  while (ADataLength >= 64) do
   begin
-    System.Move(a_data[a_index], Ftmp[0], 64 * System.SizeOf(Byte));
-    reverse(Ftmp, Fblock);
-    g_N(Fh, FN, Fblock);
-    addMod512(FN, 512);
-    addMod512(FSigma, Fblock);
-
-    a_data_length := a_data_length - 64;
-    a_index := a_index + 64;
+    System.Move(AData[AIndex], FTemp[0], 64 * System.SizeOf(Byte));
+    Reverse(FTemp, FBlock);
+    GN(FH, FN, FBlock);
+    AddMod512(FN, 512);
+    AddMod512(FSigma, FBlock);
+
+    ADataLength := ADataLength - 64;
+    AIndex := AIndex + 64;
   end;
-  while (a_data_length > 0) do
+  while (ADataLength > 0) do
   begin
-    InternalUpdate(a_data[a_index]);
-    System.Inc(a_index);
-    System.Dec(a_data_length);
+    InternalUpdate(AData[AIndex]);
+    System.Inc(AIndex);
+    System.Dec(ADataLength);
   end;
 
 end;
@@ -1596,33 +1597,33 @@ var
   tempRes: THashLibByteArray;
   lenM, i: Int32;
 begin
-  lenM := 64 - FbOff;
+  lenM := 64 - FBOff;
 
   // At this point it is certain that lenM is smaller than 64
   i := 0;
   while i <> (64 - lenM) do
   begin
-    Fm[i] := 0;
+    FM[i] := 0;
     System.Inc(i);
   end;
 
-  Fm[63 - lenM] := 1;
+  FM[63 - lenM] := 1;
 
-  if (FbOff <> 64) then
+  if (FBOff <> 64) then
   begin
-    System.Move(Fblock[FbOff], Fm[64 - lenM], lenM * System.SizeOf(Byte));
+    System.Move(FBlock[FBOff], FM[64 - lenM], lenM * System.SizeOf(Byte));
   end;
 
-  g_N(Fh, FN, Fm);
-  addMod512(FN, lenM * 8);
-  addMod512(FSigma, Fm);
-  g_N(Fh, FZero, FN);
-  g_N(Fh, FZero, FSigma);
+  GN(FH, FN, FM);
+  AddMod512(FN, lenM * 8);
+  AddMod512(FSigma, FM);
+  GN(FH, FZero, FN);
+  GN(FH, FZero, FSigma);
 
-  reverse(Fh, Ftmp);
+  Reverse(FH, FTemp);
 
   System.SetLength(tempRes, 64);
-  System.Move(Ftmp[0], tempRes[0], 64 * System.SizeOf(Byte));
+  System.Move(FTemp[0], tempRes[0], 64 * System.SizeOf(Byte));
 
   result := THashResult.Create(tempRes);
 
@@ -1633,19 +1634,19 @@ end;
 
 function TGOST3411_2012_256.Clone(): IHash;
 var
-  HashInstance: TGOST3411_2012_256;
+  LHashInstance: TGOST3411_2012_256;
 begin
-  HashInstance := TGOST3411_2012_256.Create();
-  HashInstance.FIV := System.Copy(FIV);
-  HashInstance.FN := System.Copy(FN);
-  HashInstance.FSigma := System.Copy(FSigma);
-  HashInstance.FKi := System.Copy(FKi);
-  HashInstance.Fm := System.Copy(Fm);
-  HashInstance.Fh := System.Copy(Fh);
-  HashInstance.Ftmp := System.Copy(Ftmp);
-  HashInstance.Fblock := System.Copy(Fblock);
-  HashInstance.FbOff := FbOff;
-  result := HashInstance as IHash;
+  LHashInstance := TGOST3411_2012_256.Create();
+  LHashInstance.FIV := System.Copy(FIV);
+  LHashInstance.FN := System.Copy(FN);
+  LHashInstance.FSigma := System.Copy(FSigma);
+  LHashInstance.FKi := System.Copy(FKi);
+  LHashInstance.FM := System.Copy(FM);
+  LHashInstance.FH := System.Copy(FH);
+  LHashInstance.FTemp := System.Copy(FTemp);
+  LHashInstance.FBlock := System.Copy(FBlock);
+  LHashInstance.FBOff := FBOff;
+  result := LHashInstance as IHash;
   result.BufferSize := BufferSize;
 end;
 
@@ -1665,31 +1666,31 @@ end;
 
 function TGOST3411_2012_256.TransformFinal: IHashResult;
 var
-  output, tempRes: THashLibByteArray;
+  LOutput, LTempRes: THashLibByteArray;
 begin
-  output := inherited TransformFinal.GetBytes;
-  System.SetLength(tempRes, HashSize);
-  System.Move(output[32], tempRes[0], 32 * System.SizeOf(Byte));
-  result := THashResult.Create(tempRes);
+  LOutput := inherited TransformFinal().GetBytes;
+  System.SetLength(LTempRes, HashSize);
+  System.Move(LOutput[32], LTempRes[0], 32 * System.SizeOf(Byte));
+  result := THashResult.Create(LTempRes);
 end;
 
 { TGOST3411_2012_512 }
 
 function TGOST3411_2012_512.Clone(): IHash;
 var
-  HashInstance: TGOST3411_2012_512;
+  LHashInstance: TGOST3411_2012_512;
 begin
-  HashInstance := TGOST3411_2012_512.Create();
-  HashInstance.FIV := System.Copy(FIV);
-  HashInstance.FN := System.Copy(FN);
-  HashInstance.FSigma := System.Copy(FSigma);
-  HashInstance.FKi := System.Copy(FKi);
-  HashInstance.Fm := System.Copy(Fm);
-  HashInstance.Fh := System.Copy(Fh);
-  HashInstance.Ftmp := System.Copy(Ftmp);
-  HashInstance.Fblock := System.Copy(Fblock);
-  HashInstance.FbOff := FbOff;
-  result := HashInstance as IHash;
+  LHashInstance := TGOST3411_2012_512.Create();
+  LHashInstance.FIV := System.Copy(FIV);
+  LHashInstance.FN := System.Copy(FN);
+  LHashInstance.FSigma := System.Copy(FSigma);
+  LHashInstance.FKi := System.Copy(FKi);
+  LHashInstance.FM := System.Copy(FM);
+  LHashInstance.FH := System.Copy(FH);
+  LHashInstance.FTemp := System.Copy(FTemp);
+  LHashInstance.FBlock := System.Copy(FBlock);
+  LHashInstance.FBOff := FBOff;
+  result := LHashInstance as IHash;
   result.BufferSize := BufferSize;
 end;
 

+ 189 - 198
src/libraries/hashlib4pascal/HlpGost.pas

@@ -24,20 +24,21 @@ type
 
   strict private
 
-    Fm_state, Fm_hash: THashLibUInt32Array;
-
     class var
 
-      Fs_sbox1, Fs_sbox2, Fs_sbox3, Fs_sbox4: THashLibUInt32Array;
+      FSBox1, FSBox2, FSBox3, FSBox4: THashLibUInt32Array;
+
+  var
+    FState, FHash: THashLibUInt32Array;
 
-    procedure Compress(a_m: PCardinal);
+    procedure Compress(APtr: PCardinal);
     class constructor Gost();
 
   strict protected
     procedure Finish(); override;
     function GetResult(): THashLibByteArray; override;
-    procedure TransformBlock(a_data: PByte; a_data_length: Int32;
-      a_index: Int32); override;
+    procedure TransformBlock(AData: PByte; ADataLength: Int32;
+      AIndex: Int32); override;
 
   public
     constructor Create();
@@ -52,18 +53,18 @@ implementation
 
 function TGost.Clone(): IHash;
 var
-  HashInstance: TGost;
+  LHashInstance: TGost;
 begin
-  HashInstance := TGost.Create();
-  HashInstance.Fm_state := System.Copy(Fm_state);
-  HashInstance.Fm_hash := System.Copy(Fm_hash);
-  HashInstance.Fm_buffer := Fm_buffer.Clone();
-  HashInstance.Fm_processed_bytes := Fm_processed_bytes;
-  result := HashInstance as IHash;
+  LHashInstance := TGost.Create();
+  LHashInstance.FState := System.Copy(FState);
+  LHashInstance.FHash := System.Copy(FHash);
+  LHashInstance.FBuffer := FBuffer.Clone();
+  LHashInstance.FProcessedBytesCount := FProcessedBytesCount;
+  result := LHashInstance as IHash;
   result.BufferSize := BufferSize;
 end;
 
-procedure TGost.Compress(a_m: PCardinal);
+procedure TGost.Compress(APtr: PCardinal);
 var
   u0, u1, u2, u3, u4, u5, u6, u7, v0, v1, v2, v3, v4, v5, v6, v7, w0, w1, w2,
     w3, w4, w5, w6, w7, key0, key1, key2, key3, key4, key5, key6, key7, r, l,
@@ -71,28 +72,27 @@ var
   i: Int32;
   s: array [0 .. 7] of UInt32;
 begin
-  u0 := Fm_hash[0];
-  u1 := Fm_hash[1];
-  u2 := Fm_hash[2];
-  u3 := Fm_hash[3];
-  u4 := Fm_hash[4];
-  u5 := Fm_hash[5];
-  u6 := Fm_hash[6];
-  u7 := Fm_hash[7];
-
-  v0 := a_m[0];
-  v1 := a_m[1];
-  v2 := a_m[2];
-  v3 := a_m[3];
-  v4 := a_m[4];
-  v5 := a_m[5];
-  v6 := a_m[6];
-  v7 := a_m[7];
+  u0 := FHash[0];
+  u1 := FHash[1];
+  u2 := FHash[2];
+  u3 := FHash[3];
+  u4 := FHash[4];
+  u5 := FHash[5];
+  u6 := FHash[6];
+  u7 := FHash[7];
+
+  v0 := APtr[0];
+  v1 := APtr[1];
+  v2 := APtr[2];
+  v3 := APtr[3];
+  v4 := APtr[4];
+  v5 := APtr[5];
+  v6 := APtr[6];
+  v7 := APtr[7];
 
   i := 0;
 
   while i < 8 do
-
   begin
     w0 := u0 xor v0;
     w1 := u1 xor v1;
@@ -120,105 +120,105 @@ begin
     key7 := (w1 shr 24) or ((w3 and $FF000000) shr 16) or
       ((w5 and $FF000000) shr 8) or (w7 and $FF000000);
 
-    r := Fm_hash[i];
-    l := Fm_hash[i + 1];
+    r := FHash[i];
+    l := FHash[i + 1];
 
     t := key0 + r;
-    l := l xor (Fs_sbox1[Byte(t)] xor Fs_sbox2[Byte(t shr 8)] xor Fs_sbox3
-      [Byte(t shr 16)] xor Fs_sbox4[t shr 24]);
+    l := l xor (FSBox1[Byte(t)] xor FSBox2[Byte(t shr 8)] xor FSBox3
+      [Byte(t shr 16)] xor FSBox4[t shr 24]);
     t := key1 + l;
-    r := r xor (Fs_sbox1[Byte(t)] xor Fs_sbox2[Byte(t shr 8)] xor Fs_sbox3
-      [Byte(t shr 16)] xor Fs_sbox4[t shr 24]);
+    r := r xor (FSBox1[Byte(t)] xor FSBox2[Byte(t shr 8)] xor FSBox3
+      [Byte(t shr 16)] xor FSBox4[t shr 24]);
     t := key2 + r;
-    l := l xor (Fs_sbox1[Byte(t)] xor Fs_sbox2[Byte(t shr 8)] xor Fs_sbox3
-      [Byte(t shr 16)] xor Fs_sbox4[t shr 24]);
+    l := l xor (FSBox1[Byte(t)] xor FSBox2[Byte(t shr 8)] xor FSBox3
+      [Byte(t shr 16)] xor FSBox4[t shr 24]);
     t := key3 + l;
-    r := r xor (Fs_sbox1[Byte(t)] xor Fs_sbox2[Byte(t shr 8)] xor Fs_sbox3
-      [Byte(t shr 16)] xor Fs_sbox4[t shr 24]);
+    r := r xor (FSBox1[Byte(t)] xor FSBox2[Byte(t shr 8)] xor FSBox3
+      [Byte(t shr 16)] xor FSBox4[t shr 24]);
     t := key4 + r;
-    l := l xor (Fs_sbox1[Byte(t)] xor Fs_sbox2[Byte(t shr 8)] xor Fs_sbox3
-      [Byte(t shr 16)] xor Fs_sbox4[t shr 24]);
+    l := l xor (FSBox1[Byte(t)] xor FSBox2[Byte(t shr 8)] xor FSBox3
+      [Byte(t shr 16)] xor FSBox4[t shr 24]);
     t := key5 + l;
-    r := r xor (Fs_sbox1[Byte(t)] xor Fs_sbox2[Byte(t shr 8)] xor Fs_sbox3
-      [Byte(t shr 16)] xor Fs_sbox4[t shr 24]);
+    r := r xor (FSBox1[Byte(t)] xor FSBox2[Byte(t shr 8)] xor FSBox3
+      [Byte(t shr 16)] xor FSBox4[t shr 24]);
     t := key6 + r;
-    l := l xor (Fs_sbox1[Byte(t)] xor Fs_sbox2[Byte(t shr 8)] xor Fs_sbox3
-      [Byte(t shr 16)] xor Fs_sbox4[t shr 24]);
+    l := l xor (FSBox1[Byte(t)] xor FSBox2[Byte(t shr 8)] xor FSBox3
+      [Byte(t shr 16)] xor FSBox4[t shr 24]);
     t := key7 + l;
-    r := r xor (Fs_sbox1[Byte(t)] xor Fs_sbox2[Byte(t shr 8)] xor Fs_sbox3
-      [Byte(t shr 16)] xor Fs_sbox4[t shr 24]);
+    r := r xor (FSBox1[Byte(t)] xor FSBox2[Byte(t shr 8)] xor FSBox3
+      [Byte(t shr 16)] xor FSBox4[t shr 24]);
     t := key0 + r;
-    l := l xor (Fs_sbox1[Byte(t)] xor Fs_sbox2[Byte(t shr 8)] xor Fs_sbox3
-      [Byte(t shr 16)] xor Fs_sbox4[t shr 24]);
+    l := l xor (FSBox1[Byte(t)] xor FSBox2[Byte(t shr 8)] xor FSBox3
+      [Byte(t shr 16)] xor FSBox4[t shr 24]);
     t := key1 + l;
-    r := r xor (Fs_sbox1[Byte(t)] xor Fs_sbox2[Byte(t shr 8)] xor Fs_sbox3
-      [Byte(t shr 16)] xor Fs_sbox4[t shr 24]);
+    r := r xor (FSBox1[Byte(t)] xor FSBox2[Byte(t shr 8)] xor FSBox3
+      [Byte(t shr 16)] xor FSBox4[t shr 24]);
     t := key2 + r;
-    l := l xor (Fs_sbox1[Byte(t)] xor Fs_sbox2[Byte(t shr 8)] xor Fs_sbox3
-      [Byte(t shr 16)] xor Fs_sbox4[t shr 24]);
+    l := l xor (FSBox1[Byte(t)] xor FSBox2[Byte(t shr 8)] xor FSBox3
+      [Byte(t shr 16)] xor FSBox4[t shr 24]);
     t := key3 + l;
-    r := r xor (Fs_sbox1[Byte(t)] xor Fs_sbox2[Byte(t shr 8)] xor Fs_sbox3
-      [Byte(t shr 16)] xor Fs_sbox4[t shr 24]);
+    r := r xor (FSBox1[Byte(t)] xor FSBox2[Byte(t shr 8)] xor FSBox3
+      [Byte(t shr 16)] xor FSBox4[t shr 24]);
     t := key4 + r;
-    l := l xor (Fs_sbox1[Byte(t)] xor Fs_sbox2[Byte(t shr 8)] xor Fs_sbox3
-      [Byte(t shr 16)] xor Fs_sbox4[t shr 24]);
+    l := l xor (FSBox1[Byte(t)] xor FSBox2[Byte(t shr 8)] xor FSBox3
+      [Byte(t shr 16)] xor FSBox4[t shr 24]);
     t := key5 + l;
-    r := r xor (Fs_sbox1[Byte(t)] xor Fs_sbox2[Byte(t shr 8)] xor Fs_sbox3
-      [Byte(t shr 16)] xor Fs_sbox4[t shr 24]);
+    r := r xor (FSBox1[Byte(t)] xor FSBox2[Byte(t shr 8)] xor FSBox3
+      [Byte(t shr 16)] xor FSBox4[t shr 24]);
     t := key6 + r;
-    l := l xor (Fs_sbox1[Byte(t)] xor Fs_sbox2[Byte(t shr 8)] xor Fs_sbox3
-      [Byte(t shr 16)] xor Fs_sbox4[t shr 24]);
+    l := l xor (FSBox1[Byte(t)] xor FSBox2[Byte(t shr 8)] xor FSBox3
+      [Byte(t shr 16)] xor FSBox4[t shr 24]);
     t := key7 + l;
-    r := r xor (Fs_sbox1[Byte(t)] xor Fs_sbox2[Byte(t shr 8)] xor Fs_sbox3
-      [Byte(t shr 16)] xor Fs_sbox4[t shr 24]);
+    r := r xor (FSBox1[Byte(t)] xor FSBox2[Byte(t shr 8)] xor FSBox3
+      [Byte(t shr 16)] xor FSBox4[t shr 24]);
     t := key0 + r;
-    l := l xor (Fs_sbox1[Byte(t)] xor Fs_sbox2[Byte(t shr 8)] xor Fs_sbox3
-      [Byte(t shr 16)] xor Fs_sbox4[t shr 24]);
+    l := l xor (FSBox1[Byte(t)] xor FSBox2[Byte(t shr 8)] xor FSBox3
+      [Byte(t shr 16)] xor FSBox4[t shr 24]);
     t := key1 + l;
-    r := r xor (Fs_sbox1[Byte(t)] xor Fs_sbox2[Byte(t shr 8)] xor Fs_sbox3
-      [Byte(t shr 16)] xor Fs_sbox4[t shr 24]);
+    r := r xor (FSBox1[Byte(t)] xor FSBox2[Byte(t shr 8)] xor FSBox3
+      [Byte(t shr 16)] xor FSBox4[t shr 24]);
     t := key2 + r;
-    l := l xor (Fs_sbox1[Byte(t)] xor Fs_sbox2[Byte(t shr 8)] xor Fs_sbox3
-      [Byte(t shr 16)] xor Fs_sbox4[t shr 24]);
+    l := l xor (FSBox1[Byte(t)] xor FSBox2[Byte(t shr 8)] xor FSBox3
+      [Byte(t shr 16)] xor FSBox4[t shr 24]);
     t := key3 + l;
-    r := r xor (Fs_sbox1[Byte(t)] xor Fs_sbox2[Byte(t shr 8)] xor Fs_sbox3
-      [Byte(t shr 16)] xor Fs_sbox4[t shr 24]);
+    r := r xor (FSBox1[Byte(t)] xor FSBox2[Byte(t shr 8)] xor FSBox3
+      [Byte(t shr 16)] xor FSBox4[t shr 24]);
     t := key4 + r;
-    l := l xor (Fs_sbox1[Byte(t)] xor Fs_sbox2[Byte(t shr 8)] xor Fs_sbox3
-      [Byte(t shr 16)] xor Fs_sbox4[t shr 24]);
+    l := l xor (FSBox1[Byte(t)] xor FSBox2[Byte(t shr 8)] xor FSBox3
+      [Byte(t shr 16)] xor FSBox4[t shr 24]);
     t := key5 + l;
-    r := r xor (Fs_sbox1[Byte(t)] xor Fs_sbox2[Byte(t shr 8)] xor Fs_sbox3
-      [Byte(t shr 16)] xor Fs_sbox4[t shr 24]);
+    r := r xor (FSBox1[Byte(t)] xor FSBox2[Byte(t shr 8)] xor FSBox3
+      [Byte(t shr 16)] xor FSBox4[t shr 24]);
     t := key6 + r;
-    l := l xor (Fs_sbox1[Byte(t)] xor Fs_sbox2[Byte(t shr 8)] xor Fs_sbox3
-      [Byte(t shr 16)] xor Fs_sbox4[t shr 24]);
+    l := l xor (FSBox1[Byte(t)] xor FSBox2[Byte(t shr 8)] xor FSBox3
+      [Byte(t shr 16)] xor FSBox4[t shr 24]);
     t := key7 + l;
-    r := r xor (Fs_sbox1[Byte(t)] xor Fs_sbox2[Byte(t shr 8)] xor Fs_sbox3
-      [Byte(t shr 16)] xor Fs_sbox4[t shr 24]);
+    r := r xor (FSBox1[Byte(t)] xor FSBox2[Byte(t shr 8)] xor FSBox3
+      [Byte(t shr 16)] xor FSBox4[t shr 24]);
     t := key7 + r;
-    l := l xor (Fs_sbox1[Byte(t)] xor Fs_sbox2[Byte(t shr 8)] xor Fs_sbox3
-      [Byte(t shr 16)] xor Fs_sbox4[t shr 24]);
+    l := l xor (FSBox1[Byte(t)] xor FSBox2[Byte(t shr 8)] xor FSBox3
+      [Byte(t shr 16)] xor FSBox4[t shr 24]);
     t := key6 + l;
-    r := r xor (Fs_sbox1[Byte(t)] xor Fs_sbox2[Byte(t shr 8)] xor Fs_sbox3
-      [Byte(t shr 16)] xor Fs_sbox4[t shr 24]);
+    r := r xor (FSBox1[Byte(t)] xor FSBox2[Byte(t shr 8)] xor FSBox3
+      [Byte(t shr 16)] xor FSBox4[t shr 24]);
     t := key5 + r;
-    l := l xor (Fs_sbox1[Byte(t)] xor Fs_sbox2[Byte(t shr 8)] xor Fs_sbox3
-      [Byte(t shr 16)] xor Fs_sbox4[t shr 24]);
+    l := l xor (FSBox1[Byte(t)] xor FSBox2[Byte(t shr 8)] xor FSBox3
+      [Byte(t shr 16)] xor FSBox4[t shr 24]);
     t := key4 + l;
-    r := r xor (Fs_sbox1[Byte(t)] xor Fs_sbox2[Byte(t shr 8)] xor Fs_sbox3
-      [Byte(t shr 16)] xor Fs_sbox4[t shr 24]);
+    r := r xor (FSBox1[Byte(t)] xor FSBox2[Byte(t shr 8)] xor FSBox3
+      [Byte(t shr 16)] xor FSBox4[t shr 24]);
     t := key3 + r;
-    l := l xor (Fs_sbox1[Byte(t)] xor Fs_sbox2[Byte(t shr 8)] xor Fs_sbox3
-      [Byte(t shr 16)] xor Fs_sbox4[t shr 24]);
+    l := l xor (FSBox1[Byte(t)] xor FSBox2[Byte(t shr 8)] xor FSBox3
+      [Byte(t shr 16)] xor FSBox4[t shr 24]);
     t := key2 + l;
-    r := r xor (Fs_sbox1[Byte(t)] xor Fs_sbox2[Byte(t shr 8)] xor Fs_sbox3
-      [Byte(t shr 16)] xor Fs_sbox4[t shr 24]);
+    r := r xor (FSBox1[Byte(t)] xor FSBox2[Byte(t shr 8)] xor FSBox3
+      [Byte(t shr 16)] xor FSBox4[t shr 24]);
     t := key1 + r;
-    l := l xor (Fs_sbox1[Byte(t)] xor Fs_sbox2[Byte(t shr 8)] xor Fs_sbox3
-      [Byte(t shr 16)] xor Fs_sbox4[t shr 24]);
+    l := l xor (FSBox1[Byte(t)] xor FSBox2[Byte(t shr 8)] xor FSBox3
+      [Byte(t shr 16)] xor FSBox4[t shr 24]);
     t := key0 + l;
-    r := r xor (Fs_sbox1[Byte(t)] xor Fs_sbox2[Byte(t shr 8)] xor Fs_sbox3
-      [Byte(t shr 16)] xor Fs_sbox4[t shr 24]);
+    r := r xor (FSBox1[Byte(t)] xor FSBox2[Byte(t shr 8)] xor FSBox3
+      [Byte(t shr 16)] xor FSBox4[t shr 24]);
 
     t := r;
     r := l;
@@ -269,125 +269,121 @@ begin
     System.Inc(i, 2);
   end;
 
-  u0 := a_m[0] xor s[6];
-  u1 := a_m[1] xor s[7];
-  u2 := a_m[2] xor (s[0] shl 16) xor (s[0] shr 16) xor (s[0] and $FFFF)
+  u0 := APtr[0] xor s[6];
+  u1 := APtr[1] xor s[7];
+  u2 := APtr[2] xor (s[0] shl 16) xor (s[0] shr 16) xor (s[0] and $FFFF)
     xor (s[1] and $FFFF) xor (s[1] shr 16) xor (s[2] shl 16)
     xor s[6] xor (s[6] shl 16) xor (s[7] and $FFFF0000) xor (s[7] shr 16);
-  u3 := a_m[3] xor (s[0] and $FFFF) xor (s[0] shl 16) xor (s[1] and $FFFF)
+  u3 := APtr[3] xor (s[0] and $FFFF) xor (s[0] shl 16) xor (s[1] and $FFFF)
     xor (s[1] shl 16) xor (s[1] shr 16) xor (s[2] shl 16) xor (s[2] shr 16)
     xor (s[3] shl 16) xor s[6] xor (s[6] shl 16) xor (s[6] shr 16)
     xor (s[7] and $FFFF) xor (s[7] shl 16) xor (s[7] shr 16);
-  u4 := a_m[4] xor (s[0] and $FFFF0000) xor (s[0] shl 16) xor (s[0] shr 16)
+  u4 := APtr[4] xor (s[0] and $FFFF0000) xor (s[0] shl 16) xor (s[0] shr 16)
     xor (s[1] and $FFFF0000) xor (s[1] shr 16) xor (s[2] shl 16)
     xor (s[2] shr 16) xor (s[3] shl 16) xor (s[3] shr 16) xor (s[4] shl 16)
     xor (s[6] shl 16) xor (s[6] shr 16) xor (s[7] and $FFFF) xor (s[7] shl 16)
     xor (s[7] shr 16);
-  u5 := a_m[5] xor (s[0] shl 16) xor (s[0] shr 16) xor (s[0] and $FFFF0000)
+  u5 := APtr[5] xor (s[0] shl 16) xor (s[0] shr 16) xor (s[0] and $FFFF0000)
     xor (s[1] and $FFFF) xor s[2] xor (s[2] shr 16) xor (s[3] shl 16)
     xor (s[3] shr 16) xor (s[4] shl 16) xor (s[4] shr 16) xor (s[5] shl 16)
     xor (s[6] shl 16) xor (s[6] shr 16) xor (s[7] and $FFFF0000)
     xor (s[7] shl 16) xor (s[7] shr 16);
-  u6 := a_m[6] xor s[0] xor (s[1] shr 16) xor (s[2] shl 16)
+  u6 := APtr[6] xor s[0] xor (s[1] shr 16) xor (s[2] shl 16)
     xor s[3] xor (s[3] shr 16) xor (s[4] shl 16) xor (s[4] shr 16)
     xor (s[5] shl 16) xor (s[5] shr 16) xor s[6] xor (s[6] shl 16)
     xor (s[6] shr 16) xor (s[7] shl 16);
-  u7 := a_m[7] xor (s[0] and $FFFF0000) xor (s[0] shl 16) xor (s[1] and $FFFF)
+  u7 := APtr[7] xor (s[0] and $FFFF0000) xor (s[0] shl 16) xor (s[1] and $FFFF)
     xor (s[1] shl 16) xor (s[2] shr 16) xor (s[3] shl 16)
     xor s[4] xor (s[4] shr 16) xor (s[5] shl 16) xor (s[5] shr 16)
     xor (s[6] shr 16) xor (s[7] and $FFFF) xor (s[7] shl 16) xor (s[7] shr 16);
 
-  v0 := Fm_hash[0] xor (u1 shl 16) xor (u0 shr 16);
-  v1 := Fm_hash[1] xor (u2 shl 16) xor (u1 shr 16);
-  v2 := Fm_hash[2] xor (u3 shl 16) xor (u2 shr 16);
-  v3 := Fm_hash[3] xor (u4 shl 16) xor (u3 shr 16);
-  v4 := Fm_hash[4] xor (u5 shl 16) xor (u4 shr 16);
-  v5 := Fm_hash[5] xor (u6 shl 16) xor (u5 shr 16);
-  v6 := Fm_hash[6] xor (u7 shl 16) xor (u6 shr 16);
-  v7 := Fm_hash[7] xor (u0 and $FFFF0000) xor (u0 shl 16) xor (u7 shr 16)
+  v0 := FHash[0] xor (u1 shl 16) xor (u0 shr 16);
+  v1 := FHash[1] xor (u2 shl 16) xor (u1 shr 16);
+  v2 := FHash[2] xor (u3 shl 16) xor (u2 shr 16);
+  v3 := FHash[3] xor (u4 shl 16) xor (u3 shr 16);
+  v4 := FHash[4] xor (u5 shl 16) xor (u4 shr 16);
+  v5 := FHash[5] xor (u6 shl 16) xor (u5 shr 16);
+  v6 := FHash[6] xor (u7 shl 16) xor (u6 shr 16);
+  v7 := FHash[7] xor (u0 and $FFFF0000) xor (u0 shl 16) xor (u7 shr 16)
     xor (u1 and $FFFF0000) xor (u1 shl 16) xor (u6 shl 16)
     xor (u7 and $FFFF0000);
 
-  Fm_hash[0] := (v0 and $FFFF0000) xor (v0 shl 16) xor (v0 shr 16)
-    xor (v1 shr 16) xor (v1 and $FFFF0000) xor (v2 shl 16) xor (v3 shr 16)
-    xor (v4 shl 16) xor (v5 shr 16) xor v5 xor (v6 shr 16) xor (v7 shl 16)
-    xor (v7 shr 16) xor (v7 and $FFFF);
-  Fm_hash[1] := (v0 shl 16) xor (v0 shr 16) xor (v0 and $FFFF0000)
+  FHash[0] := (v0 and $FFFF0000) xor (v0 shl 16) xor (v0 shr 16) xor (v1 shr 16)
+    xor (v1 and $FFFF0000) xor (v2 shl 16) xor (v3 shr 16) xor (v4 shl 16)
+    xor (v5 shr 16) xor v5 xor (v6 shr 16) xor (v7 shl 16) xor (v7 shr 16)
+    xor (v7 and $FFFF);
+  FHash[1] := (v0 shl 16) xor (v0 shr 16) xor (v0 and $FFFF0000)
     xor (v1 and $FFFF) xor v2 xor (v2 shr 16) xor (v3 shl 16) xor (v4 shr 16)
     xor (v5 shl 16) xor (v6 shl 16) xor v6 xor (v7 and $FFFF0000)
     xor (v7 shr 16);
-  Fm_hash[2] := (v0 and $FFFF) xor (v0 shl 16) xor (v1 shl 16) xor (v1 shr 16)
+  FHash[2] := (v0 and $FFFF) xor (v0 shl 16) xor (v1 shl 16) xor (v1 shr 16)
     xor (v1 and $FFFF0000) xor (v2 shl 16) xor (v3 shr 16)
     xor v3 xor (v4 shl 16) xor (v5 shr 16) xor v6 xor (v6 shr 16)
     xor (v7 and $FFFF) xor (v7 shl 16) xor (v7 shr 16);
-  Fm_hash[3] := (v0 shl 16) xor (v0 shr 16) xor (v0 and $FFFF0000)
+  FHash[3] := (v0 shl 16) xor (v0 shr 16) xor (v0 and $FFFF0000)
     xor (v1 and $FFFF0000) xor (v1 shr 16) xor (v2 shl 16) xor (v2 shr 16)
     xor v2 xor (v3 shl 16) xor (v4 shr 16) xor v4 xor (v5 shl 16)
     xor (v6 shl 16) xor (v7 and $FFFF) xor (v7 shr 16);
-  Fm_hash[4] := (v0 shr 16) xor (v1 shl 16) xor v1 xor (v2 shr 16)
+  FHash[4] := (v0 shr 16) xor (v1 shl 16) xor v1 xor (v2 shr 16)
     xor v2 xor (v3 shl 16) xor (v3 shr 16) xor v3 xor (v4 shl 16)
     xor (v5 shr 16) xor v5 xor (v6 shl 16) xor (v6 shr 16) xor (v7 shl 16);
-  Fm_hash[5] := (v0 shl 16) xor (v0 and $FFFF0000) xor (v1 shl 16)
-    xor (v1 shr 16) xor (v1 and $FFFF0000) xor (v2 shl 16)
-    xor v2 xor (v3 shr 16) xor v3 xor (v4 shl 16) xor (v4 shr 16)
-    xor v4 xor (v5 shl 16) xor (v6 shl 16) xor (v6 shr 16)
-    xor v6 xor (v7 shl 16) xor (v7 shr 16) xor (v7 and $FFFF0000);
-  Fm_hash[6] := v0 xor v2 xor (v2 shr 16) xor v3 xor (v3 shl 16)
+  FHash[5] := (v0 shl 16) xor (v0 and $FFFF0000) xor (v1 shl 16) xor (v1 shr 16)
+    xor (v1 and $FFFF0000) xor (v2 shl 16) xor v2 xor (v3 shr 16)
+    xor v3 xor (v4 shl 16) xor (v4 shr 16) xor v4 xor (v5 shl 16)
+    xor (v6 shl 16) xor (v6 shr 16) xor v6 xor (v7 shl 16) xor (v7 shr 16)
+    xor (v7 and $FFFF0000);
+  FHash[6] := v0 xor v2 xor (v2 shr 16) xor v3 xor (v3 shl 16)
     xor v4 xor (v4 shr 16) xor (v5 shl 16) xor (v5 shr 16)
     xor v5 xor (v6 shl 16) xor (v6 shr 16) xor v6 xor (v7 shl 16) xor v7;
-  Fm_hash[7] := v0 xor (v0 shr 16) xor (v1 shl 16) xor (v1 shr 16)
-    xor (v2 shl 16) xor (v3 shr 16) xor v3 xor (v4 shl 16)
-    xor v4 xor (v5 shr 16) xor v5 xor (v6 shl 16) xor (v6 shr 16)
-    xor (v7 shl 16) xor v7;
+  FHash[7] := v0 xor (v0 shr 16) xor (v1 shl 16) xor (v1 shr 16) xor (v2 shl 16)
+    xor (v3 shr 16) xor v3 xor (v4 shl 16) xor v4 xor (v5 shr 16)
+    xor v5 xor (v6 shl 16) xor (v6 shr 16) xor (v7 shl 16) xor v7;
 
 end;
 
 constructor TGost.Create;
 begin
   Inherited Create(32, 32);
-  System.SetLength(Fm_state, 8);
-  System.SetLength(Fm_hash, 8);
-
+  System.SetLength(FState, 8);
+  System.SetLength(FHash, 8);
 end;
 
 procedure TGost.Finish;
 var
-  bits: UInt64;
-  pad: THashLibByteArray;
-  m_length: THashLibUInt32Array;
+  LBits: UInt64;
+  LPad: THashLibByteArray;
+  LLength: THashLibUInt32Array;
 begin
-  bits := Fm_processed_bytes * 8;
+  LBits := FProcessedBytesCount * 8;
 
-  if (Fm_buffer.Pos > 0) then
+  if (FBuffer.Position > 0) then
   begin
-    System.SetLength(pad, 32 - Fm_buffer.Pos);
-    TransformBytes(pad, 0, 32 - Fm_buffer.Pos);
+    System.SetLength(LPad, 32 - FBuffer.Position);
+    TransformBytes(LPad, 0, 32 - FBuffer.Position);
   end;
-  System.SetLength(m_length, 8);
-  m_length[0] := UInt32(bits);
-  m_length[1] := UInt32(bits shr 32);
-
-  Compress(PCardinal(m_length));
+  System.SetLength(LLength, 8);
+  LLength[0] := UInt32(LBits);
+  LLength[1] := UInt32(LBits shr 32);
 
-  Compress(PCardinal(Fm_state));
+  Compress(PCardinal(LLength));
 
+  Compress(PCardinal(FState));
 end;
 
 function TGost.GetResult: THashLibByteArray;
 begin
   System.SetLength(result, 8 * System.SizeOf(UInt32));
-  TConverters.le32_copy(PCardinal(Fm_hash), 0, PByte(result), 0,
+  TConverters.le32_copy(PCardinal(FHash), 0, PByte(result), 0,
     System.Length(result));
 end;
 
 class constructor TGost.Gost;
 var
-  sbox: THashLibMatrixUInt32Array;
-
-  i, a, b: Int32;
+  LSBox: THashLibMatrixUInt32Array;
+  LIdx, LA, LB: Int32;
   ax, bx, cx, dx: UInt32;
 begin
-  sbox := THashLibMatrixUInt32Array.Create(THashLibUInt32Array.Create(4, 10, 9,
+  LSBox := THashLibMatrixUInt32Array.Create(THashLibUInt32Array.Create(4, 10, 9,
     2, 13, 8, 0, 14, 6, 11, 1, 12, 7, 15, 5, 3), THashLibUInt32Array.Create(14,
     11, 4, 12, 6, 13, 15, 10, 2, 3, 8, 1, 0, 7, 5, 9),
     THashLibUInt32Array.Create(5, 8, 1, 13, 10, 3, 4, 2, 14, 15, 12, 7, 6, 0, 9,
@@ -398,76 +394,71 @@ begin
     9, 0, 10, 14, 7, 6, 8, 2, 12), THashLibUInt32Array.Create(1, 15, 13, 0, 5,
     7, 10, 4, 9, 2, 3, 14, 6, 11, 8, 12));
 
-  System.SetLength(Fs_sbox1, 256);
-  System.SetLength(Fs_sbox2, 256);
-  System.SetLength(Fs_sbox3, 256);
-  System.SetLength(Fs_sbox4, 256);
-
-  i := 0;
+  System.SetLength(FSBox1, 256);
+  System.SetLength(FSBox2, 256);
+  System.SetLength(FSBox3, 256);
+  System.SetLength(FSBox4, 256);
 
-  for a := 0 to 15 do
+  LIdx := 0;
 
+  for LA := 0 to 15 do
   begin
-    ax := sbox[1, a] shl 15;
-    bx := sbox[3, a] shl 23;
-    cx := sbox[5, a];
+    ax := LSBox[1, LA] shl 15;
+    bx := LSBox[3, LA] shl 23;
+    cx := LSBox[5, LA];
     cx := TBits.RotateRight32(cx, 1);
-    dx := sbox[7, a] shl 7;
-
-    for b := 0 to 15 do
+    dx := LSBox[7, LA] shl 7;
 
+    for LB := 0 to 15 do
     begin
-      Fs_sbox1[i] := ax or (sbox[0, b] shl 11);
-      Fs_sbox2[i] := bx or (sbox[2, b] shl 19);
-      Fs_sbox3[i] := cx or (sbox[4, b] shl 27);
-      Fs_sbox4[i] := dx or (sbox[6, b] shl 3);
-      System.Inc(i);
+      FSBox1[LIdx] := ax or (LSBox[0, LB] shl 11);
+      FSBox2[LIdx] := bx or (LSBox[2, LB] shl 19);
+      FSBox3[LIdx] := cx or (LSBox[4, LB] shl 27);
+      FSBox4[LIdx] := dx or (LSBox[6, LB] shl 3);
+      System.Inc(LIdx);
     end;
-
   end;
 
 end;
 
 procedure TGost.Initialize;
 begin
-  TArrayUtils.ZeroFill(Fm_state);
-  TArrayUtils.ZeroFill(Fm_hash);
-
+  TArrayUtils.ZeroFill(FState);
+  TArrayUtils.ZeroFill(FHash);
   Inherited Initialize();
 end;
 
-procedure TGost.TransformBlock(a_data: PByte; a_data_length: Int32;
-  a_index: Int32);
+procedure TGost.TransformBlock(AData: PByte; ADataLength: Int32; AIndex: Int32);
 var
-  data, m: array [0 .. 7] of UInt32;
-  c, a, b: UInt32;
-  i: Int32;
+  LData, LM: array [0 .. 7] of UInt32;
+  LC, LA, LB: UInt32;
+  LIdx: Int32;
 begin
+  LC := 0;
 
-  c := 0;
+  TConverters.le32_copy(AData, AIndex, @(LData[0]), 0, ADataLength);
 
-  TConverters.le32_copy(a_data, a_index, @(data[0]), 0, a_data_length);
-
-  for i := 0 to 7 do
+  for LIdx := 0 to 7 do
   begin
-    a := data[i];
-    m[i] := a;
-    b := Fm_state[i];
-    c := a + c + Fm_state[i];
-    Fm_state[i] := c;
-    if ((c < a) or (c < b)) then
-
-      c := UInt32(1)
+    LA := LData[LIdx];
+    LM[LIdx] := LA;
+    LB := FState[LIdx];
+    LC := LA + LC + FState[LIdx];
+    FState[LIdx] := LC;
+    if ((LC < LA) or (LC < LB)) then
+    begin
+      LC := UInt32(1)
+    end
     else
-      c := UInt32(0);
-
+    begin
+      LC := UInt32(0);
+    end;
   end;
 
-  Compress(@(m[0]));
-
-  System.FillChar(m, System.SizeOf(m), UInt32(0));
-  System.FillChar(data, System.SizeOf(data), UInt32(0));
+  Compress(@(LM[0]));
 
+  System.FillChar(LM, System.SizeOf(LM), UInt32(0));
+  System.FillChar(LData, System.SizeOf(LData), UInt32(0));
 end;
 
 end.

+ 144 - 159
src/libraries/hashlib4pascal/HlpGrindahl256.pas

@@ -24,74 +24,73 @@ type
   TGrindahl256 = class sealed(TBlockHash, ICryptoNotBuildIn, ITransformBlock)
 
   strict private
-
-    Fm_state, Fm_temp: THashLibUInt32Array;
+  var
+    FState, FTemp: THashLibUInt32Array;
 
     class var
 
-      Fs_table_0, Fs_table_1, Fs_table_2, Fs_table_3: THashLibUInt32Array;
+      FSTable0, FSTable1, FSTable2, FSTable3: THashLibUInt32Array;
 
 {$REGION 'Consts'}
 
   const
-
-    s_master_table: array [0 .. 255] of UInt32 = ($C66363A5, $F87C7C84,
-      $EE777799, $F67B7B8D, $FFF2F20D, $D66B6BBD, $DE6F6FB1, $91C5C554,
-      $60303050, $02010103, $CE6767A9, $562B2B7D, $E7FEFE19, $B5D7D762,
-      $4DABABE6, $EC76769A, $8FCACA45, $1F82829D, $89C9C940, $FA7D7D87,
-      $EFFAFA15, $B25959EB, $8E4747C9, $FBF0F00B, $41ADADEC, $B3D4D467,
-      $5FA2A2FD, $45AFAFEA, $239C9CBF, $53A4A4F7, $E4727296, $9BC0C05B,
-      $75B7B7C2, $E1FDFD1C, $3D9393AE, $4C26266A, $6C36365A, $7E3F3F41,
-      $F5F7F702, $83CCCC4F, $6834345C, $51A5A5F4, $D1E5E534, $F9F1F108,
-      $E2717193, $ABD8D873, $62313153, $2A15153F, $0804040C, $95C7C752,
-      $46232365, $9DC3C35E, $30181828, $379696A1, $0A05050F, $2F9A9AB5,
-      $0E070709, $24121236, $1B80809B, $DFE2E23D, $CDEBEB26, $4E272769,
-      $7FB2B2CD, $EA75759F, $1209091B, $1D83839E, $582C2C74, $341A1A2E,
-      $361B1B2D, $DC6E6EB2, $B45A5AEE, $5BA0A0FB, $A45252F6, $763B3B4D,
-      $B7D6D661, $7DB3B3CE, $5229297B, $DDE3E33E, $5E2F2F71, $13848497,
-      $A65353F5, $B9D1D168, $00000000, $C1EDED2C, $40202060, $E3FCFC1F,
-      $79B1B1C8, $B65B5BED, $D46A6ABE, $8DCBCB46, $67BEBED9, $7239394B,
-      $944A4ADE, $984C4CD4, $B05858E8, $85CFCF4A, $BBD0D06B, $C5EFEF2A,
-      $4FAAAAE5, $EDFBFB16, $864343C5, $9A4D4DD7, $66333355, $11858594,
-      $8A4545CF, $E9F9F910, $04020206, $FE7F7F81, $A05050F0, $783C3C44,
-      $259F9FBA, $4BA8A8E3, $A25151F3, $5DA3A3FE, $804040C0, $058F8F8A,
-      $3F9292AD, $219D9DBC, $70383848, $F1F5F504, $63BCBCDF, $77B6B6C1,
-      $AFDADA75, $42212163, $20101030, $E5FFFF1A, $FDF3F30E, $BFD2D26D,
-      $81CDCD4C, $180C0C14, $26131335, $C3ECEC2F, $BE5F5FE1, $359797A2,
-      $884444CC, $2E171739, $93C4C457, $55A7A7F2, $FC7E7E82, $7A3D3D47,
-      $C86464AC, $BA5D5DE7, $3219192B, $E6737395, $C06060A0, $19818198,
-      $9E4F4FD1, $A3DCDC7F, $44222266, $542A2A7E, $3B9090AB, $0B888883,
-      $8C4646CA, $C7EEEE29, $6BB8B8D3, $2814143C, $A7DEDE79, $BC5E5EE2,
-      $160B0B1D, $ADDBDB76, $DBE0E03B, $64323256, $743A3A4E, $140A0A1E,
-      $924949DB, $0C06060A, $4824246C, $B85C5CE4, $9FC2C25D, $BDD3D36E,
-      $43ACACEF, $C46262A6, $399191A8, $319595A4, $D3E4E437, $F279798B,
-      $D5E7E732, $8BC8C843, $6E373759, $DA6D6DB7, $018D8D8C, $B1D5D564,
-      $9C4E4ED2, $49A9A9E0, $D86C6CB4, $AC5656FA, $F3F4F407, $CFEAEA25,
-      $CA6565AF, $F47A7A8E, $47AEAEE9, $10080818, $6FBABAD5, $F0787888,
-      $4A25256F, $5C2E2E72, $381C1C24, $57A6A6F1, $73B4B4C7, $97C6C651,
-      $CBE8E823, $A1DDDD7C, $E874749C, $3E1F1F21, $964B4BDD, $61BDBDDC,
-      $0D8B8B86, $0F8A8A85, $E0707090, $7C3E3E42, $71B5B5C4, $CC6666AA,
-      $904848D8, $06030305, $F7F6F601, $1C0E0E12, $C26161A3, $6A35355F,
-      $AE5757F9, $69B9B9D0, $17868691, $99C1C158, $3A1D1D27, $279E9EB9,
-      $D9E1E138, $EBF8F813, $2B9898B3, $22111133, $D26969BB, $A9D9D970,
-      $078E8E89, $339494A7, $2D9B9BB6, $3C1E1E22, $15878792, $C9E9E920,
-      $87CECE49, $AA5555FF, $50282878, $A5DFDF7A, $038C8C8F, $59A1A1F8,
-      $09898980, $1A0D0D17, $65BFBFDA, $D7E6E631, $844242C6, $D06868B8,
-      $824141C3, $299999B0, $5A2D2D77, $1E0F0F11, $7BB0B0CB, $A85454FC,
-      $6DBBBBD6, $2C16163A);
+    SMasterTable: array [0 .. 255] of UInt32 = ($C66363A5, $F87C7C84, $EE777799,
+      $F67B7B8D, $FFF2F20D, $D66B6BBD, $DE6F6FB1, $91C5C554, $60303050,
+      $02010103, $CE6767A9, $562B2B7D, $E7FEFE19, $B5D7D762, $4DABABE6,
+      $EC76769A, $8FCACA45, $1F82829D, $89C9C940, $FA7D7D87, $EFFAFA15,
+      $B25959EB, $8E4747C9, $FBF0F00B, $41ADADEC, $B3D4D467, $5FA2A2FD,
+      $45AFAFEA, $239C9CBF, $53A4A4F7, $E4727296, $9BC0C05B, $75B7B7C2,
+      $E1FDFD1C, $3D9393AE, $4C26266A, $6C36365A, $7E3F3F41, $F5F7F702,
+      $83CCCC4F, $6834345C, $51A5A5F4, $D1E5E534, $F9F1F108, $E2717193,
+      $ABD8D873, $62313153, $2A15153F, $0804040C, $95C7C752, $46232365,
+      $9DC3C35E, $30181828, $379696A1, $0A05050F, $2F9A9AB5, $0E070709,
+      $24121236, $1B80809B, $DFE2E23D, $CDEBEB26, $4E272769, $7FB2B2CD,
+      $EA75759F, $1209091B, $1D83839E, $582C2C74, $341A1A2E, $361B1B2D,
+      $DC6E6EB2, $B45A5AEE, $5BA0A0FB, $A45252F6, $763B3B4D, $B7D6D661,
+      $7DB3B3CE, $5229297B, $DDE3E33E, $5E2F2F71, $13848497, $A65353F5,
+      $B9D1D168, $00000000, $C1EDED2C, $40202060, $E3FCFC1F, $79B1B1C8,
+      $B65B5BED, $D46A6ABE, $8DCBCB46, $67BEBED9, $7239394B, $944A4ADE,
+      $984C4CD4, $B05858E8, $85CFCF4A, $BBD0D06B, $C5EFEF2A, $4FAAAAE5,
+      $EDFBFB16, $864343C5, $9A4D4DD7, $66333355, $11858594, $8A4545CF,
+      $E9F9F910, $04020206, $FE7F7F81, $A05050F0, $783C3C44, $259F9FBA,
+      $4BA8A8E3, $A25151F3, $5DA3A3FE, $804040C0, $058F8F8A, $3F9292AD,
+      $219D9DBC, $70383848, $F1F5F504, $63BCBCDF, $77B6B6C1, $AFDADA75,
+      $42212163, $20101030, $E5FFFF1A, $FDF3F30E, $BFD2D26D, $81CDCD4C,
+      $180C0C14, $26131335, $C3ECEC2F, $BE5F5FE1, $359797A2, $884444CC,
+      $2E171739, $93C4C457, $55A7A7F2, $FC7E7E82, $7A3D3D47, $C86464AC,
+      $BA5D5DE7, $3219192B, $E6737395, $C06060A0, $19818198, $9E4F4FD1,
+      $A3DCDC7F, $44222266, $542A2A7E, $3B9090AB, $0B888883, $8C4646CA,
+      $C7EEEE29, $6BB8B8D3, $2814143C, $A7DEDE79, $BC5E5EE2, $160B0B1D,
+      $ADDBDB76, $DBE0E03B, $64323256, $743A3A4E, $140A0A1E, $924949DB,
+      $0C06060A, $4824246C, $B85C5CE4, $9FC2C25D, $BDD3D36E, $43ACACEF,
+      $C46262A6, $399191A8, $319595A4, $D3E4E437, $F279798B, $D5E7E732,
+      $8BC8C843, $6E373759, $DA6D6DB7, $018D8D8C, $B1D5D564, $9C4E4ED2,
+      $49A9A9E0, $D86C6CB4, $AC5656FA, $F3F4F407, $CFEAEA25, $CA6565AF,
+      $F47A7A8E, $47AEAEE9, $10080818, $6FBABAD5, $F0787888, $4A25256F,
+      $5C2E2E72, $381C1C24, $57A6A6F1, $73B4B4C7, $97C6C651, $CBE8E823,
+      $A1DDDD7C, $E874749C, $3E1F1F21, $964B4BDD, $61BDBDDC, $0D8B8B86,
+      $0F8A8A85, $E0707090, $7C3E3E42, $71B5B5C4, $CC6666AA, $904848D8,
+      $06030305, $F7F6F601, $1C0E0E12, $C26161A3, $6A35355F, $AE5757F9,
+      $69B9B9D0, $17868691, $99C1C158, $3A1D1D27, $279E9EB9, $D9E1E138,
+      $EBF8F813, $2B9898B3, $22111133, $D26969BB, $A9D9D970, $078E8E89,
+      $339494A7, $2D9B9BB6, $3C1E1E22, $15878792, $C9E9E920, $87CECE49,
+      $AA5555FF, $50282878, $A5DFDF7A, $038C8C8F, $59A1A1F8, $09898980,
+      $1A0D0D17, $65BFBFDA, $D7E6E631, $844242C6, $D06868B8, $824141C3,
+      $299999B0, $5A2D2D77, $1E0F0F11, $7BB0B0CB, $A85454FC, $6DBBBBD6,
+      $2C16163A);
 
 {$ENDREGION}
-    class function CalcTable(i: Int32): THashLibUInt32Array;
+    class function CalcTable(AI: Int32): THashLibUInt32Array;
 
-    procedure InjectMsg(a_full_process: Boolean);
+    procedure InjectMsg(AFullProcess: Boolean);
 
     class constructor Grindahl256();
 
   strict protected
     procedure Finish(); override;
     function GetResult(): THashLibByteArray; override;
-    procedure TransformBlock(a_data: PByte; a_data_length: Int32;
-      a_index: Int32); override;
+    procedure TransformBlock(AData: PByte; ADataLength: Int32;
+      AIndex: Int32); override;
 
   public
     constructor Create();
@@ -104,191 +103,177 @@ implementation
 
 { TGrindahl256 }
 
-class function TGrindahl256.CalcTable(i: Int32): THashLibUInt32Array;
+class function TGrindahl256.CalcTable(AI: Int32): THashLibUInt32Array;
 var
-  j: Int32;
+  Jdx: Int32;
 begin
   System.SetLength(result, 256);
-  j := 0;
-  while j < 256 do
+  Jdx := 0;
+  while Jdx < 256 do
   begin
-    result[j] := UInt32((s_master_table[j] shr (i * 8)) or
-      (s_master_table[j] shl (32 - i * 8)));
-    System.Inc(j);
+    result[Jdx] := UInt32((SMasterTable[Jdx] shr (AI * 8)) or
+      (SMasterTable[Jdx] shl (32 - AI * 8)));
+    System.Inc(Jdx);
   end;
 end;
 
 function TGrindahl256.Clone(): IHash;
 var
-  HashInstance: TGrindahl256;
+  LHashInstance: TGrindahl256;
 begin
-  HashInstance := TGrindahl256.Create();
-  HashInstance.Fm_state := System.Copy(Fm_state);
-  HashInstance.Fm_temp := System.Copy(Fm_temp);
-  HashInstance.Fm_buffer := Fm_buffer.Clone();
-  HashInstance.Fm_processed_bytes := Fm_processed_bytes;
-  result := HashInstance as IHash;
+  LHashInstance := TGrindahl256.Create();
+  LHashInstance.FState := System.Copy(FState);
+  LHashInstance.FTemp := System.Copy(FTemp);
+  LHashInstance.FBuffer := FBuffer.Clone();
+  LHashInstance.FProcessedBytesCount := FProcessedBytesCount;
+  result := LHashInstance as IHash;
   result.BufferSize := BufferSize;
 end;
 
 constructor TGrindahl256.Create;
 begin
   Inherited Create(32, 4);
-  System.SetLength(Fm_state, 13);
-  System.SetLength(Fm_temp, 13);
+  System.SetLength(FState, 13);
+  System.SetLength(FTemp, 13);
 end;
 
 procedure TGrindahl256.Finish;
 var
-  padding_size, i: Int32;
-  msg_length: UInt64;
-  pad: THashLibByteArray;
+  LPaddingSize, LIdx: Int32;
+  LMessageLength: UInt64;
+  LPad: THashLibByteArray;
 begin
+  LPaddingSize := 12 - Int32(FProcessedBytesCount and UInt32(3));
+  LMessageLength := (FProcessedBytesCount shr UInt64(2)) + 1;
 
-  padding_size := 12 - Int32(Fm_processed_bytes and UInt32(3));
-  msg_length := (Fm_processed_bytes shr UInt64(2)) + 1;
+  System.SetLength(LPad, LPaddingSize);
 
-  System.SetLength(pad, padding_size);
+  LPad[0] := $80;
 
-  pad[0] := $80;
+  LMessageLength := TConverters.be2me_64(LMessageLength);
 
-  msg_length := TConverters.be2me_64(msg_length);
+  TConverters.ReadUInt64AsBytesLE(LMessageLength, LPad, LPaddingSize - 8);
 
-  TConverters.ReadUInt64AsBytesLE(msg_length, pad, padding_size - 8);
+  TransformBytes(LPad, 0, LPaddingSize - 4);
 
-  TransformBytes(pad, 0, padding_size - 4);
+  FState[0] := TConverters.ReadBytesAsUInt32LE(PByte(LPad), LPaddingSize - 4);
 
-  Fm_state[0] := TConverters.ReadBytesAsUInt32LE(PByte(pad), padding_size - 4);
-
-  Fm_state[0] := TConverters.be2me_32(Fm_state[0]);
+  FState[0] := TConverters.be2me_32(FState[0]);
 
   InjectMsg(true);
 
-  i := 0;
+  LIdx := 0;
 
-  while i < 8 do
+  while LIdx < 8 do
   begin
     InjectMsg(true);
-    System.Inc(i);
+    System.Inc(LIdx);
   end;
-
 end;
 
 function TGrindahl256.GetResult: THashLibByteArray;
 begin
-
   System.SetLength(result, 8 * System.SizeOf(UInt32));
-
-  TConverters.be32_copy(PCardinal(Fm_state), 5 * System.SizeOf(UInt32),
+  TConverters.be32_copy(PCardinal(FState), 5 * System.SizeOf(UInt32),
     PByte(result), 0, System.Length(result));
-
 end;
 
 class constructor TGrindahl256.Grindahl256;
 var
-  LowVal1, LowVal2: Int32;
+  LLowIndex1, LLowIndex2: Int32;
 begin
+  System.SetLength(FSTable0, System.Length(SMasterTable));
 
-  System.SetLength(Fs_table_0, System.Length(s_master_table));
-
-  LowVal1 := System.Low(s_master_table);
-  LowVal2 := System.Low(Fs_table_0);
+  LLowIndex1 := System.Low(SMasterTable);
+  LLowIndex2 := System.Low(FSTable0);
 
-  System.Move(s_master_table[LowVal1], Fs_table_0[LowVal2],
-    System.SizeOf(s_master_table));
+  System.Move(SMasterTable[LLowIndex1], FSTable0[LLowIndex2],
+    System.SizeOf(SMasterTable));
 
-  Fs_table_1 := CalcTable(1);
-  Fs_table_2 := CalcTable(2);
-  Fs_table_3 := CalcTable(3);
+  FSTable1 := CalcTable(1);
+  FSTable2 := CalcTable(2);
+  FSTable3 := CalcTable(3);
 end;
 
 procedure TGrindahl256.Initialize;
 begin
-  TArrayUtils.ZeroFill(Fm_state);
-  TArrayUtils.ZeroFill(Fm_temp);
-
+  TArrayUtils.ZeroFill(FState);
+  TArrayUtils.ZeroFill(FTemp);
   Inherited Initialize();
-
 end;
 
-procedure TGrindahl256.InjectMsg(a_full_process: Boolean);
+procedure TGrindahl256.InjectMsg(AFullProcess: Boolean);
 var
-  u: THashLibUInt32Array;
+  LU: THashLibUInt32Array;
 begin
+  FState[12] := FState[12] xor $01;
 
-  Fm_state[12] := Fm_state[12] xor $01;
-
-  if (a_full_process) then
+  if (AFullProcess) then
   begin
-    Fm_temp[0] := Fs_table_0[Byte(Fm_state[12] shr 24)] xor Fs_table_1
-      [Byte(Fm_state[11] shr 16)] xor Fs_table_2[Byte(Fm_state[9] shr 8)
-      ] xor Fs_table_3[Byte(Fm_state[3])];
+    FTemp[0] := FSTable0[Byte(FState[12] shr 24)] xor FSTable1
+      [Byte(FState[11] shr 16)] xor FSTable2[Byte(FState[9] shr 8)] xor FSTable3
+      [Byte(FState[3])];
   end;
 
-  Fm_temp[1] := Fs_table_0[Byte(Fm_state[0] shr 24)] xor Fs_table_1
-    [Byte(Fm_state[12] shr 16)] xor Fs_table_2[Byte(Fm_state[10] shr 8)
-    ] xor Fs_table_3[Byte(Fm_state[4])];
-
-  Fm_temp[2] := Fs_table_0[Byte(Fm_state[1] shr 24)] xor Fs_table_1
-    [Byte(Fm_state[0] shr 16)] xor Fs_table_2[Byte(Fm_state[11] shr 8)
-    ] xor Fs_table_3[Byte(Fm_state[5])];
+  FTemp[1] := FSTable0[Byte(FState[0] shr 24)] xor FSTable1
+    [Byte(FState[12] shr 16)] xor FSTable2[Byte(FState[10] shr 8)] xor FSTable3
+    [Byte(FState[4])];
 
-  Fm_temp[3] := Fs_table_0[Byte(Fm_state[2] shr 24)] xor Fs_table_1
-    [Byte(Fm_state[1] shr 16)] xor Fs_table_2[Byte(Fm_state[12] shr 8)
-    ] xor Fs_table_3[Byte(Fm_state[6])];
+  FTemp[2] := FSTable0[Byte(FState[1] shr 24)] xor FSTable1
+    [Byte(FState[0] shr 16)] xor FSTable2[Byte(FState[11] shr 8)] xor FSTable3
+    [Byte(FState[5])];
 
-  Fm_temp[4] := Fs_table_0[Byte(Fm_state[3] shr 24)] xor Fs_table_1
-    [Byte(Fm_state[2] shr 16)] xor Fs_table_2[Byte(Fm_state[0] shr 8)
-    ] xor Fs_table_3[Byte(Fm_state[7])];
+  FTemp[3] := FSTable0[Byte(FState[2] shr 24)] xor FSTable1
+    [Byte(FState[1] shr 16)] xor FSTable2[Byte(FState[12] shr 8)] xor FSTable3
+    [Byte(FState[6])];
 
-  Fm_temp[5] := Fs_table_0[Byte(Fm_state[4] shr 24)] xor Fs_table_1
-    [Byte(Fm_state[3] shr 16)] xor Fs_table_2[Byte(Fm_state[1] shr 8)
-    ] xor Fs_table_3[Byte(Fm_state[8])];
+  FTemp[4] := FSTable0[Byte(FState[3] shr 24)] xor FSTable1
+    [Byte(FState[2] shr 16)] xor FSTable2[Byte(FState[0] shr 8)] xor FSTable3
+    [Byte(FState[7])];
 
-  Fm_temp[6] := Fs_table_0[Byte(Fm_state[5] shr 24)] xor Fs_table_1
-    [Byte(Fm_state[4] shr 16)] xor Fs_table_2[Byte(Fm_state[2] shr 8)
-    ] xor Fs_table_3[Byte(Fm_state[9])];
+  FTemp[5] := FSTable0[Byte(FState[4] shr 24)] xor FSTable1
+    [Byte(FState[3] shr 16)] xor FSTable2[Byte(FState[1] shr 8)] xor FSTable3
+    [Byte(FState[8])];
 
-  Fm_temp[7] := Fs_table_0[Byte(Fm_state[6] shr 24)] xor Fs_table_1
-    [Byte(Fm_state[5] shr 16)] xor Fs_table_2[Byte(Fm_state[3] shr 8)
-    ] xor Fs_table_3[Byte(Fm_state[10])];
+  FTemp[6] := FSTable0[Byte(FState[5] shr 24)] xor FSTable1
+    [Byte(FState[4] shr 16)] xor FSTable2[Byte(FState[2] shr 8)] xor FSTable3
+    [Byte(FState[9])];
 
-  Fm_temp[8] := Fs_table_0[Byte(Fm_state[7] shr 24)] xor Fs_table_1
-    [Byte(Fm_state[6] shr 16)] xor Fs_table_2[Byte(Fm_state[4] shr 8)
-    ] xor Fs_table_3[Byte(Fm_state[11])];
+  FTemp[7] := FSTable0[Byte(FState[6] shr 24)] xor FSTable1
+    [Byte(FState[5] shr 16)] xor FSTable2[Byte(FState[3] shr 8)] xor FSTable3
+    [Byte(FState[10])];
 
-  Fm_temp[9] := Fs_table_0[Byte(Fm_state[8] shr 24)] xor Fs_table_1
-    [Byte(Fm_state[7] shr 16)] xor Fs_table_2[Byte(Fm_state[5] shr 8)
-    ] xor Fs_table_3[Byte(Fm_state[12])];
+  FTemp[8] := FSTable0[Byte(FState[7] shr 24)] xor FSTable1
+    [Byte(FState[6] shr 16)] xor FSTable2[Byte(FState[4] shr 8)] xor FSTable3
+    [Byte(FState[11])];
 
-  Fm_temp[10] := Fs_table_0[Byte(Fm_state[9] shr 24)] xor Fs_table_1
-    [Byte(Fm_state[8] shr 16)] xor Fs_table_2[Byte(Fm_state[6] shr 8)
-    ] xor Fs_table_3[Byte(Fm_state[0])];
+  FTemp[9] := FSTable0[Byte(FState[8] shr 24)] xor FSTable1
+    [Byte(FState[7] shr 16)] xor FSTable2[Byte(FState[5] shr 8)] xor FSTable3
+    [Byte(FState[12])];
 
-  Fm_temp[11] := Fs_table_0[Byte(Fm_state[10] shr 24)] xor Fs_table_1
-    [Byte(Fm_state[9] shr 16)] xor Fs_table_2[Byte(Fm_state[7] shr 8)
-    ] xor Fs_table_3[Byte(Fm_state[1])];
+  FTemp[10] := FSTable0[Byte(FState[9] shr 24)] xor FSTable1
+    [Byte(FState[8] shr 16)] xor FSTable2[Byte(FState[6] shr 8)] xor FSTable3
+    [Byte(FState[0])];
 
-  Fm_temp[12] := Fs_table_0[Byte(Fm_state[11] shr 24)] xor Fs_table_1
-    [Byte(Fm_state[10] shr 16)] xor Fs_table_2[Byte(Fm_state[8] shr 8)
-    ] xor Fs_table_3[Byte(Fm_state[2])];
+  FTemp[11] := FSTable0[Byte(FState[10] shr 24)] xor FSTable1
+    [Byte(FState[9] shr 16)] xor FSTable2[Byte(FState[7] shr 8)] xor FSTable3
+    [Byte(FState[1])];
 
-  u := Fm_temp;
-  Fm_temp := Fm_state;
-  Fm_state := u;
+  FTemp[12] := FSTable0[Byte(FState[11] shr 24)] xor FSTable1
+    [Byte(FState[10] shr 16)] xor FSTable2[Byte(FState[8] shr 8)] xor FSTable3
+    [Byte(FState[2])];
 
+  LU := FTemp;
+  FTemp := FState;
+  FState := LU;
 end;
 
-procedure TGrindahl256.TransformBlock(a_data: PByte; a_data_length: Int32;
-  a_index: Int32);
+procedure TGrindahl256.TransformBlock(AData: PByte; ADataLength: Int32;
+  AIndex: Int32);
 begin
-
-  Fm_state[0] := TConverters.ReadBytesAsUInt32LE(a_data, a_index);
-
-  Fm_state[0] := TConverters.be2me_32(Fm_state[0]);
-
+  FState[0] := TConverters.ReadBytesAsUInt32LE(AData, AIndex);
+  FState[0] := TConverters.be2me_32(FState[0]);
   InjectMsg(false);
-
 end;
 
 end.

+ 143 - 163
src/libraries/hashlib4pascal/HlpGrindahl512.pas

@@ -25,19 +25,18 @@ type
   TGrindahl512 = class sealed(TBlockHash, ICryptoNotBuildIn, ITransformBlock)
 
   strict private
-
-    Fm_state, Fm_temp: THashLibUInt64Array;
+  var
+    FState, FTemp: THashLibUInt64Array;
 
     class var
 
-      Fs_table_0, Fs_table_1, Fs_table_2, Fs_table_3, Fs_table_4, Fs_table_5,
-      Fs_table_6, Fs_table_7: THashLibUInt64Array;
+      FSTable0, FSTable1, FSTable2, FSTable3, FSTable4, FSTable5, FSTable6,
+      FSTable7: THashLibUInt64Array;
 
 {$REGION 'Consts'}
 
   const
-
-    s_master_table: array [0 .. 255] of UInt64 = (UInt64($C6636397633551A2),
+    SMasterTable: array [0 .. 255] of UInt64 = (UInt64($C6636397633551A2),
       UInt64($F87C7CEB7CCD1326), UInt64($EE7777C777952952),
       UInt64($F67B7BF77BF50102), UInt64($FFF2F2E5F2D11A34),
       UInt64($D66B6BB76B7561C2), UInt64($DE6F6FA76F5579F2),
@@ -168,17 +167,17 @@ type
       UInt64($2C16165816B074E8));
 
 {$ENDREGION}
-    class function CalcTable(i: Int32): THashLibUInt64Array;
+    class function CalcTable(AI: Int32): THashLibUInt64Array;
 
-    procedure InjectMsg(a_full_process: Boolean);
+    procedure InjectMsg(AFullProcess: Boolean);
 
     class constructor Grindahl512();
 
   strict protected
     procedure Finish(); override;
     function GetResult(): THashLibByteArray; override;
-    procedure TransformBlock(a_data: PByte; a_data_length: Int32;
-      a_index: Int32); override;
+    procedure TransformBlock(AData: PByte; ADataLength: Int32;
+      AIndex: Int32); override;
 
   public
     constructor Create();
@@ -191,225 +190,206 @@ implementation
 
 { TGrindahl512 }
 
-class function TGrindahl512.CalcTable(i: Int32): THashLibUInt64Array;
+class function TGrindahl512.CalcTable(AI: Int32): THashLibUInt64Array;
 var
-  j: Int32;
+  Jdx: Int32;
 begin
   System.SetLength(result, 256);
-  j := 0;
-  while j < 256 do
+  Jdx := 0;
+  while Jdx < 256 do
   begin
-    result[j] := TBits.RotateRight64(s_master_table[j], i * 8);
-    System.Inc(j);
+    result[Jdx] := TBits.RotateRight64(SMasterTable[Jdx], AI * 8);
+    System.Inc(Jdx);
   end;
 end;
 
 function TGrindahl512.Clone(): IHash;
 var
-  HashInstance: TGrindahl512;
+  LHashInstance: TGrindahl512;
 begin
-  HashInstance := TGrindahl512.Create();
-  HashInstance.Fm_state := System.Copy(Fm_state);
-  HashInstance.Fm_temp := System.Copy(Fm_temp);
-  HashInstance.Fm_buffer := Fm_buffer.Clone();
-  HashInstance.Fm_processed_bytes := Fm_processed_bytes;
-  result := HashInstance as IHash;
+  LHashInstance := TGrindahl512.Create();
+  LHashInstance.FState := System.Copy(FState);
+  LHashInstance.FTemp := System.Copy(FTemp);
+  LHashInstance.FBuffer := FBuffer.Clone();
+  LHashInstance.FProcessedBytesCount := FProcessedBytesCount;
+  result := LHashInstance as IHash;
   result.BufferSize := BufferSize;
 end;
 
 constructor TGrindahl512.Create;
 begin
   Inherited Create(64, 8);
-  System.SetLength(Fm_state, 13);
-  System.SetLength(Fm_temp, 13);
+  System.SetLength(FState, 13);
+  System.SetLength(FTemp, 13);
 end;
 
 procedure TGrindahl512.Finish;
 var
-  padding_size, i: Int32;
-  msg_length: UInt64;
-  pad: THashLibByteArray;
+  LPaddingSize, LIdx: Int32;
+  LMessageLength: UInt64;
+  LPad: THashLibByteArray;
 begin
-  padding_size := 16 - Int32(Fm_processed_bytes and UInt32(7));
-  msg_length := (Fm_processed_bytes shr UInt64(3)) + 1;
+  LPaddingSize := 16 - Int32(FProcessedBytesCount and UInt32(7));
+  LMessageLength := (FProcessedBytesCount shr UInt64(3)) + 1;
 
-  System.SetLength(pad, padding_size);
+  System.SetLength(LPad, LPaddingSize);
 
-  pad[0] := $80;
+  LPad[0] := $80;
 
-  msg_length := TConverters.be2me_64(msg_length);
+  LMessageLength := TConverters.be2me_64(LMessageLength);
 
-  TConverters.ReadUInt64AsBytesLE(msg_length, pad, padding_size - 8);
+  TConverters.ReadUInt64AsBytesLE(LMessageLength, LPad, LPaddingSize - 8);
 
-  TransformBytes(pad, 0, padding_size - 8);
+  TransformBytes(LPad, 0, LPaddingSize - 8);
 
-  Fm_state[0] := TConverters.ReadBytesAsUInt64LE(PByte(pad), padding_size - 8);
+  FState[0] := TConverters.ReadBytesAsUInt64LE(PByte(LPad), LPaddingSize - 8);
 
-  Fm_state[0] := TConverters.be2me_64(Fm_state[0]);
+  FState[0] := TConverters.be2me_64(FState[0]);
 
   InjectMsg(true);
 
-  i := 0;
+  LIdx := 0;
 
-  while i < 8 do
+  while LIdx < 8 do
   begin
     InjectMsg(true);
-    System.Inc(i);
+    System.Inc(LIdx);
   end;
-
 end;
 
 function TGrindahl512.GetResult: THashLibByteArray;
 begin
-
   System.SetLength(result, 8 * System.SizeOf(UInt64));
-
-  TConverters.be64_copy(PUInt64(Fm_state), 5 * System.SizeOf(UInt64),
+  TConverters.be64_copy(PUInt64(FState), 5 * System.SizeOf(UInt64),
     PByte(result), 0, System.Length(result));
-
 end;
 
 class constructor TGrindahl512.Grindahl512;
 var
-  LowVal1, LowVal2: Int32;
+  LLowIndex1, LLowIndex2: Int32;
 begin
+  System.SetLength(FSTable0, System.Length(SMasterTable));
 
-  System.SetLength(Fs_table_0, System.Length(s_master_table));
-
-  LowVal1 := System.Low(s_master_table);
-  LowVal2 := System.Low(Fs_table_0);
-
-  System.Move(s_master_table[LowVal1], Fs_table_0[LowVal2],
-    System.SizeOf(s_master_table));
+  LLowIndex1 := System.Low(SMasterTable);
+  LLowIndex2 := System.Low(FSTable0);
 
-  Fs_table_1 := CalcTable(1);
-  Fs_table_2 := CalcTable(2);
-  Fs_table_3 := CalcTable(3);
-  Fs_table_4 := CalcTable(4);
-  Fs_table_5 := CalcTable(5);
-  Fs_table_6 := CalcTable(6);
-  Fs_table_7 := CalcTable(7);
+  System.Move(SMasterTable[LLowIndex1], FSTable0[LLowIndex2],
+    System.SizeOf(SMasterTable));
 
+  FSTable1 := CalcTable(1);
+  FSTable2 := CalcTable(2);
+  FSTable3 := CalcTable(3);
+  FSTable4 := CalcTable(4);
+  FSTable5 := CalcTable(5);
+  FSTable6 := CalcTable(6);
+  FSTable7 := CalcTable(7);
 end;
 
 procedure TGrindahl512.Initialize;
 begin
-  TArrayUtils.ZeroFill(Fm_state);
-  TArrayUtils.ZeroFill(Fm_temp);
-
+  TArrayUtils.ZeroFill(FState);
+  TArrayUtils.ZeroFill(FTemp);
   Inherited Initialize();
-
 end;
 
-procedure TGrindahl512.InjectMsg(a_full_process: Boolean);
+procedure TGrindahl512.InjectMsg(AFullProcess: Boolean);
 var
-  u: THashLibUInt64Array;
+  LU: THashLibUInt64Array;
 begin
+  FState[12] := FState[12] xor $01;
 
-  Fm_state[12] := Fm_state[12] xor $01;
-
-  if (a_full_process) then
+  if (AFullProcess) then
   begin
-    Fm_temp[0] := Fs_table_0[Byte(Fm_state[12] shr 56)] xor Fs_table_1
-      [Byte(Fm_state[11] shr 48)] xor Fs_table_2[Byte(Fm_state[10] shr 40)
-      ] xor Fs_table_3[Byte(Fm_state[9] shr 32)] xor Fs_table_4
-      [Byte(Fm_state[8] shr 24)] xor Fs_table_5[Byte(Fm_state[7] shr 16)
-      ] xor Fs_table_6[Byte(Fm_state[6] shr 8)] xor Fs_table_7
-      [Byte(Fm_state[5])];
+    FTemp[0] := FSTable0[Byte(FState[12] shr 56)] xor FSTable1
+      [Byte(FState[11] shr 48)] xor FSTable2[Byte(FState[10] shr 40)
+      ] xor FSTable3[Byte(FState[9] shr 32)] xor FSTable4[Byte(FState[8] shr 24)
+      ] xor FSTable5[Byte(FState[7] shr 16)] xor FSTable6[Byte(FState[6] shr 8)
+      ] xor FSTable7[Byte(FState[5])];
   end;
 
-  Fm_temp[1] := Fs_table_0[Byte(Fm_state[0] shr 56)] xor Fs_table_1
-    [Byte(Fm_state[12] shr 48)] xor Fs_table_2[Byte(Fm_state[11] shr 40)
-    ] xor Fs_table_3[Byte(Fm_state[10] shr 32)] xor Fs_table_4
-    [Byte(Fm_state[9] shr 24)] xor Fs_table_5[Byte(Fm_state[8] shr 16)
-    ] xor Fs_table_6[Byte(Fm_state[7] shr 8)] xor Fs_table_7[Byte(Fm_state[6])];
-
-  Fm_temp[2] := Fs_table_0[Byte(Fm_state[1] shr 56)] xor Fs_table_1
-    [Byte(Fm_state[0] shr 48)] xor Fs_table_2[Byte(Fm_state[12] shr 40)
-    ] xor Fs_table_3[Byte(Fm_state[11] shr 32)] xor Fs_table_4
-    [Byte(Fm_state[10] shr 24)] xor Fs_table_5[Byte(Fm_state[9] shr 16)
-    ] xor Fs_table_6[Byte(Fm_state[8] shr 8)] xor Fs_table_7[Byte(Fm_state[7])];
-
-  Fm_temp[3] := Fs_table_0[Byte(Fm_state[2] shr 56)] xor Fs_table_1
-    [Byte(Fm_state[1] shr 48)] xor Fs_table_2[Byte(Fm_state[0] shr 40)
-    ] xor Fs_table_3[Byte(Fm_state[12] shr 32)] xor Fs_table_4
-    [Byte(Fm_state[11] shr 24)] xor Fs_table_5[Byte(Fm_state[10] shr 16)
-    ] xor Fs_table_6[Byte(Fm_state[9] shr 8)] xor Fs_table_7[Byte(Fm_state[8])];
-
-  Fm_temp[4] := Fs_table_0[Byte(Fm_state[3] shr 56)] xor Fs_table_1
-    [Byte(Fm_state[2] shr 48)] xor Fs_table_2[Byte(Fm_state[1] shr 40)
-    ] xor Fs_table_3[Byte(Fm_state[0] shr 32)] xor Fs_table_4
-    [Byte(Fm_state[12] shr 24)] xor Fs_table_5[Byte(Fm_state[11] shr 16)
-    ] xor Fs_table_6[Byte(Fm_state[10] shr 8)] xor Fs_table_7
-    [Byte(Fm_state[9])];
-
-  Fm_temp[5] := Fs_table_0[Byte(Fm_state[4] shr 56)] xor Fs_table_1
-    [Byte(Fm_state[3] shr 48)] xor Fs_table_2[Byte(Fm_state[2] shr 40)
-    ] xor Fs_table_3[Byte(Fm_state[1] shr 32)] xor Fs_table_4
-    [Byte(Fm_state[0] shr 24)] xor Fs_table_5[Byte(Fm_state[12] shr 16)
-    ] xor Fs_table_6[Byte(Fm_state[11] shr 8)] xor Fs_table_7
-    [Byte(Fm_state[10])];
-
-  Fm_temp[6] := Fs_table_0[Byte(Fm_state[5] shr 56)] xor Fs_table_1
-    [Byte(Fm_state[4] shr 48)] xor Fs_table_2[Byte(Fm_state[3] shr 40)
-    ] xor Fs_table_3[Byte(Fm_state[2] shr 32)] xor Fs_table_4
-    [Byte(Fm_state[1] shr 24)] xor Fs_table_5[Byte(Fm_state[0] shr 16)
-    ] xor Fs_table_6[Byte(Fm_state[12] shr 8)] xor Fs_table_7
-    [Byte(Fm_state[11])];
-
-  Fm_temp[7] := Fs_table_0[Byte(Fm_state[6] shr 56)] xor Fs_table_1
-    [Byte(Fm_state[5] shr 48)] xor Fs_table_2[Byte(Fm_state[4] shr 40)
-    ] xor Fs_table_3[Byte(Fm_state[3] shr 32)] xor Fs_table_4
-    [Byte(Fm_state[2] shr 24)] xor Fs_table_5[Byte(Fm_state[1] shr 16)
-    ] xor Fs_table_6[Byte(Fm_state[0] shr 8)] xor Fs_table_7
-    [Byte(Fm_state[12])];
-
-  Fm_temp[8] := Fs_table_0[Byte(Fm_state[7] shr 56)] xor Fs_table_1
-    [Byte(Fm_state[6] shr 48)] xor Fs_table_2[Byte(Fm_state[5] shr 40)
-    ] xor Fs_table_3[Byte(Fm_state[4] shr 32)] xor Fs_table_4
-    [Byte(Fm_state[3] shr 24)] xor Fs_table_5[Byte(Fm_state[2] shr 16)
-    ] xor Fs_table_6[Byte(Fm_state[1] shr 8)] xor Fs_table_7[Byte(Fm_state[0])];
-
-  Fm_temp[9] := Fs_table_0[Byte(Fm_state[8] shr 56)] xor Fs_table_1
-    [Byte(Fm_state[7] shr 48)] xor Fs_table_2[Byte(Fm_state[6] shr 40)
-    ] xor Fs_table_3[Byte(Fm_state[5] shr 32)] xor Fs_table_4
-    [Byte(Fm_state[4] shr 24)] xor Fs_table_5[Byte(Fm_state[3] shr 16)
-    ] xor Fs_table_6[Byte(Fm_state[2] shr 8)] xor Fs_table_7[Byte(Fm_state[1])];
-
-  Fm_temp[10] := Fs_table_0[Byte(Fm_state[9] shr 56)] xor Fs_table_1
-    [Byte(Fm_state[8] shr 48)] xor Fs_table_2[Byte(Fm_state[7] shr 40)
-    ] xor Fs_table_3[Byte(Fm_state[6] shr 32)] xor Fs_table_4
-    [Byte(Fm_state[5] shr 24)] xor Fs_table_5[Byte(Fm_state[4] shr 16)
-    ] xor Fs_table_6[Byte(Fm_state[3] shr 8)] xor Fs_table_7[Byte(Fm_state[2])];
-
-  Fm_temp[11] := Fs_table_0[Byte(Fm_state[10] shr 56)] xor Fs_table_1
-    [Byte(Fm_state[9] shr 48)] xor Fs_table_2[Byte(Fm_state[8] shr 40)
-    ] xor Fs_table_3[Byte(Fm_state[7] shr 32)] xor Fs_table_4
-    [Byte(Fm_state[6] shr 24)] xor Fs_table_5[Byte(Fm_state[5] shr 16)
-    ] xor Fs_table_6[Byte(Fm_state[4] shr 8)] xor Fs_table_7[Byte(Fm_state[3])];
-
-  Fm_temp[12] := Fs_table_0[Byte(Fm_state[11] shr 56)] xor Fs_table_1
-    [Byte(Fm_state[10] shr 48)] xor Fs_table_2[Byte(Fm_state[9] shr 40)
-    ] xor Fs_table_3[Byte(Fm_state[8] shr 32)] xor Fs_table_4
-    [Byte(Fm_state[7] shr 24)] xor Fs_table_5[Byte(Fm_state[6] shr 16)
-    ] xor Fs_table_6[Byte(Fm_state[5] shr 8)] xor Fs_table_7[Byte(Fm_state[4])];
-
-  u := Fm_temp;
-  Fm_temp := Fm_state;
-  Fm_state := u;
-
+  FTemp[1] := FSTable0[Byte(FState[0] shr 56)] xor FSTable1
+    [Byte(FState[12] shr 48)] xor FSTable2[Byte(FState[11] shr 40)] xor FSTable3
+    [Byte(FState[10] shr 32)] xor FSTable4[Byte(FState[9] shr 24)] xor FSTable5
+    [Byte(FState[8] shr 16)] xor FSTable6[Byte(FState[7] shr 8)] xor FSTable7
+    [Byte(FState[6])];
+
+  FTemp[2] := FSTable0[Byte(FState[1] shr 56)] xor FSTable1
+    [Byte(FState[0] shr 48)] xor FSTable2[Byte(FState[12] shr 40)] xor FSTable3
+    [Byte(FState[11] shr 32)] xor FSTable4[Byte(FState[10] shr 24)] xor FSTable5
+    [Byte(FState[9] shr 16)] xor FSTable6[Byte(FState[8] shr 8)] xor FSTable7
+    [Byte(FState[7])];
+
+  FTemp[3] := FSTable0[Byte(FState[2] shr 56)] xor FSTable1
+    [Byte(FState[1] shr 48)] xor FSTable2[Byte(FState[0] shr 40)] xor FSTable3
+    [Byte(FState[12] shr 32)] xor FSTable4[Byte(FState[11] shr 24)] xor FSTable5
+    [Byte(FState[10] shr 16)] xor FSTable6[Byte(FState[9] shr 8)] xor FSTable7
+    [Byte(FState[8])];
+
+  FTemp[4] := FSTable0[Byte(FState[3] shr 56)] xor FSTable1
+    [Byte(FState[2] shr 48)] xor FSTable2[Byte(FState[1] shr 40)] xor FSTable3
+    [Byte(FState[0] shr 32)] xor FSTable4[Byte(FState[12] shr 24)] xor FSTable5
+    [Byte(FState[11] shr 16)] xor FSTable6[Byte(FState[10] shr 8)] xor FSTable7
+    [Byte(FState[9])];
+
+  FTemp[5] := FSTable0[Byte(FState[4] shr 56)] xor FSTable1
+    [Byte(FState[3] shr 48)] xor FSTable2[Byte(FState[2] shr 40)] xor FSTable3
+    [Byte(FState[1] shr 32)] xor FSTable4[Byte(FState[0] shr 24)] xor FSTable5
+    [Byte(FState[12] shr 16)] xor FSTable6[Byte(FState[11] shr 8)] xor FSTable7
+    [Byte(FState[10])];
+
+  FTemp[6] := FSTable0[Byte(FState[5] shr 56)] xor FSTable1
+    [Byte(FState[4] shr 48)] xor FSTable2[Byte(FState[3] shr 40)] xor FSTable3
+    [Byte(FState[2] shr 32)] xor FSTable4[Byte(FState[1] shr 24)] xor FSTable5
+    [Byte(FState[0] shr 16)] xor FSTable6[Byte(FState[12] shr 8)] xor FSTable7
+    [Byte(FState[11])];
+
+  FTemp[7] := FSTable0[Byte(FState[6] shr 56)] xor FSTable1
+    [Byte(FState[5] shr 48)] xor FSTable2[Byte(FState[4] shr 40)] xor FSTable3
+    [Byte(FState[3] shr 32)] xor FSTable4[Byte(FState[2] shr 24)] xor FSTable5
+    [Byte(FState[1] shr 16)] xor FSTable6[Byte(FState[0] shr 8)] xor FSTable7
+    [Byte(FState[12])];
+
+  FTemp[8] := FSTable0[Byte(FState[7] shr 56)] xor FSTable1
+    [Byte(FState[6] shr 48)] xor FSTable2[Byte(FState[5] shr 40)] xor FSTable3
+    [Byte(FState[4] shr 32)] xor FSTable4[Byte(FState[3] shr 24)] xor FSTable5
+    [Byte(FState[2] shr 16)] xor FSTable6[Byte(FState[1] shr 8)] xor FSTable7
+    [Byte(FState[0])];
+
+  FTemp[9] := FSTable0[Byte(FState[8] shr 56)] xor FSTable1
+    [Byte(FState[7] shr 48)] xor FSTable2[Byte(FState[6] shr 40)] xor FSTable3
+    [Byte(FState[5] shr 32)] xor FSTable4[Byte(FState[4] shr 24)] xor FSTable5
+    [Byte(FState[3] shr 16)] xor FSTable6[Byte(FState[2] shr 8)] xor FSTable7
+    [Byte(FState[1])];
+
+  FTemp[10] := FSTable0[Byte(FState[9] shr 56)] xor FSTable1
+    [Byte(FState[8] shr 48)] xor FSTable2[Byte(FState[7] shr 40)] xor FSTable3
+    [Byte(FState[6] shr 32)] xor FSTable4[Byte(FState[5] shr 24)] xor FSTable5
+    [Byte(FState[4] shr 16)] xor FSTable6[Byte(FState[3] shr 8)] xor FSTable7
+    [Byte(FState[2])];
+
+  FTemp[11] := FSTable0[Byte(FState[10] shr 56)] xor FSTable1
+    [Byte(FState[9] shr 48)] xor FSTable2[Byte(FState[8] shr 40)] xor FSTable3
+    [Byte(FState[7] shr 32)] xor FSTable4[Byte(FState[6] shr 24)] xor FSTable5
+    [Byte(FState[5] shr 16)] xor FSTable6[Byte(FState[4] shr 8)] xor FSTable7
+    [Byte(FState[3])];
+
+  FTemp[12] := FSTable0[Byte(FState[11] shr 56)] xor FSTable1
+    [Byte(FState[10] shr 48)] xor FSTable2[Byte(FState[9] shr 40)] xor FSTable3
+    [Byte(FState[8] shr 32)] xor FSTable4[Byte(FState[7] shr 24)] xor FSTable5
+    [Byte(FState[6] shr 16)] xor FSTable6[Byte(FState[5] shr 8)] xor FSTable7
+    [Byte(FState[4])];
+
+  LU := FTemp;
+  FTemp := FState;
+  FState := LU;
 end;
 
-procedure TGrindahl512.TransformBlock(a_data: PByte; a_data_length: Int32;
-  a_index: Int32);
+procedure TGrindahl512.TransformBlock(AData: PByte; ADataLength: Int32;
+  AIndex: Int32);
 begin
-
-  Fm_state[0] := TConverters.ReadBytesAsUInt64LE(a_data, a_index);
-
-  Fm_state[0] := TConverters.be2me_64(Fm_state[0]);
-
+  FState[0] := TConverters.ReadBytesAsUInt64LE(AData, AIndex);
+  FState[0] := TConverters.be2me_64(FState[0]);
   InjectMsg(false);
-
 end;
 
 end.

+ 89 - 92
src/libraries/hashlib4pascal/HlpHAS160.pas

@@ -23,20 +23,19 @@ type
   THAS160 = class sealed(TBlockHash, ICryptoNotBuildIn, ITransformBlock)
 
   strict private
-
-    Fm_hash: THashLibUInt32Array;
+  var
+    FHash: THashLibUInt32Array;
 
 {$REGION 'Consts'}
 
   const
-
-    s_rot: array [0 .. 19] of Int32 = (5, 11, 7, 15, 6, 13, 8, 14, 7, 12, 9, 11,
+    SRot: array [0 .. 19] of Int32 = (5, 11, 7, 15, 6, 13, 8, 14, 7, 12, 9, 11,
       8, 15, 6, 12, 9, 14, 5, 13);
 
-    s_tor: array [0 .. 19] of Int32 = (27, 21, 25, 17, 26, 19, 24, 18, 25, 20,
+    Stor: array [0 .. 19] of Int32 = (27, 21, 25, 17, 26, 19, 24, 18, 25, 20,
       23, 21, 24, 17, 26, 20, 23, 18, 27, 19);
 
-    s_index: array [0 .. 79] of Int32 = (18, 0, 1, 2, 3, 19, 4, 5, 6, 7, 16, 8,
+    SIndex: array [0 .. 79] of Int32 = (18, 0, 1, 2, 3, 19, 4, 5, 6, 7, 16, 8,
       9, 10, 11, 17, 12, 13, 14, 15, 18, 3, 6, 9, 12, 19, 15, 2, 5, 8, 16, 11,
       14, 1, 4, 17, 7, 10, 13, 0, 18, 12, 5, 14, 7, 19, 0, 9, 2, 11, 16, 4, 13,
       6, 15, 17, 8, 1, 10, 3, 18, 7, 2, 13, 8, 19, 3, 14, 9, 4, 16, 15, 10, 5,
@@ -46,8 +45,8 @@ type
   strict protected
     procedure Finish(); override;
     function GetResult(): THashLibByteArray; override;
-    procedure TransformBlock(a_data: PByte; a_data_length: Int32;
-      a_index: Int32); override;
+    procedure TransformBlock(AData: PByte; ADataLength: Int32;
+      AIndex: Int32); override;
 
   public
     constructor Create();
@@ -61,164 +60,162 @@ implementation
 
 function THAS160.Clone(): IHash;
 var
-  HashInstance: THAS160;
+  LHashInstance: THAS160;
 begin
-  HashInstance := THAS160.Create();
-  HashInstance.Fm_hash := System.Copy(Fm_hash);
-  HashInstance.Fm_buffer := Fm_buffer.Clone();
-  HashInstance.Fm_processed_bytes := Fm_processed_bytes;
-  result := HashInstance as IHash;
+  LHashInstance := THAS160.Create();
+  LHashInstance.FHash := System.Copy(FHash);
+  LHashInstance.FBuffer := FBuffer.Clone();
+  LHashInstance.FProcessedBytesCount := FProcessedBytesCount;
+  result := LHashInstance as IHash;
   result.BufferSize := BufferSize;
 end;
 
 constructor THAS160.Create;
 begin
   Inherited Create(20, 64);
-  System.SetLength(Fm_hash, 5);
+  System.SetLength(FHash, 5);
 end;
 
 procedure THAS160.Finish;
 var
-  pad_index: Int32;
-  bits: UInt64;
-  pad: THashLibByteArray;
+  LPadIndex: Int32;
+  LBits: UInt64;
+  LPad: THashLibByteArray;
 begin
-  bits := Fm_processed_bytes * 8;
-  if (Fm_buffer.Pos < 56) then
-    pad_index := (56 - Fm_buffer.Pos)
+  LBits := FProcessedBytesCount * 8;
+  if (FBuffer.Position < 56) then
+  begin
+    LPadIndex := (56 - FBuffer.Position)
+  end
   else
-    pad_index := (120 - Fm_buffer.Pos);
-
-  System.SetLength(pad, pad_index + 8);
+  begin
+    LPadIndex := (120 - FBuffer.Position);
+  end;
 
-  pad[0] := $80;
+  System.SetLength(LPad, LPadIndex + 8);
 
-  bits := TConverters.le2me_64(bits);
+  LPad[0] := $80;
 
-  TConverters.ReadUInt64AsBytesLE(bits, pad, pad_index);
+  LBits := TConverters.le2me_64(LBits);
 
-  pad_index := pad_index + 8;
+  TConverters.ReadUInt64AsBytesLE(LBits, LPad, LPadIndex);
 
-  TransformBytes(pad, 0, pad_index);
+  LPadIndex := LPadIndex + 8;
 
+  TransformBytes(LPad, 0, LPadIndex);
 end;
 
 function THAS160.GetResult: THashLibByteArray;
 begin
-
   System.SetLength(result, 5 * System.SizeOf(UInt32));
-
-  TConverters.le32_copy(PCardinal(Fm_hash), 0, PByte(result), 0,
+  TConverters.le32_copy(PCardinal(FHash), 0, PByte(result), 0,
     System.Length(result));
-
 end;
 
 procedure THAS160.Initialize;
 begin
-  Fm_hash[0] := $67452301;
-  Fm_hash[1] := $EFCDAB89;
-  Fm_hash[2] := $98BADCFE;
-  Fm_hash[3] := $10325476;
-  Fm_hash[4] := $C3D2E1F0;
-
+  FHash[0] := $67452301;
+  FHash[1] := $EFCDAB89;
+  FHash[2] := $98BADCFE;
+  FHash[3] := $10325476;
+  FHash[4] := $C3D2E1F0;
   Inherited Initialize();
 end;
 
-procedure THAS160.TransformBlock(a_data: PByte; a_data_length: Int32;
-  a_index: Int32);
+procedure THAS160.TransformBlock(AData: PByte; ADataLength: Int32;
+  AIndex: Int32);
 var
   A, B, C, D, E, T: UInt32;
-  r: Int32;
-  data: array [0 .. 19] of UInt32;
+  R: Int32;
+  LData: array [0 .. 19] of UInt32;
 begin
-  A := Fm_hash[0];
-  B := Fm_hash[1];
-  C := Fm_hash[2];
-  D := Fm_hash[3];
-  E := Fm_hash[4];
+  A := FHash[0];
+  B := FHash[1];
+  C := FHash[2];
+  D := FHash[3];
+  E := FHash[4];
 
-  TConverters.le32_copy(a_data, a_index, @(data[0]), 0, a_data_length);
+  TConverters.le32_copy(AData, AIndex, @(LData[0]), 0, ADataLength);
 
-  data[16] := data[0] xor data[1] xor data[2] xor data[3];
-  data[17] := data[4] xor data[5] xor data[6] xor data[7];
-  data[18] := data[8] xor data[9] xor data[10] xor data[11];
-  data[19] := data[12] xor data[13] xor data[14] xor data[15];
+  LData[16] := LData[0] xor LData[1] xor LData[2] xor LData[3];
+  LData[17] := LData[4] xor LData[5] xor LData[6] xor LData[7];
+  LData[18] := LData[8] xor LData[9] xor LData[10] xor LData[11];
+  LData[19] := LData[12] xor LData[13] xor LData[14] xor LData[15];
 
-  r := 0;
-  while r < 20 do
+  R := 0;
+  while R < 20 do
   begin
-    T := data[s_index[r]] + (A shl s_rot[r] or A shr s_tor[r]) +
+    T := LData[SIndex[R]] + (A shl SRot[R] or A shr Stor[R]) +
       ((B and C) or (not B and D)) + E;
     E := D;
     D := C;
     C := B shl 10 or B shr 22;
     B := A;
     A := T;
-    System.Inc(r);
+    System.Inc(R);
   end;
 
-  data[16] := data[3] xor data[6] xor data[9] xor data[12];
-  data[17] := data[2] xor data[5] xor data[8] xor data[15];
-  data[18] := data[1] xor data[4] xor data[11] xor data[14];
-  data[19] := data[0] xor data[7] xor data[10] xor data[13];
+  LData[16] := LData[3] xor LData[6] xor LData[9] xor LData[12];
+  LData[17] := LData[2] xor LData[5] xor LData[8] xor LData[15];
+  LData[18] := LData[1] xor LData[4] xor LData[11] xor LData[14];
+  LData[19] := LData[0] xor LData[7] xor LData[10] xor LData[13];
 
-  r := 20;
-  while r < 40 do
+  R := 20;
+  while R < 40 do
   begin
-    T := data[s_index[r]] + $5A827999 +
-      (A shl s_rot[r - 20] or A shr s_tor[r - 20]) + (B xor C xor D) + E;
+    T := LData[SIndex[R]] + $5A827999 +
+      (A shl SRot[R - 20] or A shr Stor[R - 20]) + (B xor C xor D) + E;
     E := D;
     D := C;
     C := B shl 17 or B shr 15;
     B := A;
     A := T;
-    System.Inc(r);
+    System.Inc(R);
   end;
 
-  data[16] := data[5] xor data[7] xor data[12] xor data[14];
-  data[17] := data[0] xor data[2] xor data[9] xor data[11];
-  data[18] := data[4] xor data[6] xor data[13] xor data[15];
-  data[19] := data[1] xor data[3] xor data[8] xor data[10];
+  LData[16] := LData[5] xor LData[7] xor LData[12] xor LData[14];
+  LData[17] := LData[0] xor LData[2] xor LData[9] xor LData[11];
+  LData[18] := LData[4] xor LData[6] xor LData[13] xor LData[15];
+  LData[19] := LData[1] xor LData[3] xor LData[8] xor LData[10];
 
-  r := 40;
-  while r < 60 do
+  R := 40;
+  while R < 60 do
   begin
-    T := data[s_index[r]] + $6ED9EBA1 +
-      (A shl s_rot[r - 40] or A shr s_tor[r - 40]) + (C xor (B or not D)) + E;
+    T := LData[SIndex[R]] + $6ED9EBA1 +
+      (A shl SRot[R - 40] or A shr Stor[R - 40]) + (C xor (B or not D)) + E;
     E := D;
     D := C;
     C := B shl 25 or B shr 7;
     B := A;
     A := T;
-    System.Inc(r);
+    System.Inc(R);
   end;
 
-  data[16] := data[2] xor data[7] xor data[8] xor data[13];
-  data[17] := data[3] xor data[4] xor data[9] xor data[14];
-  data[18] := data[0] xor data[5] xor data[10] xor data[15];
-  data[19] := data[1] xor data[6] xor data[11] xor data[12];
+  LData[16] := LData[2] xor LData[7] xor LData[8] xor LData[13];
+  LData[17] := LData[3] xor LData[4] xor LData[9] xor LData[14];
+  LData[18] := LData[0] xor LData[5] xor LData[10] xor LData[15];
+  LData[19] := LData[1] xor LData[6] xor LData[11] xor LData[12];
 
-  r := 60;
-  while r < 80 do
+  R := 60;
+  while R < 80 do
   begin
-    T := data[s_index[r]] + $8F1BBCDC +
-      (A shl s_rot[r - 60] or A shr s_tor[r - 60]) + (B xor C xor D) + E;
+    T := LData[SIndex[R]] + $8F1BBCDC +
+      (A shl SRot[R - 60] or A shr Stor[R - 60]) + (B xor C xor D) + E;
     E := D;
     D := C;
-    C := B shl 30 or B shr 2;
+    C := (B shl 30) or (B shr 2);
     B := A;
     A := T;
-    System.Inc(r);
+    System.Inc(R);
   end;
 
-  Fm_hash[0] := Fm_hash[0] + A;
-  Fm_hash[1] := Fm_hash[1] + B;
-  Fm_hash[2] := Fm_hash[2] + C;
-  Fm_hash[3] := Fm_hash[3] + D;
-  Fm_hash[4] := Fm_hash[4] + E;
-
-  System.FillChar(data, System.SizeOf(data), UInt32(0));
+  FHash[0] := FHash[0] + A;
+  FHash[1] := FHash[1] + B;
+  FHash[2] := FHash[2] + C;
+  FHash[3] := FHash[3] + D;
+  FHash[4] := FHash[4] + E;
 
+  System.FillChar(LData, System.SizeOf(LData), UInt32(0));
 end;
 
 end.

+ 54 - 66
src/libraries/hashlib4pascal/HlpHMACNotBuildInAdapter.pas

@@ -5,11 +5,7 @@ unit HlpHMACNotBuildInAdapter;
 interface
 
 uses
-{$IFDEF HAS_UNITSCOPE}
-  System.SysUtils,
-{$ELSE}
   SysUtils,
-{$ENDIF HAS_UNITSCOPE}
   HlpHashLibTypes,
   HlpHash,
   HlpIHash,
@@ -24,10 +20,9 @@ type
     ICrypto, ICryptoNotBuildIn)
 
   strict private
-
-    Fm_hash: IHash;
-    Fm_opad, Fm_ipad, Fm_key: THashLibByteArray;
-    Fm_blocksize: Int32;
+  var
+    FHash: IHash;
+    FOpad, FIpad, FKey: THashLibByteArray;
 
   strict protected
 
@@ -35,13 +30,13 @@ type
 
     function GetKey(): THashLibByteArray;
     function GetKeyLength(): TNullableInteger;
-    procedure SetKey(const value: THashLibByteArray);
+    procedure SetKey(const AValue: THashLibByteArray);
     procedure UpdatePads();
 
   public
 
-    constructor Create(const a_underlyingHash: IHash;
-      const a_hmacKey: THashLibByteArray = Nil);
+    constructor Create(const AUnderlyingHash: IHash;
+      const AHMACKey: THashLibByteArray = Nil);
 
     destructor Destroy; override;
 
@@ -49,15 +44,15 @@ type
 
     procedure Initialize(); override;
     function TransformFinal(): IHashResult; override;
-    procedure TransformBytes(const a_data: THashLibByteArray;
-      a_index, a_length: Int32); override;
+    procedure TransformBytes(const AData: THashLibByteArray;
+      AIndex, ALength: Int32); override;
     function Clone(): IHash; override;
     property Key: THashLibByteArray read GetKey write SetKey;
     property Name: String read GetName;
     property KeyLength: TNullableInteger read GetKeyLength;
 
-    class function CreateHMAC(const a_hash: IHash;
-      const a_hmacKey: THashLibByteArray): IHMAC; static;
+    class function CreateHMAC(const AHash: IHash;
+      const AHMACKey: THashLibByteArray): IHMAC; static;
 
   end;
 
@@ -67,30 +62,28 @@ implementation
 
 procedure THMACNotBuildInAdapter.Clear();
 begin
-  TArrayUtils.ZeroFill(Fm_key);
+  TArrayUtils.ZeroFill(FKey);
 end;
 
 function THMACNotBuildInAdapter.Clone(): IHash;
 var
   HmacInstance: THMACNotBuildInAdapter;
 begin
-  HmacInstance := THMACNotBuildInAdapter.Create(Fm_hash.Clone(), Fm_key);
-  HmacInstance.Fm_opad := System.Copy(Fm_opad);
-  HmacInstance.Fm_ipad := System.Copy(Fm_ipad);
-  HmacInstance.Fm_blocksize := Fm_blocksize;
+  HmacInstance := THMACNotBuildInAdapter.Create(FHash.Clone(), FKey);
+  HmacInstance.FOpad := System.Copy(FOpad);
+  HmacInstance.FIpad := System.Copy(FIpad);
   result := HmacInstance as IHash;
   result.BufferSize := BufferSize;
 end;
 
-constructor THMACNotBuildInAdapter.Create(const a_underlyingHash: IHash;
-  const a_hmacKey: THashLibByteArray);
+constructor THMACNotBuildInAdapter.Create(const AUnderlyingHash: IHash;
+  const AHMACKey: THashLibByteArray);
 begin
-  Inherited Create(a_underlyingHash.HashSize, a_underlyingHash.BlockSize);
-  Fm_hash := a_underlyingHash;
-  Fm_blocksize := Fm_hash.BlockSize;
-  SetKey(a_hmacKey);
-  System.SetLength(Fm_ipad, Fm_blocksize);
-  System.SetLength(Fm_opad, Fm_blocksize);
+  Inherited Create(AUnderlyingHash.HashSize, AUnderlyingHash.BlockSize);
+  FHash := AUnderlyingHash;
+  SetKey(AHMACKey);
+  System.SetLength(FIpad, FHash.BlockSize);
+  System.SetLength(FOpad, FHash.BlockSize);
 end;
 
 destructor THMACNotBuildInAdapter.Destroy;
@@ -101,7 +94,7 @@ end;
 
 function THMACNotBuildInAdapter.GetKey: THashLibByteArray;
 begin
-  result := System.Copy(Fm_key);
+  result := System.Copy(FKey);
 end;
 
 function THMACNotBuildInAdapter.GetKeyLength: TNullableInteger;
@@ -109,94 +102,89 @@ begin
   result := Nil;
 end;
 
-procedure THMACNotBuildInAdapter.SetKey(const value: THashLibByteArray);
+procedure THMACNotBuildInAdapter.SetKey(const AValue: THashLibByteArray);
 begin
-  if (value = Nil) then
+  if (AValue = Nil) then
   begin
-    System.SetLength(Fm_key, 0);
+    FKey := Nil;
   end
   else
   begin
-    Fm_key := System.Copy(value);
+    FKey := System.Copy(AValue);
   end;
 end;
 
 procedure THMACNotBuildInAdapter.UpdatePads;
 var
   LKey: THashLibByteArray;
-  Idx, LBlockSize: Int32;
+  LIdx, LBlockSize: Int32;
 begin
-  LBlockSize := Fm_blocksize;
+  LBlockSize := FHash.BlockSize;
   if (System.Length(Key) > LBlockSize) then
   begin
-    LKey := Fm_hash.ComputeBytes(Key).GetBytes();
+    LKey := FHash.ComputeBytes(Key).GetBytes();
   end
   else
   begin
     LKey := Key;
   end;
 
-  TArrayUtils.Fill(Fm_ipad, 0, LBlockSize, Byte($36));
-  TArrayUtils.Fill(Fm_opad, 0, LBlockSize, Byte($5C));
+  TArrayUtils.Fill(FIpad, 0, LBlockSize, Byte($36));
+  TArrayUtils.Fill(FOpad, 0, LBlockSize, Byte($5C));
 
-  Idx := 0;
-  while (Idx < System.Length(LKey)) and (Idx < LBlockSize) do
+  LIdx := 0;
+  while (LIdx < System.Length(LKey)) and (LIdx < LBlockSize) do
   begin
-    Fm_ipad[Idx] := Fm_ipad[Idx] xor LKey[Idx];
-    Fm_opad[Idx] := Fm_opad[Idx] xor LKey[Idx];
-    System.Inc(Idx);
+    FIpad[LIdx] := FIpad[LIdx] xor LKey[LIdx];
+    FOpad[LIdx] := FOpad[LIdx] xor LKey[LIdx];
+    System.Inc(LIdx);
   end;
 
 end;
 
 procedure THMACNotBuildInAdapter.Initialize;
 begin
-  Fm_hash.Initialize();
+  FHash.Initialize();
   UpdatePads();
-  Fm_hash.TransformBytes(Fm_ipad);
+  FHash.TransformBytes(FIpad);
 end;
 
 function THMACNotBuildInAdapter.TransformFinal: IHashResult;
 begin
-  result := Fm_hash.TransformFinal();
-  Fm_hash.TransformBytes(Fm_opad);
-  Fm_hash.TransformBytes(result.GetBytes());
-  result := Fm_hash.TransformFinal();
+  result := FHash.TransformFinal();
+  FHash.TransformBytes(FOpad);
+  FHash.TransformBytes(result.GetBytes());
+  result := FHash.TransformFinal();
   Initialize();
-
 end;
 
-procedure THMACNotBuildInAdapter.TransformBytes(const a_data: THashLibByteArray;
-  a_index, a_length: Int32);
+procedure THMACNotBuildInAdapter.TransformBytes(const AData: THashLibByteArray;
+  AIndex, ALength: Int32);
 begin
 {$IFDEF DEBUG}
-  System.Assert(a_index >= 0);
-  System.Assert(a_length >= 0);
-  System.Assert(a_index + a_length <= System.Length(a_data));
+  System.Assert(AIndex >= 0);
+  System.Assert(ALength >= 0);
+  System.Assert(AIndex + ALength <= System.Length(AData));
 {$ENDIF}
-  Fm_hash.TransformBytes(a_data, a_index, a_length);
+  FHash.TransformBytes(AData, AIndex, ALength);
 end;
 
 function THMACNotBuildInAdapter.GetName: String;
 begin
-  result := Format('%s(%s)', ['THMAC', Fm_hash.Name]);
+  result := Format('%s(%s)', ['THMAC', FHash.Name]);
 end;
 
-class function THMACNotBuildInAdapter.CreateHMAC(const a_hash: IHash;
-  const a_hmacKey: THashLibByteArray): IHMAC;
+class function THMACNotBuildInAdapter.CreateHMAC(const AHash: IHash;
+  const AHMACKey: THashLibByteArray): IHMAC;
 begin
-
-  if Supports(a_hash, IHMAC) then
+  if Supports(AHash, IHMAC) then
   begin
-    result := (a_hash) as IHMAC;
-    Exit;
+    result := AHash as IHMAC;
   end
   else
   begin
-    result := THMACNotBuildInAdapter.Create(a_hash, a_hmacKey);
-    Exit;
+    result := THMACNotBuildInAdapter.Create(AHash, AHMACKey);
   end;
-
 end;
 
 end.

+ 116 - 127
src/libraries/hashlib4pascal/HlpHash.pas

@@ -1,17 +1,12 @@
 unit HlpHash;
 
-{$I HashLib.inc}
+{$I ..\Include\HashLib.inc}
 
 interface
 
 uses
-{$IFDEF HAS_UNITSCOPE}
-  System.Classes,
-  System.SysUtils,
-{$ELSE}
   Classes,
   SysUtils,
-{$ENDIF HAS_UNITSCOPE}
   HlpHashLibTypes,
   HlpConverters,
   HlpIHash,
@@ -28,8 +23,8 @@ type
   THash = class abstract(TInterfacedObject, IHash)
 
   strict private
-
-    Fm_buffer_size, Fm_block_size, Fm_hash_size: Int32;
+  var
+    FBufferSize, FBlockSize, FHashSize: Int32;
 
   const
     BUFFER_SIZE = Int32(64 * 1024); // 64Kb
@@ -37,47 +32,49 @@ type
   strict protected
 
     function GetBlockSize: Int32; virtual;
-    procedure SetBlockSize(value: Int32); virtual;
+    procedure SetBlockSize(AValue: Int32); virtual;
 
     function GetHashSize: Int32; virtual;
-    procedure SetHashSize(value: Int32); virtual;
+    procedure SetHashSize(AValue: Int32); virtual;
 
     function GetBufferSize: Int32; inline;
-    procedure SetBufferSize(value: Int32); inline;
+    procedure SetBufferSize(AValue: Int32); inline;
 
     function GetName: String; virtual;
 
   public
 
-    constructor Create(a_hash_size, a_block_size: Int32);
-    property Name: String read GetName;
-    property BlockSize: Int32 read GetBlockSize write SetBlockSize;
-    property HashSize: Int32 read GetHashSize write SetHashSize;
-    function ComputeString(const a_data: String; a_encoding: TEncoding)
-      : IHashResult; virtual;
-    function ComputeBytes(const a_data: THashLibByteArray)
-      : IHashResult; virtual;
-    function ComputeUntyped(const a_data; a_length: Int64): IHashResult;
-    function ComputeStream(const a_stream: TStream; a_length: Int64 = -1)
-      : IHashResult;
-    function ComputeFile(const a_file_name: String; a_from: Int64 = 0;
-      a_length: Int64 = -1): IHashResult;
-    procedure TransformString(const a_data: String;
-      const a_encoding: TEncoding);
-    procedure TransformBytes(const a_data: THashLibByteArray); overload;
-    procedure TransformBytes(const a_data: THashLibByteArray;
-      a_index: Int32); overload;
-    procedure TransformBytes(const a_data: THashLibByteArray; a_index: Int32;
-      a_length: Int32); overload; virtual; abstract;
-    procedure TransformUntyped(const a_data; a_length: Int64);
-    procedure TransformStream(const a_stream: TStream; a_length: Int64 = -1);
-    procedure TransformFile(const a_file_name: String; a_from: Int64 = 0;
-      a_length: Int64 = -1);
+    constructor Create(AHashSize, ABlockSize: Int32);
+
     procedure Initialize(); virtual; abstract;
+
+    procedure TransformString(const AData: String; const AEncoding: TEncoding);
+    procedure TransformBytes(const AData: THashLibByteArray); overload;
+    procedure TransformBytes(const AData: THashLibByteArray;
+      AIndex: Int32); overload;
+    procedure TransformBytes(const AData: THashLibByteArray; AIndex: Int32;
+      ALength: Int32); overload; virtual; abstract;
+    procedure TransformUntyped(const AData; ALength: Int64);
+    procedure TransformStream(const AStream: TStream; ALength: Int64 = -1);
+    procedure TransformFile(const AFileName: String; AFrom: Int64 = 0;
+      ALength: Int64 = -1);
+
     function TransformFinal(): IHashResult; virtual; abstract;
 
+    function ComputeString(const AData: String; AEncoding: TEncoding)
+      : IHashResult; virtual;
+    function ComputeBytes(const AData: THashLibByteArray): IHashResult; virtual;
+    function ComputeUntyped(const AData; ALength: Int64): IHashResult;
+    function ComputeStream(const AStream: TStream; ALength: Int64 = -1)
+      : IHashResult;
+    function ComputeFile(const AFileName: String; AFrom: Int64 = 0;
+      ALength: Int64 = -1): IHashResult;
+
     function Clone(): IHash; virtual;
 
+    property Name: String read GetName;
+    property BlockSize: Int32 read GetBlockSize write SetBlockSize;
+    property HashSize: Int32 read GetHashSize write SetHashSize;
     property BufferSize: Int32 read GetBufferSize write SetBufferSize;
   end;
 
@@ -85,16 +82,16 @@ implementation
 
 { THash }
 
-constructor THash.Create(a_hash_size, a_block_size: Int32);
+constructor THash.Create(AHashSize, ABlockSize: Int32);
 begin
   Inherited Create();
 {$IFDEF DEBUG}
-  System.Assert((a_block_size > 0) or (a_block_size = -1));
-  System.Assert((a_hash_size > 0) or (a_hash_size = -1));
+  System.Assert((ABlockSize > 0) or (ABlockSize = -1));
+  System.Assert((AHashSize > 0) or (AHashSize = -1));
 {$ENDIF DEBUG}
-  Fm_block_size := a_block_size;
-  Fm_hash_size := a_hash_size;
-  Fm_buffer_size := BUFFER_SIZE;
+  FBlockSize := ABlockSize;
+  FHashSize := AHashSize;
+  FBufferSize := BUFFER_SIZE;
 end;
 
 function THash.GetName: String;
@@ -104,14 +101,14 @@ end;
 
 function THash.GetBufferSize: Int32;
 begin
-  result := Fm_buffer_size;
+  result := FBufferSize;
 end;
 
-procedure THash.SetBufferSize(value: Int32);
+procedure THash.SetBufferSize(AValue: Int32);
 begin
-  if value > 0 then
+  if AValue > 0 then
   begin
-    Fm_buffer_size := value;
+    FBufferSize := AValue;
   end
   else
   begin
@@ -121,49 +118,46 @@ end;
 
 function THash.GetBlockSize: Int32;
 begin
-  result := Fm_block_size;
+  result := FBlockSize;
 end;
 
-procedure THash.SetBlockSize(value: Int32);
+procedure THash.SetBlockSize(AValue: Int32);
 begin
-  Fm_block_size := value;
+  FBlockSize := AValue;
 end;
 
 function THash.GetHashSize: Int32;
 begin
-  result := Fm_hash_size;
+  result := FHashSize;
 end;
 
-procedure THash.SetHashSize(value: Int32);
+procedure THash.SetHashSize(AValue: Int32);
 begin
-  Fm_hash_size := value;
+  FHashSize := AValue;
 end;
 
-function THash.ComputeString(const a_data: String; a_encoding: TEncoding)
+function THash.ComputeString(const AData: String; AEncoding: TEncoding)
   : IHashResult;
 begin
-  result := ComputeBytes(TConverters.ConvertStringToBytes(a_data, a_encoding));
+  result := ComputeBytes(TConverters.ConvertStringToBytes(AData, AEncoding));
 end;
 
-function THash.ComputeUntyped(const a_data; a_length: Int64): IHashResult;
-
+function THash.ComputeUntyped(const AData; ALength: Int64): IHashResult;
 begin
-
   Initialize();
-  TransformUntyped(a_data, a_length);
+  TransformUntyped(AData, ALength);
   result := TransformFinal();
-
 end;
 
-procedure THash.TransformUntyped(const a_data; a_length: Int64);
+procedure THash.TransformUntyped(const AData; ALength: Int64);
 var
-  PtrBuffer, PtrEnd: PByte;
-  ArrBuffer: THashLibByteArray;
+  LPtrStart, LPtrEnd: PByte;
+  LBuffer: THashLibByteArray;
   LBufferSize: Int32;
 begin
-  PtrBuffer := @a_data;
+  LPtrStart := @AData;
 
-  if BufferSize > a_length then // Sanity Check
+  if BufferSize > ALength then // Sanity Check
   begin
     LBufferSize := BUFFER_SIZE;
   end
@@ -172,25 +166,25 @@ begin
     LBufferSize := BufferSize;
   end;
 
-  if PtrBuffer <> Nil then
+  if LPtrStart <> Nil then
   begin
-    System.SetLength(ArrBuffer, LBufferSize);
-    PtrEnd := (PtrBuffer) + a_length;
+    System.SetLength(LBuffer, LBufferSize);
+    LPtrEnd := LPtrStart + ALength;
 
-    while PtrBuffer < PtrEnd do
+    while LPtrStart < LPtrEnd do
     begin
 
-      if (PtrEnd - PtrBuffer) >= LBufferSize then
+      if (LPtrEnd - LPtrStart) >= LBufferSize then
       begin
-        System.Move(PtrBuffer^, ArrBuffer[0], LBufferSize);
-        TransformBytes(ArrBuffer);
-        System.Inc(PtrBuffer, LBufferSize);
+        System.Move(LPtrStart^, LBuffer[0], LBufferSize);
+        TransformBytes(LBuffer);
+        System.Inc(LPtrStart, LBufferSize);
       end
       else
       begin
-        System.SetLength(ArrBuffer, PtrEnd - PtrBuffer);
-        System.Move(PtrBuffer^, ArrBuffer[0], System.Length(ArrBuffer));
-        TransformBytes(ArrBuffer);
+        System.SetLength(LBuffer, LPtrEnd - LPtrStart);
+        System.Move(LPtrStart^, LBuffer[0], System.Length(LBuffer));
+        TransformBytes(LBuffer);
         break;
       end;
 
@@ -199,22 +193,20 @@ begin
   end;
 end;
 
-function THash.ComputeStream(const a_stream: TStream; a_length: Int64)
+function THash.ComputeStream(const AStream: TStream; ALength: Int64)
   : IHashResult;
 begin
   Initialize();
-  TransformStream(a_stream, a_length);
+  TransformStream(AStream, ALength);
   result := TransformFinal();
-
 end;
 
-function THash.ComputeFile(const a_file_name: String; a_from, a_length: Int64)
+function THash.ComputeFile(const AFileName: String; AFrom, ALength: Int64)
   : IHashResult;
 begin
   Initialize();
-  TransformFile(a_file_name, a_from, a_length);
+  TransformFile(AFileName, AFrom, ALength);
   result := TransformFinal();
-
 end;
 
 function THash.Clone(): IHash;
@@ -223,61 +215,60 @@ begin
     (@SCloneNotYetImplemented, [Name]);
 end;
 
-function THash.ComputeBytes(const a_data: THashLibByteArray): IHashResult;
+function THash.ComputeBytes(const AData: THashLibByteArray): IHashResult;
 begin
   Initialize();
-  TransformBytes(a_data);
+  TransformBytes(AData);
   result := TransformFinal();
-
 end;
 
-procedure THash.TransformString(const a_data: String;
-  const a_encoding: TEncoding);
+procedure THash.TransformString(const AData: String;
+  const AEncoding: TEncoding);
 begin
-  TransformBytes(TConverters.ConvertStringToBytes(a_data, a_encoding));
+  TransformBytes(TConverters.ConvertStringToBytes(AData, AEncoding));
 end;
 
-procedure THash.TransformBytes(const a_data: THashLibByteArray);
+procedure THash.TransformBytes(const AData: THashLibByteArray);
 begin
-  TransformBytes(a_data, 0, System.Length(a_data));
+  TransformBytes(AData, 0, System.Length(AData));
 end;
 
-procedure THash.TransformBytes(const a_data: THashLibByteArray; a_index: Int32);
+procedure THash.TransformBytes(const AData: THashLibByteArray; AIndex: Int32);
 var
-  &Length: Int32;
+  LLength: Int32;
 begin
 {$IFDEF DEBUG}
-  System.Assert(a_index >= 0);
+  System.Assert(AIndex >= 0);
 {$ENDIF DEBUG}
-  Length := System.Length(a_data) - a_index;
+  LLength := System.Length(AData) - AIndex;
 
 {$IFDEF DEBUG}
-  System.Assert(Length >= 0);
+  System.Assert(LLength >= 0);
 {$ENDIF DEBUG}
-  TransformBytes(a_data, a_index, Length);
+  TransformBytes(AData, AIndex, LLength);
 end;
 
-procedure THash.TransformStream(const a_stream: TStream; a_length: Int64);
+procedure THash.TransformStream(const AStream: TStream; ALength: Int64);
 var
-  data: THashLibByteArray;
-  readed, LBufferSize: Int32;
-  total: Int64;
+  LData: THashLibByteArray;
+  LRead, LBufferSize: Int32;
+  LTotal: Int64;
 begin
 {$IFDEF DEBUG}
-  System.Assert((a_length = -1) or (a_length > 0));
+  System.Assert((ALength = -1) or (ALength > 0));
 {$ENDIF DEBUG}
-  total := 0;
-  if (a_stream <> Nil) then
+  LTotal := 0;
+  if (AStream <> Nil) then
   begin
-    if (a_length > -1) then
+    if (ALength > -1) then
     begin
-      if ((a_stream.Position + a_length) > a_stream.Size) then
+      if ((AStream.Position + ALength) > AStream.Size) then
       begin
         raise EIndexOutOfRangeHashLibException.CreateRes(@SIndexOutOfRange);
       end;
     end;
 
-    if (a_stream.Position >= a_stream.Size) then
+    if (AStream.Position >= AStream.Size) then
     begin
       Exit;
     end;
@@ -287,7 +278,7 @@ begin
     raise EArgumentNilHashLibException.CreateRes(@SUnAssignedStream);
   end;
 
-  if BufferSize > a_stream.Size then // Sanity Check
+  if BufferSize > AStream.Size then // Sanity Check
   begin
     LBufferSize := BUFFER_SIZE;
   end
@@ -296,24 +287,24 @@ begin
     LBufferSize := BufferSize;
   end;
 
-  System.SetLength(data, LBufferSize);
+  System.SetLength(LData, LBufferSize);
 
-  if (a_length = -1) then
+  if (ALength = -1) then
   begin
 
     while true do
     begin
 
-      readed := a_stream.Read(data[0], LBufferSize);
+      LRead := AStream.Read(LData[0], LBufferSize);
 
-      if (readed <> LBufferSize) then
+      if (LRead <> LBufferSize) then
       begin
-        TransformBytes(data, 0, readed);
+        TransformBytes(LData, 0, LRead);
         break;
       end
       else
       begin
-        TransformBytes(data, 0, readed);
+        TransformBytes(LData, 0, LRead);
       end;
     end;
 
@@ -323,17 +314,17 @@ begin
     while true do
     begin
 
-      readed := a_stream.Read(data[0], LBufferSize);
+      LRead := AStream.Read(LData[0], LBufferSize);
 
-      if ((total + Int64(readed)) >= a_length) then
+      if ((LTotal + Int64(LRead)) >= ALength) then
       begin
-        TransformBytes(data, 0, Int32(a_length - total));
+        TransformBytes(LData, 0, Int32(ALength - LTotal));
         break;
       end
       else
       begin
-        TransformBytes(data, 0, readed);
-        total := total + readed;
+        TransformBytes(LData, 0, LRead);
+        LTotal := LTotal + LRead;
       end;
     end;
 
@@ -341,28 +332,26 @@ begin
 
 end;
 
-procedure THash.TransformFile(const a_file_name: String;
-  a_from, a_length: Int64);
+procedure THash.TransformFile(const AFileName: String; AFrom, ALength: Int64);
 var
-  MyFileStream: TFileStream;
+  LFileStream: TFileStream;
 begin
 {$IFDEF DEBUG}
-  System.Assert(a_from >= 0);
-  System.Assert((a_length = -1) or (a_length > 0));
+  System.Assert(AFrom >= 0);
+  System.Assert((ALength = -1) or (ALength > 0));
 {$ENDIF DEBUG}
-  if not FileExists(a_file_name) then
+  if not FileExists(AFileName) then
   begin
     raise EArgumentHashLibException.CreateRes(@SFileNotExist);
   end;
 
-  MyFileStream := TFileStream.Create(a_file_name, fmOpenRead or
-    fmShareDenyWrite);
+  LFileStream := TFileStream.Create(AFileName, fmOpenRead or fmShareDenyWrite);
 
   try
-    MyFileStream.Seek(a_from, TSeekOrigin.soBeginning);
-    TransformStream(MyFileStream, a_length);
+    LFileStream.Seek(AFrom, TSeekOrigin.soBeginning);
+    TransformStream(LFileStream, ALength);
   finally
-    MyFileStream.Free;
+    LFileStream.Free;
   end;
 end;
 

+ 62 - 64
src/libraries/hashlib4pascal/HlpHashBuffer.pas

@@ -5,46 +5,45 @@ unit HlpHashBuffer;
 interface
 
 uses
-{$IFDEF HAS_UNITSCOPE}
-  System.SysUtils,
-{$ELSE}
   SysUtils,
-{$ENDIF HAS_UNITSCOPE}
   HlpArrayUtils,
   HlpHashLibTypes;
 
 resourcestring
-  SHashBufferMessage = 'HashBuffer, Length: %d, Pos: %d, IsEmpty: %s';
+  SHashBufferMessage = 'HashBuffer, Length: %d, Position: %d, IsEmpty: %s';
 
 type
   THashBuffer = record
 
   private
-
-    Fm_data: THashLibByteArray;
-    Fm_pos: Int32;
+  var
+    FData: THashLibByteArray;
+    FPosition: Int32;
 
     function GetIsEmpty: Boolean; inline;
     function GetIsFull: Boolean; inline;
-    function GetPos: Int32; inline;
+    function GetPosition: Int32; inline;
     function GetLength: Int32; inline;
 
   public
-    constructor Create(a_length: Int32);
+    constructor Create(ALength: Int32);
+
     procedure Initialize();
     function GetBytes(): THashLibByteArray; inline;
     function GetBytesZeroPadded(): THashLibByteArray; inline;
-    function Feed(a_data: PByte; a_length_a_data: Int32;
-      var a_start_index: Int32; var a_length: Int32;
-      var a_processed_bytes: UInt64): Boolean; overload;
-    function Feed(a_data: PByte; a_length_a_data: Int32; a_length: Int32)
+
+    function Feed(AData: PByte; ADataLength: Int32; var AStartIndex: Int32;
+      var ALength: Int32; var AProcessedBytesCount: UInt64): Boolean; overload;
+
+    function Feed(AData: PByte; ADataLength: Int32; ALength: Int32)
       : Boolean; overload;
+
     function ToString(): String;
     function Clone(): THashBuffer; inline;
 
     property IsEmpty: Boolean read GetIsEmpty;
     property IsFull: Boolean read GetIsFull;
-    property Pos: Int32 read GetPos;
+    property Position: Int32 read GetPosition;
     property Length: Int32 read GetLength;
   end;
 
@@ -55,95 +54,94 @@ implementation
 function THashBuffer.Clone(): THashBuffer;
 begin
   result := Default (THashBuffer);
-  result.Fm_data := System.Copy(Fm_data);
-  result.Fm_pos := Fm_pos;
+  result.FData := System.Copy(FData);
+  result.FPosition := FPosition;
 end;
 
-constructor THashBuffer.Create(a_length: Int32);
+constructor THashBuffer.Create(ALength: Int32);
 begin
 {$IFDEF DEBUG}
-  System.Assert(a_length > 0);
+  System.Assert(ALength > 0);
 {$ENDIF DEBUG}
-  System.SetLength(Fm_data, a_length);
+  System.SetLength(FData, ALength);
   Initialize();
-
 end;
 
 function THashBuffer.GetIsFull: Boolean;
 begin
-  result := Fm_pos = System.Length(Fm_data);
+  result := FPosition = System.Length(FData);
 end;
 
-function THashBuffer.Feed(a_data: PByte; a_length_a_data: Int32;
-  a_length: Int32): Boolean;
+function THashBuffer.Feed(AData: PByte; ADataLength: Int32;
+  ALength: Int32): Boolean;
 var
-  &Length: Int32;
+  LLength: Int32;
 begin
 {$IFDEF DEBUG}
-  System.Assert(a_length >= 0);
-  System.Assert(a_length <= a_length_a_data);
+  System.Assert(ALength >= 0);
+  System.Assert(ALength <= ADataLength);
   System.Assert(not IsFull);
 {$ENDIF DEBUG}
-  if (a_length_a_data = 0) then
+  if (ADataLength = 0) then
   begin
     result := false;
     Exit;
   end;
 
-  if (a_length = 0) then
+  if (ALength = 0) then
   begin
     result := false;
     Exit;
   end;
-  Length := System.Length(Fm_data) - Fm_pos;
-  if (Length > a_length) then
+  LLength := System.Length(FData) - FPosition;
+  if (LLength > ALength) then
   begin
-    Length := a_length;
+    LLength := ALength;
   end;
 
-  System.Move(a_data[0], Fm_data[Fm_pos], Length * System.SizeOf(Byte));
+  System.Move(AData[0], FData[FPosition], LLength * System.SizeOf(Byte));
 
-  Fm_pos := Fm_pos + Length;
+  FPosition := FPosition + LLength;
 
   result := IsFull;
 end;
 
-function THashBuffer.Feed(a_data: PByte; a_length_a_data: Int32;
-  var a_start_index, a_length: Int32; var a_processed_bytes: UInt64): Boolean;
+function THashBuffer.Feed(AData: PByte; ADataLength: Int32;
+  var AStartIndex, ALength: Int32; var AProcessedBytesCount: UInt64): Boolean;
 var
-  &Length: Int32;
+  LLength: Int32;
 begin
 {$IFDEF DEBUG}
-  System.Assert(a_start_index >= 0);
-  System.Assert(a_length >= 0);
-  System.Assert((a_start_index + a_length) <= a_length_a_data);
+  System.Assert(AStartIndex >= 0);
+  System.Assert(ALength >= 0);
+  System.Assert((AStartIndex + ALength) <= ADataLength);
   System.Assert(not IsFull);
 {$ENDIF DEBUG}
-  if (a_length_a_data = 0) then
+  if (ADataLength = 0) then
   begin
     result := false;
     Exit;
   end;
 
-  if (a_length = 0) then
+  if (ALength = 0) then
   begin
     result := false;
     Exit;
   end;
 
-  Length := System.Length(Fm_data) - Fm_pos;
-  if (Length > a_length) then
+  LLength := System.Length(FData) - FPosition;
+  if (LLength > ALength) then
   begin
-    Length := a_length;
+    LLength := ALength;
   end;
 
-  System.Move(a_data[a_start_index], Fm_data[Fm_pos],
-    Length * System.SizeOf(Byte));
+  System.Move(AData[AStartIndex], FData[FPosition],
+    LLength * System.SizeOf(Byte));
 
-  Fm_pos := Fm_pos + Length;
-  a_start_index := a_start_index + Length;
-  a_length := a_length - Length;
-  a_processed_bytes := a_processed_bytes + UInt64(Length);
+  FPosition := FPosition + LLength;
+  AStartIndex := AStartIndex + LLength;
+  ALength := ALength - LLength;
+  AProcessedBytesCount := AProcessedBytesCount + UInt64(LLength);
 
   result := IsFull;
 end;
@@ -153,42 +151,42 @@ begin
 {$IFDEF DEBUG}
   System.Assert(IsFull);
 {$ENDIF DEBUG}
-  Fm_pos := 0;
-  result := Fm_data;
+  FPosition := 0;
+  result := FData;
 end;
 
 function THashBuffer.GetBytesZeroPadded: THashLibByteArray;
 begin
-  TArrayUtils.Fill(Fm_data, Fm_pos, (System.Length(Fm_data) - Fm_pos) +
-    Fm_pos, Byte(0));
-  Fm_pos := 0;
-  result := Fm_data;
+  TArrayUtils.Fill(FData, FPosition, (System.Length(FData) - FPosition) +
+    FPosition, Byte(0));
+  FPosition := 0;
+  result := FData;
 end;
 
 function THashBuffer.GetIsEmpty: Boolean;
 begin
-  result := Fm_pos = 0;
+  result := FPosition = 0;
 end;
 
 function THashBuffer.GetLength: Int32;
 begin
-  result := System.Length(Fm_data);
+  result := System.Length(FData);
 end;
 
-function THashBuffer.GetPos: Int32;
+function THashBuffer.GetPosition: Int32;
 begin
-  result := Fm_pos;
+  result := FPosition;
 end;
 
 procedure THashBuffer.Initialize;
 begin
-  Fm_pos := 0;
-  TArrayUtils.ZeroFill(Fm_data);
+  FPosition := 0;
+  TArrayUtils.ZeroFill(FData);
 end;
 
 function THashBuffer.ToString: String;
 begin
-  result := Format(SHashBufferMessage, [Self.Length, Self.Pos,
+  result := Format(SHashBufferMessage, [Self.Length, Self.Position,
     BoolToStr(Self.IsEmpty, True)]);
 end;
 

+ 40 - 42
src/libraries/hashlib4pascal/HlpHashCryptoNotBuildIn.pas

@@ -15,21 +15,20 @@ uses
 type
   TBlockHash = class abstract(THash, IBlockHash)
   strict protected
-
-    Fm_buffer: THashBuffer;
-    Fm_processed_bytes: UInt64;
+  var
+    FBuffer: THashBuffer;
+    FProcessedBytesCount: UInt64;
 
     procedure TransformBuffer(); inline;
     procedure Finish(); virtual; abstract;
-    procedure TransformBlock(a_data: PByte; a_data_length: Int32;
-      a_index: Int32); virtual; abstract;
+    procedure TransformBlock(AData: PByte; ADataLength: Int32; AIndex: Int32);
+      virtual; abstract;
     function GetResult(): THashLibByteArray; virtual; abstract;
 
   public
-    constructor Create(a_hash_size, a_block_size: Int32;
-      a_buffer_size: Int32 = -1);
-    procedure TransformBytes(const a_data: THashLibByteArray;
-      a_index, a_length: Int32); override;
+    constructor Create(AHashSize, ABlockSize: Int32; ABufferSize: Int32 = -1);
+    procedure TransformBytes(const AData: THashLibByteArray;
+      AIndex, ALength: Int32); override;
     procedure Initialize(); override;
     function TransformFinal(): IHashResult; override;
   end;
@@ -38,83 +37,82 @@ implementation
 
 { TBlockHash }
 
-constructor TBlockHash.Create(a_hash_size, a_block_size, a_buffer_size: Int32);
+constructor TBlockHash.Create(AHashSize, ABlockSize, ABufferSize: Int32);
 begin
-  Inherited Create(a_hash_size, a_block_size);
-  if (a_buffer_size = -1) then
+  Inherited Create(AHashSize, ABlockSize);
+  if (ABufferSize = -1) then
   begin
-    a_buffer_size := a_block_size;
+    ABufferSize := ABlockSize;
   end;
-  Fm_buffer := THashBuffer.Create(a_buffer_size);
+  FBuffer := THashBuffer.Create(ABufferSize);
 end;
 
 procedure TBlockHash.Initialize;
 begin
-  Fm_buffer.Initialize();
-  Fm_processed_bytes := 0;
+  FBuffer.Initialize();
+  FProcessedBytesCount := 0;
 end;
 
 procedure TBlockHash.TransformBuffer;
 begin
 {$IFDEF DEBUG}
-  System.Assert(Fm_buffer.IsFull);
+  System.Assert(FBuffer.IsFull);
 {$ENDIF DEBUG}
-  TransformBlock(PByte(Fm_buffer.GetBytes()), Fm_buffer.Length, 0);
+  TransformBlock(PByte(FBuffer.GetBytes()), FBuffer.Length, 0);
 end;
 
-procedure TBlockHash.TransformBytes(const a_data: THashLibByteArray;
-  a_index, a_length: Int32);
+procedure TBlockHash.TransformBytes(const AData: THashLibByteArray;
+  AIndex, ALength: Int32);
 var
-  ptr_a_data: PByte;
+  LPtrData: PByte;
 begin
 {$IFDEF DEBUG}
-  System.Assert(a_index >= 0);
-  System.Assert(a_length >= 0);
-  System.Assert(a_index + a_length <= System.Length(a_data));
+  System.Assert(AIndex >= 0);
+  System.Assert(ALength >= 0);
+  System.Assert(AIndex + ALength <= System.Length(AData));
 {$ENDIF DEBUG}
-  ptr_a_data := PByte(a_data);
+  LPtrData := PByte(AData);
 
-  if (not Fm_buffer.IsEmpty) then
+  if (not FBuffer.IsEmpty) then
   begin
-    if (Fm_buffer.Feed(ptr_a_data, System.Length(a_data), a_index, a_length,
-      Fm_processed_bytes)) then
+    if (FBuffer.Feed(LPtrData, System.Length(AData), AIndex, ALength,
+      FProcessedBytesCount)) then
     begin
       TransformBuffer();
     end;
   end;
 
-  while (a_length >= (Fm_buffer.Length)) do
+  while (ALength >= (FBuffer.Length)) do
   begin
-    Fm_processed_bytes := Fm_processed_bytes + UInt64(Fm_buffer.Length);
-    TransformBlock(ptr_a_data, Fm_buffer.Length, a_index);
-    a_index := a_index + (Fm_buffer.Length);
-    a_length := a_length - (Fm_buffer.Length);
+    FProcessedBytesCount := FProcessedBytesCount + UInt64(FBuffer.Length);
+    TransformBlock(LPtrData, FBuffer.Length, AIndex);
+    AIndex := AIndex + (FBuffer.Length);
+    ALength := ALength - (FBuffer.Length);
   end;
 
-  if (a_length > 0) then
+  if (ALength > 0) then
   begin
-    Fm_buffer.Feed(ptr_a_data, System.Length(a_data), a_index, a_length,
-      Fm_processed_bytes);
+    FBuffer.Feed(LPtrData, System.Length(AData), AIndex, ALength,
+      FProcessedBytesCount);
   end;
-
 end;
 
 function TBlockHash.TransformFinal: IHashResult;
 var
-  tempresult: THashLibByteArray;
+  LTempResult: THashLibByteArray;
 begin
   Finish();
 
 {$IFDEF DEBUG}
-  System.Assert(Fm_buffer.IsEmpty);
+  System.Assert(FBuffer.IsEmpty);
 {$ENDIF DEBUG}
-  tempresult := GetResult();
+  LTempResult := GetResult();
 {$IFDEF DEBUG}
-  System.Assert(System.Length(tempresult) = HashSize);
+  System.Assert(System.Length(LTempResult) = HashSize);
 {$ENDIF DEBUG}
   Initialize();
 
-  result := THashResult.Create(tempresult);
+  result := THashResult.Create(LTempResult);
 end;
 
 end.

+ 89 - 90
src/libraries/hashlib4pascal/HlpHashFactory.pas

@@ -119,23 +119,24 @@ type
 
     public
 
-      class function CreateCRC(_Width: Int32; _poly, _Init: UInt64;
-        _refIn, _refOut: Boolean; _XorOut, _check: UInt64;
-        const _Names: THashLibStringArray): IHash; overload; static;
+      class function CreateCRC(AWidth: Int32;
+        APolynomial, AInitialValue: UInt64; AReflectIn, AReflectOut: Boolean;
+        AOutputXor, ACheckValue: UInt64; const ANames: THashLibStringArray)
+        : IHash; overload; static;
 
-      class function CreateCRC(_value: TCRCStandard): IHash; overload; static;
+      class function CreateCRC(AValue: TCRCStandard): IHash; overload; static;
 
-      class function CreateCRC16(_poly, _Init: UInt64; _refIn, _refOut: Boolean;
-        _XorOut, _check: UInt64; const _Names: THashLibStringArray)
-        : IHash; static;
+      class function CreateCRC16(APolynomial, AInitialValue: UInt64;
+        AReflectIn, AReflectOut: Boolean; AOutputXor, ACheckValue: UInt64;
+        const ANames: THashLibStringArray): IHash; static;
 
-      class function CreateCRC32(_poly, _Init: UInt64; _refIn, _refOut: Boolean;
-        _XorOut, _check: UInt64; const _Names: THashLibStringArray)
-        : IHash; static;
+      class function CreateCRC32(APolynomial, AInitialValue: UInt64;
+        AReflectIn, AReflectOut: Boolean; AOutputXor, ACheckValue: UInt64;
+        const ANames: THashLibStringArray): IHash; static;
 
-      class function CreateCRC64(_poly, _Init: UInt64; _refIn, _refOut: Boolean;
-        _XorOut, _check: UInt64; const _Names: THashLibStringArray)
-        : IHash; static;
+      class function CreateCRC64(APolynomial, AInitialValue: UInt64;
+        AReflectIn, AReflectOut: Boolean; AOutputXor, ACheckValue: UInt64;
+        const ANames: THashLibStringArray): IHash; static;
 
       /// <summary>
       /// BUYPASS, polynomial = $8005
@@ -259,10 +260,10 @@ type
       /// <summary>
       ///
       /// </summary>
-      /// <param name="a_hash_size">16, 20 or 24 bytes. </param>
-      /// <param name="a_rounds">no of rounds (standard rounds are 3, 4 and 5)</param>
+      /// <param name="AHashSize">16, 20 or 24 bytes. </param>
+      /// <param name="ARounds">no of rounds (standard rounds are 3, 4 and 5)</param>
       /// <returns></returns>
-      class function CreateTiger(a_hash_size: Int32; a_rounds: THashRounds)
+      class function CreateTiger(AHashSize: Int32; ARounds: THashRounds)
         : IHash; static;
       class function CreateTiger_3_128(): IHash; static;
       class function CreateTiger_3_160(): IHash; static;
@@ -279,10 +280,10 @@ type
       /// <summary>
       ///
       /// </summary>
-      /// <param name="a_hash_size">16, 20 or 24 bytes. </param>
-      /// <param name="a_rounds">no of rounds (standard rounds are 3, 4 and 5)</param>
+      /// <param name="AHashSize">16, 20 or 24 bytes. </param>
+      /// <param name="ARounds">no of rounds (standard rounds are 3, 4 and 5)</param>
       /// <returns></returns>
-      class function CreateTiger2(a_hash_size: Int32; a_rounds: THashRounds)
+      class function CreateTiger2(AHashSize: Int32; ARounds: THashRounds)
         : IHash; static;
 
       class function CreateTiger2_3_128(): IHash; static;
@@ -324,21 +325,21 @@ type
       /// <summary>
       ///
       /// </summary>
-      /// <param name="a_security_level">any Integer value greater than 0. Standard is 8. </param>
-      /// <param name="a_hash_size">128bit, 256bit</param>
+      /// <param name="ASecurityLevel">any Integer value greater than 0. Standard is 8. </param>
+      /// <param name="AHashSize">128bit, 256bit</param>
       /// <returns></returns>
-      class function CreateSnefru(a_security_level: Int32;
-        a_hash_size: THashSize): IHash; static;
+      class function CreateSnefru(ASecurityLevel: Int32; AHashSize: THashSize)
+        : IHash; static;
       class function CreateSnefru_8_128(): IHash; static;
       class function CreateSnefru_8_256(): IHash; static;
 
       /// <summary>
       ///
       /// </summary>
-      /// <param name="a_rounds">3, 4, 5</param>
-      /// <param name="a_hash_size">128, 160, 192, 224, 256</param>
+      /// <param name="ARounds">3, 4, 5</param>
+      /// <param name="AHashSize">128, 160, 192, 224, 256</param>
       /// <returns></returns>
-      class function CreateHaval(a_rounds: THashRounds; a_hash_size: THashSize)
+      class function CreateHaval(ARounds: THashRounds; AHashSize: THashSize)
         : IHash; static;
 
       class function CreateHaval_3_128(): IHash; static;
@@ -388,16 +389,16 @@ type
       class function CreateKeccak_384(): IHash; static;
       class function CreateKeccak_512(): IHash; static;
 
-      class function CreateBlake2B(const config: IBlake2BConfig = Nil;
-        const treeConfig: IBlake2BTreeConfig = Nil): IHash; static;
+      class function CreateBlake2B(const AConfig: IBlake2BConfig = Nil;
+        const ATreeConfig: IBlake2BTreeConfig = Nil): IHash; static;
 
       class function CreateBlake2B_160(): IHash; static;
       class function CreateBlake2B_256(): IHash; static;
       class function CreateBlake2B_384(): IHash; static;
       class function CreateBlake2B_512(): IHash; static;
 
-      class function CreateBlake2S(const config: IBlake2SConfig = Nil;
-        const treeConfig: IBlake2STreeConfig = Nil): IHash; static;
+      class function CreateBlake2S(const AConfig: IBlake2SConfig = Nil;
+        const ATreeConfig: IBlake2STreeConfig = Nil): IHash; static;
 
       class function CreateBlake2S_128(): IHash; static;
       class function CreateBlake2S_160(): IHash; static;
@@ -413,8 +414,8 @@ type
 
     public
 
-      class function CreateShake_128(a_xof_size_in_bits: UInt32): IHash; static;
-      class function CreateShake_256(a_xof_size_in_bits: UInt32): IHash; static;
+      class function CreateShake_128(AXofSizeInBits: UInt32): IHash; static;
+      class function CreateShake_256(AXofSizeInBits: UInt32): IHash; static;
 
     end;
 
@@ -426,7 +427,7 @@ type
     public
 
       class function CreateHMAC(const AHash: IHash;
-        const AHmacKey: THashLibByteArray = Nil): IHMAC; static;
+        const AHMACKey: THashLibByteArray = Nil): IHMAC; static;
 
     end;
 
@@ -553,25 +554,25 @@ end;
 
 { THashFactory.TCRC }
 
-class function THashFactory.TCRC.CreateCRC(_Width: Int32; _poly, _Init: UInt64;
-  _refIn, _refOut: Boolean; _XorOut, _check: UInt64;
-  const _Names: THashLibStringArray): IHash;
+class function THashFactory.TCRC.CreateCRC(AWidth: Int32;
+  APolynomial, AInitialValue: UInt64; AReflectIn, AReflectOut: Boolean;
+  AOutputXor, ACheckValue: UInt64; const ANames: THashLibStringArray): IHash;
 begin
-  Result := HlpCRC.TCRC.Create(_Width, _poly, _Init, _refIn, _refOut, _XorOut,
-    _check, _Names);
+  Result := HlpCRC.TCRC.Create(AWidth, APolynomial, AInitialValue, AReflectIn,
+    AReflectOut, AOutputXor, ACheckValue, ANames);
 end;
 
-class function THashFactory.TCRC.CreateCRC(_value: TCRCStandard): IHash;
+class function THashFactory.TCRC.CreateCRC(AValue: TCRCStandard): IHash;
 begin
-  Result := HlpCRC.TCRC.CreateCRCObject(_value);
+  Result := HlpCRC.TCRC.CreateCRCObject(AValue);
 end;
 
-class function THashFactory.TCRC.CreateCRC16(_poly, _Init: UInt64;
-  _refIn, _refOut: Boolean; _XorOut, _check: UInt64;
-  const _Names: THashLibStringArray): IHash;
+class function THashFactory.TCRC.CreateCRC16(APolynomial, AInitialValue: UInt64;
+  AReflectIn, AReflectOut: Boolean; AOutputXor, ACheckValue: UInt64;
+  const ANames: THashLibStringArray): IHash;
 begin
-  Result := TCRC16.Create(_poly, _Init, _refIn, _refOut, _XorOut,
-    _check, _Names);
+  Result := TCRC16.Create(APolynomial, AInitialValue, AReflectIn, AReflectOut,
+    AOutputXor, ACheckValue, ANames);
 end;
 
 class function THashFactory.TCRC.CreateCRC16_BUYPASS: IHash;
@@ -579,12 +580,12 @@ begin
   Result := TCRC16_BUYPASS.Create();
 end;
 
-class function THashFactory.TCRC.CreateCRC32(_poly, _Init: UInt64;
-  _refIn, _refOut: Boolean; _XorOut, _check: UInt64;
-  const _Names: THashLibStringArray): IHash;
+class function THashFactory.TCRC.CreateCRC32(APolynomial, AInitialValue: UInt64;
+  AReflectIn, AReflectOut: Boolean; AOutputXor, ACheckValue: UInt64;
+  const ANames: THashLibStringArray): IHash;
 begin
-  Result := TCRC32.Create(_poly, _Init, _refIn, _refOut, _XorOut,
-    _check, _Names);
+  Result := TCRC32.Create(APolynomial, AInitialValue, AReflectIn, AReflectOut,
+    AOutputXor, ACheckValue, ANames);
 end;
 
 class function THashFactory.TCRC.CreateCRC32_CASTAGNOLI: IHash;
@@ -597,12 +598,12 @@ begin
   Result := HlpCRC32Fast.TCRC32_PKZIP.Create();
 end;
 
-class function THashFactory.TCRC.CreateCRC64(_poly, _Init: UInt64;
-  _refIn, _refOut: Boolean; _XorOut, _check: UInt64;
-  const _Names: THashLibStringArray): IHash;
+class function THashFactory.TCRC.CreateCRC64(APolynomial, AInitialValue: UInt64;
+  AReflectIn, AReflectOut: Boolean; AOutputXor, ACheckValue: UInt64;
+  const ANames: THashLibStringArray): IHash;
 begin
-  Result := TCRC64.Create(_poly, _Init, _refIn, _refOut, _XorOut,
-    _check, _Names);
+  Result := TCRC64.Create(APolynomial, AInitialValue, AReflectIn, AReflectOut,
+    AOutputXor, ACheckValue, ANames);
 end;
 
 class function THashFactory.TCRC.CreateCRC64_ECMA_182: IHash;
@@ -795,12 +796,12 @@ begin
   Result := THAS160.Create();
 end;
 
-class function THashFactory.TCrypto.CreateHaval(a_rounds: THashRounds;
-  a_hash_size: THashSize): IHash;
+class function THashFactory.TCrypto.CreateHaval(ARounds: THashRounds;
+  AHashSize: THashSize): IHash;
 begin
-  case a_rounds of
+  case ARounds of
     THashRounds.hrRounds3:
-      case a_hash_size of
+      case AHashSize of
         THashSize.hsHashSize128:
           Result := CreateHaval_3_128();
         THashSize.hsHashSize160:
@@ -816,7 +817,7 @@ begin
       end;
 
     THashRounds.hrRounds4:
-      case a_hash_size of
+      case AHashSize of
         THashSize.hsHashSize128:
           Result := CreateHaval_4_128();
         THashSize.hsHashSize160:
@@ -832,7 +833,7 @@ begin
       end;
 
     THashRounds.hrRounds5:
-      case a_hash_size of
+      case AHashSize of
         THashSize.hsHashSize128:
           Result := CreateHaval_5_128();
         THashSize.hsHashSize160:
@@ -1067,17 +1068,17 @@ begin
   Result := TKeccak_512.Create();
 end;
 
-class function THashFactory.TCrypto.CreateBlake2B(const config: IBlake2BConfig;
-  const treeConfig: IBlake2BTreeConfig): IHash;
+class function THashFactory.TCrypto.CreateBlake2B(const AConfig: IBlake2BConfig;
+  const ATreeConfig: IBlake2BTreeConfig): IHash;
 var
   LConfig: IBlake2BConfig;
 begin
-  LConfig := config;
+  LConfig := AConfig;
   if (LConfig = Nil) then
   begin
     LConfig := TBlake2BConfig.Create();
   end;
-  Result := TBlake2B.Create(LConfig, treeConfig);
+  Result := TBlake2B.Create(LConfig, ATreeConfig);
 end;
 
 class function THashFactory.TCrypto.CreateBlake2B_160: IHash;
@@ -1104,17 +1105,17 @@ begin
     (TBlake2BConfig.Create(THashSize.hsHashSize512));
 end;
 
-class function THashFactory.TCrypto.CreateBlake2S(const config: IBlake2SConfig;
-  const treeConfig: IBlake2STreeConfig): IHash;
+class function THashFactory.TCrypto.CreateBlake2S(const AConfig: IBlake2SConfig;
+  const ATreeConfig: IBlake2STreeConfig): IHash;
 var
   LConfig: IBlake2SConfig;
 begin
-  LConfig := config;
+  LConfig := AConfig;
   if (LConfig = Nil) then
   begin
     LConfig := TBlake2SConfig.Create();
   end;
-  Result := TBlake2S.Create(LConfig, treeConfig);
+  Result := TBlake2S.Create(LConfig, ATreeConfig);
 end;
 
 class function THashFactory.TCrypto.CreateBlake2S_128: IHash;
@@ -1141,15 +1142,15 @@ begin
     (TBlake2SConfig.Create(THashSize.hsHashSize256));
 end;
 
-class function THashFactory.TCrypto.CreateSnefru(a_security_level: Int32;
-  a_hash_size: THashSize): IHash;
+class function THashFactory.TCrypto.CreateSnefru(ASecurityLevel: Int32;
+  AHashSize: THashSize): IHash;
 begin
-  if a_security_level < Int32(1) then
+  if ASecurityLevel < Int32(1) then
     raise EArgumentHashLibException.CreateRes(@SInvalidSnefruLevel);
 
-  case a_hash_size of
+  case AHashSize of
     THashSize.hsHashSize128, THashSize.hsHashSize256:
-      Result := TSnefru.Create(a_security_level, a_hash_size);
+      Result := TSnefru.Create(ASecurityLevel, AHashSize);
   else
     raise EArgumentHashLibException.CreateRes(@SInvalidSnefruHashSize);
   end;
@@ -1216,23 +1217,23 @@ begin
   Result := TWhirlPool.Create();
 end;
 
-class function THashFactory.TCrypto.CreateTiger(a_hash_size: Int32;
-  a_rounds: THashRounds): IHash;
+class function THashFactory.TCrypto.CreateTiger(AHashSize: Int32;
+  ARounds: THashRounds): IHash;
 begin
-  case a_hash_size of
+  case AHashSize of
     16, 20, 24:
-      Result := TTiger_Base.Create(a_hash_size, a_rounds);
+      Result := TTiger_Base.Create(AHashSize, ARounds);
   else
     raise EArgumentHashLibException.CreateRes(@SInvalidTigerHashSize);
   end;
 end;
 
-class function THashFactory.TCrypto.CreateTiger2(a_hash_size: Int32;
-  a_rounds: THashRounds): IHash;
+class function THashFactory.TCrypto.CreateTiger2(AHashSize: Int32;
+  ARounds: THashRounds): IHash;
 begin
-  case a_hash_size of
+  case AHashSize of
     16, 20, 24:
-      Result := TTiger2_Base.Create(a_hash_size, a_rounds);
+      Result := TTiger2_Base.Create(AHashSize, ARounds);
   else
     raise EArgumentHashLibException.CreateRes(@SInvalidTiger2HashSize);
   end;
@@ -1285,32 +1286,30 @@ end;
 
 { THashFactory.TXOF }
 
-class function THashFactory.TXOF.CreateShake_128(a_xof_size_in_bits
-  : UInt32): IHash;
+class function THashFactory.TXOF.CreateShake_128(AXofSizeInBits: UInt32): IHash;
 var
   LXof: IXOF;
 begin
   LXof := (TShake_128.Create() as IXOF);
-  LXof.XOFSizeInBits := a_xof_size_in_bits;
+  LXof.XOFSizeInBits := AXofSizeInBits;
   Result := LXof as IHash;
 end;
 
-class function THashFactory.TXOF.CreateShake_256(a_xof_size_in_bits
-  : UInt32): IHash;
+class function THashFactory.TXOF.CreateShake_256(AXofSizeInBits: UInt32): IHash;
 var
   LXof: IXOF;
 begin
   LXof := (TShake_256.Create() as IXOF);
-  LXof.XOFSizeInBits := a_xof_size_in_bits;
+  LXof.XOFSizeInBits := AXofSizeInBits;
   Result := LXof as IHash;
 end;
 
 { THashFactory.THMAC }
 
 class function THashFactory.THMAC.CreateHMAC(const AHash: IHash;
-  const AHmacKey: THashLibByteArray): IHMAC;
+  const AHMACKey: THashLibByteArray): IHMAC;
 begin
-  Result := THMACNotBuildInAdapter.CreateHMAC(AHash, AHmacKey);
+  Result := THMACNotBuildInAdapter.CreateHMAC(AHash, AHMACKey);
 end;
 
 { TKDF.TPBKDF2_HMAC }

+ 1 - 6
src/libraries/hashlib4pascal/HlpHashLibTypes.pas

@@ -5,12 +5,7 @@ unit HlpHashLibTypes;
 interface
 
 uses
-
-{$IFDEF HAS_UNITSCOPE}
-  System.SysUtils
-{$ELSE}
-    SysUtils
-{$ENDIF HAS_UNITSCOPE};
+  SysUtils;
 
 type
 

+ 90 - 98
src/libraries/hashlib4pascal/HlpHashResult.pas

@@ -5,25 +5,17 @@ unit HlpHashResult;
 interface
 
 uses
-
-{$IFDEF HAS_UNITSCOPE}
-  System.SysUtils,
-{$IFDEF DELPHIXE7_UP}
-  System.NetEncoding,
+  SysUtils,
+{$IFDEF FPC}
+  base64,
 {$ELSE}
-  System.Classes,
-  Soap.EncdDecd,
-{$ENDIF DELPHIXE7_UP}
+{$IFDEF HAS_DELPHI_NET_ENCODING}
+  System.NetEncoding,
 {$ELSE}
-  SysUtils,
-{$IFDEF DELPHI}
   Classes,
   EncdDecd,
-{$ENDIF DELPHI}
-{$IFDEF FPC}
-  base64,
+{$ENDIF HAS_DELPHI_NET_ENCODING}
 {$ENDIF FPC}
-{$ENDIF HAS_UNITSCOPE}
   HlpBits,
   HlpHashLibTypes,
   HlpIHashResult,
@@ -46,17 +38,17 @@ type
   THashResult = class sealed(TInterfacedObject, IHashResult)
 
   strict private
-
-    Fm_hash: THashLibByteArray;
+  var
+    FHash: THashLibByteArray;
 
   public
 
-    constructor Create(a_hash: Int32); overload;
-    constructor Create(a_hash: UInt8); overload;
-    constructor Create(a_hash: UInt16); overload;
-    constructor Create(a_hash: UInt32); overload;
-    constructor Create(a_hash: UInt64); overload;
-    constructor Create(const a_hash: THashLibByteArray); overload;
+    constructor Create(AHash: Int32); overload;
+    constructor Create(AHash: UInt8); overload;
+    constructor Create(AHash: UInt16); overload;
+    constructor Create(AHash: UInt32); overload;
+    constructor Create(AHash: UInt64); overload;
+    constructor Create(const AHash: THashLibByteArray); overload;
 
     function GetBytes(): THashLibByteArray;
     function GetUInt8(): UInt8;
@@ -64,8 +56,8 @@ type
     function GetUInt32(): UInt32;
     function GetInt32(): Int32;
     function GetUInt64(): UInt64;
-    function ToString(a_group: Boolean = false): String; reintroduce;
-    function Equals(const a_hashResult: IHashResult): Boolean; reintroduce;
+    function ToString(AGroup: Boolean = False): String; reintroduce;
+    function Equals(const AHashResult: IHashResult): Boolean; reintroduce;
     function GetHashCode(): {$IFDEF DELPHI}Int32; {$ELSE}PtrInt;
 {$ENDIF DELPHI}override;
 
@@ -75,54 +67,54 @@ implementation
 
 { THashResult }
 
-constructor THashResult.Create(a_hash: UInt64);
+constructor THashResult.Create(AHash: UInt64);
 begin
   Inherited Create();
-  Fm_hash := THashLibByteArray.Create(Byte(a_hash shr 56), Byte(a_hash shr 48),
-    Byte(a_hash shr 40), Byte(a_hash shr 32), Byte(a_hash shr 24),
-    Byte(a_hash shr 16), Byte(a_hash shr 8), Byte(a_hash));
+  FHash := THashLibByteArray.Create(Byte(AHash shr 56), Byte(AHash shr 48),
+    Byte(AHash shr 40), Byte(AHash shr 32), Byte(AHash shr 24),
+    Byte(AHash shr 16), Byte(AHash shr 8), Byte(AHash));
 end;
 
-constructor THashResult.Create(const a_hash: THashLibByteArray);
+constructor THashResult.Create(const AHash: THashLibByteArray);
 begin
   Inherited Create();
-  Fm_hash := a_hash;
+  FHash := AHash;
 end;
 
-constructor THashResult.Create(a_hash: UInt32);
+constructor THashResult.Create(AHash: UInt32);
 begin
   Inherited Create();
-  Fm_hash := THashLibByteArray.Create(Byte(a_hash shr 24), Byte(a_hash shr 16),
-    Byte(a_hash shr 8), Byte(a_hash));
+  FHash := THashLibByteArray.Create(Byte(AHash shr 24), Byte(AHash shr 16),
+    Byte(AHash shr 8), Byte(AHash));
 end;
 
-constructor THashResult.Create(a_hash: UInt8);
+constructor THashResult.Create(AHash: UInt8);
 begin
   Inherited Create();
-  Fm_hash := THashLibByteArray.Create(a_hash);
+  FHash := THashLibByteArray.Create(AHash);
 end;
 
-constructor THashResult.Create(a_hash: UInt16);
+constructor THashResult.Create(AHash: UInt16);
 begin
   Inherited Create();
-  Fm_hash := THashLibByteArray.Create(Byte(a_hash shr 8), Byte(a_hash));
+  FHash := THashLibByteArray.Create(Byte(AHash shr 8), Byte(AHash));
 end;
 
-constructor THashResult.Create(a_hash: Int32);
+constructor THashResult.Create(AHash: Int32);
 begin
   Inherited Create();
-  Fm_hash := THashLibByteArray.Create(Byte(TBits.Asr32(a_hash, 24)),
-    Byte(TBits.Asr32(a_hash, 16)), Byte(TBits.Asr32(a_hash, 8)), Byte(a_hash));
+  FHash := THashLibByteArray.Create(Byte(TBits.Asr32(AHash, 24)),
+    Byte(TBits.Asr32(AHash, 16)), Byte(TBits.Asr32(AHash, 8)), Byte(AHash));
 end;
 
-function THashResult.Equals(const a_hashResult: IHashResult): Boolean;
+function THashResult.Equals(const AHashResult: IHashResult): Boolean;
 begin
-  result := TArrayUtils.ConstantTimeAreEqual(a_hashResult.GetBytes(), Fm_hash);
+  result := TArrayUtils.ConstantTimeAreEqual(AHashResult.GetBytes(), FHash);
 end;
 
 function THashResult.GetBytes: THashLibByteArray;
 begin
-  result := Fm_hash;
+  result := FHash;
 end;
 
 function THashResult.GetHashCode: {$IFDEF DELPHI}Int32; {$ELSE}PtrInt;
@@ -130,63 +122,62 @@ function THashResult.GetHashCode: {$IFDEF DELPHI}Int32; {$ELSE}PtrInt;
 
 var
   LResult: UInt32;
-  I, Top: Int32;
-  Temp: string;
-{$IFDEF DELPHIXE7_UP}
-  TempHolder: THashLibByteArray;
+  LIdx, LTop: Int32;
+  LTemp: String;
+{$IFDEF HAS_DELPHI_NET_ENCODING}
+  LTempHolder: THashLibByteArray;
 {$ELSE}
 {$IFDEF DELPHI}
-  TempHolder: TBytesStream;
+  LTempHolder: TBytesStream;
 {$ENDIF DELPHI}
-{$ENDIF DELPHIXE7_UP}
+{$ENDIF HAS_DELPHI_NET_ENCODING}
 {$IFDEF FPC}
-  TempHolder: String;
+  LTempHolder: String;
 {$ENDIF FPC}
 begin
 
-{$IFDEF DELPHIXE7_UP}
-  TempHolder := Self.Fm_hash;
+{$IFDEF HAS_DELPHI_NET_ENCODING}
+  LTempHolder := Self.FHash;
 {$ELSE}
 {$IFDEF DELPHI}
-  TempHolder := TBytesStream.Create(Self.Fm_hash);
+  LTempHolder := TBytesStream.Create(Self.FHash);
 {$ENDIF DELPHI}
-{$ENDIF DELPHIXE7_UP}
+{$ENDIF HAS_DELPHI_NET_ENCODING}
 {$IFDEF FPC}
-  TempHolder := EncodeStringBase64
-    (TConverters.ConvertBytesToString(Self.Fm_hash, TEncoding.UTF8));
+  LTempHolder := EncodeStringBase64(TConverters.ConvertBytesToString(Self.FHash,
+    TEncoding.UTF8));
 {$ENDIF FPC}
-{$IFDEF DELPHIXE7_UP}
-  Temp := StringReplace(TNetEncoding.base64.EncodeBytesToString(TempHolder),
+{$IFDEF HAS_DELPHI_NET_ENCODING}
+  LTemp := StringReplace(TNetEncoding.base64.EncodeBytesToString(LTempHolder),
     sLineBreak, '', [rfReplaceAll]);
 {$ELSE}
 {$IFDEF DELPHI}
   try
-    Temp := StringReplace(String(EncodeBase64(TempHolder.Memory,
-      TempHolder.Size)), sLineBreak, '', [rfReplaceAll]);
+    LTemp := StringReplace(String(EncodeBase64(LTempHolder.Memory,
+      LTempHolder.Size)), sLineBreak, '', [rfReplaceAll]);
   finally
-    TempHolder.Free;
+    LTempHolder.Free;
   end;
 {$ENDIF DELPHI}
-{$ENDIF DELPHIXE7_UP}
+{$ENDIF HAS_DELPHI_NET_ENCODING}
 {$IFDEF FPC}
-  Temp := TempHolder;
+  LTemp := LTempHolder;
 {$ENDIF FPC}
-  Temp := AnsiUpperCase(Temp);
+  LTemp := AnsiUpperCase(LTemp);
 
   LResult := 0;
 {$IFDEF DELPHIXE3_UP}
-  I := System.Low(Temp);
-  Top := System.High(Temp);
+  LIdx := System.Low(LTemp);
+  LTop := System.High(LTemp);
 {$ELSE}
-  I := 1;
-  Top := System.Length(Temp);
+  LIdx := 1;
+  LTop := System.Length(LTemp);
 {$ENDIF DELPHIXE3_UP}
-  while I <= Top do
+  while LIdx <= LTop do
   begin
-
     LResult := TBits.RotateLeft32(LResult, 5);
-    LResult := LResult xor UInt32(Temp[I]);
-    System.Inc(I);
+    LResult := LResult xor UInt32(LTemp[LIdx]);
+    System.Inc(LIdx);
   end;
 
   result := LResult;
@@ -194,61 +185,62 @@ end;
 
 function THashResult.GetInt32: Int32;
 begin
-  if (System.Length(Fm_hash) <> 4) then
+  if (System.Length(FHash) <> 4) then
+  begin
     raise EInvalidOperationHashLibException.CreateRes
       (@SImpossibleRepresentationInt32);
-
-  result := Int32((Int32(Fm_hash[0]) shl 24) or (Int32(Fm_hash[1]) shl 16) or
-    (Int32(Fm_hash[2]) shl 8) or (Int32(Fm_hash[3])));
-
+  end;
+  result := Int32((Int32(FHash[0]) shl 24) or (Int32(FHash[1]) shl 16) or
+    (Int32(FHash[2]) shl 8) or (Int32(FHash[3])));
 end;
 
 function THashResult.GetUInt8: UInt8;
 begin
-  if (System.Length(Fm_hash) <> 1) then
+  if (System.Length(FHash) <> 1) then
+  begin
     raise EInvalidOperationHashLibException.CreateRes
       (@SImpossibleRepresentationUInt8);
-
-  result := (UInt8(Fm_hash[0]));
+  end;
+  result := (UInt8(FHash[0]));
 end;
 
 function THashResult.GetUInt16: UInt16;
 begin
-  if (System.Length(Fm_hash) <> 2) then
+  if (System.Length(FHash) <> 2) then
+  begin
     raise EInvalidOperationHashLibException.CreateRes
       (@SImpossibleRepresentationUInt16);
-
-  result := (UInt16(Fm_hash[0]) shl 8) or (UInt16(Fm_hash[1]));
-
+  end;
+  result := (UInt16(FHash[0]) shl 8) or (UInt16(FHash[1]));
 end;
 
 function THashResult.GetUInt32: UInt32;
 begin
-  if (System.Length(Fm_hash) <> 4) then
+  if (System.Length(FHash) <> 4) then
+  begin
     raise EInvalidOperationHashLibException.CreateRes
       (@SImpossibleRepresentationUInt32);
-
-  result := (UInt32(Fm_hash[0]) shl 24) or (UInt32(Fm_hash[1]) shl 16) or
-    (UInt32(Fm_hash[2]) shl 8) or (UInt32(Fm_hash[3]));
-
+  end;
+  result := (UInt32(FHash[0]) shl 24) or (UInt32(FHash[1]) shl 16) or
+    (UInt32(FHash[2]) shl 8) or (UInt32(FHash[3]));
 end;
 
 function THashResult.GetUInt64: UInt64;
 begin
-  if (System.Length(Fm_hash) <> 8) then
+  if (System.Length(FHash) <> 8) then
+  begin
     raise EInvalidOperationHashLibException.CreateRes
       (@SImpossibleRepresentationUInt64);
-
-  result := (UInt64(Fm_hash[0]) shl 56) or (UInt64(Fm_hash[1]) shl 48) or
-    (UInt64(Fm_hash[2]) shl 40) or (UInt64(Fm_hash[3]) shl 32) or
-    (UInt64(Fm_hash[4]) shl 24) or (UInt64(Fm_hash[5]) shl 16) or
-    (UInt64(Fm_hash[6]) shl 8) or (UInt64(Fm_hash[7]));
-
+  end;
+  result := (UInt64(FHash[0]) shl 56) or (UInt64(FHash[1]) shl 48) or
+    (UInt64(FHash[2]) shl 40) or (UInt64(FHash[3]) shl 32) or
+    (UInt64(FHash[4]) shl 24) or (UInt64(FHash[5]) shl 16) or
+    (UInt64(FHash[6]) shl 8) or (UInt64(FHash[7]));
 end;
 
-function THashResult.ToString(a_group: Boolean): String;
+function THashResult.ToString(AGroup: Boolean): String;
 begin
-  result := TConverters.ConvertBytesToHexString(Fm_hash, a_group);
+  result := TConverters.ConvertBytesToHexString(FHash, AGroup);
 end;
 
 end.

+ 2 - 2
src/libraries/hashlib4pascal/HlpHashSize.pas

@@ -7,8 +7,8 @@ interface
 type
 {$SCOPEDENUMS ON}
   THashSize = (hsHashSize128 = 16, hsHashSize160 = 20, hsHashSize192 = 24,
-    hsHashSize224 = 28, hsHashSize256 = 32, hsHashSize288 = 36, hsHashSize384 = 48,
-    hsHashSize512 = 64);
+    hsHashSize224 = 28, hsHashSize256 = 32, hsHashSize288 = 36,
+    hsHashSize384 = 48, hsHashSize512 = 64);
 {$SCOPEDENUMS OFF}
 
 implementation

File diff suppressed because it is too large
+ 557 - 566
src/libraries/hashlib4pascal/HlpHaval.pas


+ 4 - 4
src/libraries/hashlib4pascal/HlpIBlake2BConfig.pas

@@ -11,17 +11,17 @@ type
   IBlake2BConfig = interface(IInterface)
     ['{176861A3-B06E-4CA3-A1BB-DDEAFF40BFE1}']
     function GetPersonalisation: THashLibByteArray;
-    procedure SetPersonalisation(const value: THashLibByteArray);
+    procedure SetPersonalisation(const AValue: THashLibByteArray);
     property Personalisation: THashLibByteArray read GetPersonalisation
       write SetPersonalisation;
     function GetSalt: THashLibByteArray;
-    procedure SetSalt(const value: THashLibByteArray);
+    procedure SetSalt(const AValue: THashLibByteArray);
     property Salt: THashLibByteArray read GetSalt write SetSalt;
     function GetKey: THashLibByteArray;
-    procedure SetKey(const value: THashLibByteArray);
+    procedure SetKey(const AValue: THashLibByteArray);
     property Key: THashLibByteArray read GetKey write SetKey;
     function GetHashSize: Int32;
-    procedure SetHashSize(value: Int32);
+    procedure SetHashSize(AValue: Int32);
     property HashSize: Int32 read GetHashSize write SetHashSize;
 
   end;

+ 7 - 7
src/libraries/hashlib4pascal/HlpIBlake2BTreeConfig.pas

@@ -9,31 +9,31 @@ type
     ['{3EFB1A70-4478-4375-BAF6-EF17B3673DA8}']
 
     function GetFanOut: Byte;
-    procedure SetFanOut(value: Byte);
+    procedure SetFanOut(AValue: Byte);
     property FanOut: Byte read GetFanOut write SetFanOut;
 
     function GetMaxDepth: Byte;
-    procedure SetMaxDepth(value: Byte);
+    procedure SetMaxDepth(AValue: Byte);
     property MaxDepth: Byte read GetMaxDepth write SetMaxDepth;
 
     function GetNodeDepth: Byte;
-    procedure SetNodeDepth(value: Byte);
+    procedure SetNodeDepth(AValue: Byte);
     property NodeDepth: Byte read GetNodeDepth write SetNodeDepth;
 
     function GetInnerHashSize: Byte;
-    procedure SetInnerHashSize(value: Byte);
+    procedure SetInnerHashSize(AValue: Byte);
     property InnerHashSize: Byte read GetInnerHashSize write SetInnerHashSize;
 
     function GetLeafSize: UInt32;
-    procedure SetLeafSize(value: UInt32);
+    procedure SetLeafSize(AValue: UInt32);
     property LeafSize: UInt32 read GetLeafSize write SetLeafSize;
 
     function GetNodeOffset: UInt64;
-    procedure SetNodeOffset(value: UInt64);
+    procedure SetNodeOffset(AValue: UInt64);
     property NodeOffset: UInt64 read GetNodeOffset write SetNodeOffset;
 
     function GetIsLastNode: Boolean;
-    procedure SetIsLastNode(value: Boolean);
+    procedure SetIsLastNode(AValue: Boolean);
     property IsLastNode: Boolean read GetIsLastNode write SetIsLastNode;
 
   end;

+ 4 - 4
src/libraries/hashlib4pascal/HlpIBlake2SConfig.pas

@@ -11,17 +11,17 @@ type
   IBlake2SConfig = interface(IInterface)
     ['{C78DE94A-0290-467D-BE26-D0AD1639076C}']
     function GetPersonalisation: THashLibByteArray;
-    procedure SetPersonalisation(const value: THashLibByteArray);
+    procedure SetPersonalisation(const AValue: THashLibByteArray);
     property Personalisation: THashLibByteArray read GetPersonalisation
       write SetPersonalisation;
     function GetSalt: THashLibByteArray;
-    procedure SetSalt(const value: THashLibByteArray);
+    procedure SetSalt(const AValue: THashLibByteArray);
     property Salt: THashLibByteArray read GetSalt write SetSalt;
     function GetKey: THashLibByteArray;
-    procedure SetKey(const value: THashLibByteArray);
+    procedure SetKey(const AValue: THashLibByteArray);
     property Key: THashLibByteArray read GetKey write SetKey;
     function GetHashSize: Int32;
-    procedure SetHashSize(value: Int32);
+    procedure SetHashSize(AValue: Int32);
     property HashSize: Int32 read GetHashSize write SetHashSize;
 
   end;

+ 7 - 7
src/libraries/hashlib4pascal/HlpIBlake2STreeConfig.pas

@@ -9,31 +9,31 @@ type
     ['{93635D4F-7104-4E4A-BE9B-C608606F620F}']
 
     function GetFanOut: Byte;
-    procedure SetFanOut(value: Byte);
+    procedure SetFanOut(AValue: Byte);
     property FanOut: Byte read GetFanOut write SetFanOut;
 
     function GetMaxDepth: Byte;
-    procedure SetMaxDepth(value: Byte);
+    procedure SetMaxDepth(AValue: Byte);
     property MaxDepth: Byte read GetMaxDepth write SetMaxDepth;
 
     function GetNodeDepth: Byte;
-    procedure SetNodeDepth(value: Byte);
+    procedure SetNodeDepth(AValue: Byte);
     property NodeDepth: Byte read GetNodeDepth write SetNodeDepth;
 
     function GetInnerHashSize: Byte;
-    procedure SetInnerHashSize(value: Byte);
+    procedure SetInnerHashSize(AValue: Byte);
     property InnerHashSize: Byte read GetInnerHashSize write SetInnerHashSize;
 
     function GetLeafSize: UInt32;
-    procedure SetLeafSize(value: UInt32);
+    procedure SetLeafSize(AValue: UInt32);
     property LeafSize: UInt32 read GetLeafSize write SetLeafSize;
 
     function GetNodeOffset: UInt64;
-    procedure SetNodeOffset(value: UInt64);
+    procedure SetNodeOffset(AValue: UInt64);
     property NodeOffset: UInt64 read GetNodeOffset write SetNodeOffset;
 
     function GetIsLastNode: Boolean;
-    procedure SetIsLastNode(value: Boolean);
+    procedure SetIsLastNode(AValue: Boolean);
     property IsLastNode: Boolean read GetIsLastNode write SetIsLastNode;
 
   end;

+ 2 - 2
src/libraries/hashlib4pascal/HlpICRC.pas

@@ -19,8 +19,8 @@ type
     property Width: Int32 read GetWidth;
     function GetPolynomial: UInt64;
     property Polynomial: UInt64 read GetPolynomial;
-    function GetInitial: UInt64;
-    property Initial: UInt64 read GetInitial;
+    function GetInitialValue: UInt64;
+    property InitialVlaue: UInt64 read GetInitialValue;
     function GetIsInputReflected: Boolean;
     property IsInputReflected: Boolean read GetIsInputReflected;
     function GetIsOutputReflected: Boolean;

+ 25 - 29
src/libraries/hashlib4pascal/HlpIHash.pas

@@ -5,57 +5,53 @@ unit HlpIHash;
 interface
 
 uses
-
-{$IFDEF HAS_UNITSCOPE}
-  System.SysUtils,
-  System.Classes,
-{$ELSE}
   SysUtils,
   Classes,
-{$ENDIF HAS_UNITSCOPE}
   HlpHashLibTypes,
   HlpIHashResult;
 
 type
   IHash = interface(IInterface)
     ['{E91711E1-FD37-4AFD-875A-DD122470D269}']
-    function GetName: String;
-    property Name: String read GetName;
+
     function GetBlockSize: Int32;
     property BlockSize: Int32 read GetBlockSize;
+
     function GetHashSize: Int32;
     property HashSize: Int32 read GetHashSize;
+
     function GetBufferSize: Int32;
-    procedure SetBufferSize(value: Int32);
+    procedure SetBufferSize(AValue: Int32);
     property BufferSize: Int32 read GetBufferSize write SetBufferSize;
 
-    function ComputeString(const a_data: String; a_encoding: TEncoding)
-      : IHashResult;
-    function ComputeBytes(const a_data: THashLibByteArray): IHashResult;
-    function ComputeUntyped(const a_data; a_length: Int64): IHashResult;
-    function ComputeStream(const a_stream: TStream; a_length: Int64 = -1)
-      : IHashResult;
-    function ComputeFile(const a_file_name: String; a_from: Int64 = 0;
-      a_length: Int64 = -1): IHashResult;
+    function GetName: String;
+    property Name: String read GetName;
 
     procedure Initialize();
 
-    procedure TransformBytes(const a_data: THashLibByteArray); overload;
-    procedure TransformBytes(const a_data: THashLibByteArray;
-      a_index: Int32); overload;
-    procedure TransformBytes(const a_data: THashLibByteArray; a_index: Int32;
-      a_length: Int32); overload;
-    procedure TransformUntyped(const a_data; a_length: Int64);
+    procedure TransformString(const AData: String; const AEncoding: TEncoding);
+    procedure TransformBytes(const AData: THashLibByteArray); overload;
+    procedure TransformBytes(const AData: THashLibByteArray;
+      AIndex: Int32); overload;
+    procedure TransformBytes(const AData: THashLibByteArray; AIndex: Int32;
+      ALength: Int32); overload;
+    procedure TransformUntyped(const AData; ALength: Int64);
+    procedure TransformStream(const AStream: TStream; ALength: Int64 = -1);
+    procedure TransformFile(const AFileName: String; AFrom: Int64 = 0;
+      ALength: Int64 = -1);
 
     function TransformFinal(): IHashResult;
 
-    function Clone(): IHash;
+    function ComputeString(const AData: String; AEncoding: TEncoding)
+      : IHashResult;
+    function ComputeBytes(const AData: THashLibByteArray): IHashResult;
+    function ComputeUntyped(const AData; ALength: Int64): IHashResult;
+    function ComputeStream(const AStream: TStream; ALength: Int64 = -1)
+      : IHashResult;
+    function ComputeFile(const AFileName: String; AFrom: Int64 = 0;
+      ALength: Int64 = -1): IHashResult;
 
-    procedure TransformString(const a_data: String;
-      const a_encoding: TEncoding);
-    procedure TransformStream(const a_stream: TStream; a_length: Int64 = -1);
-    procedure TransformFile(const a_file_name: String; a_from: Int64 = 0;
-      a_length: Int64 = -1);
+    function Clone(): IHash;
 
   end;
 

+ 2 - 2
src/libraries/hashlib4pascal/HlpIHashInfo.pas

@@ -41,7 +41,7 @@ type
     ['{DD5E0FE4-3573-4051-B7CF-F23BABE982D8}']
 
     function GetKey(): THashLibByteArray;
-    procedure SetKey(const value: THashLibByteArray);
+    procedure SetKey(const AValue: THashLibByteArray);
     property Key: THashLibByteArray read GetKey write SetKey;
     function GetKeyLength(): TNullableInteger;
     property KeyLength: TNullableInteger read GetKeyLength;
@@ -104,7 +104,7 @@ type
   IXOF = Interface(IHash)
     ['{944ED7F0-D033-4489-A5DD-9C83353F23F0}']
     function GetXOFSizeInBits: UInt32;
-    procedure SetXOFSizeInBits(a_xof_size_in_bits: UInt32);
+    procedure SetXOFSizeInBits(AXofSizeInBits: UInt32);
     property XOFSizeInBits: UInt32 read GetXOFSizeInBits write SetXOFSizeInBits;
   end;
 

+ 2 - 2
src/libraries/hashlib4pascal/HlpIHashResult.pas

@@ -17,8 +17,8 @@ type
     function GetUInt32(): UInt32;
     function GetInt32(): Int32;
     function GetUInt64(): UInt64;
-    function ToString(a_group: Boolean = false): String;
-    function Equals(const a_hashResult: IHashResult): Boolean; overload;
+    function ToString(AGroup: Boolean = False): String;
+    function Equals(const AHashResult: IHashResult): Boolean; overload;
     function GetHashCode(): {$IFDEF DELPHI}Int32; {$ELSE}PtrInt;
 {$ENDIF DELPHI}
   end;

+ 3 - 3
src/libraries/hashlib4pascal/HlpIKDF.pas

@@ -15,11 +15,11 @@ type
     /// <summary>
     /// Returns the pseudo-random bytes for this object.
     /// </summary>
-    /// <param name="bc">The number of pseudo-random key bytes to generate.</param>
+    /// <param name="AByteCount">The number of pseudo-random key bytes to generate.</param>
     /// <returns>A byte array filled with pseudo-random key bytes.</returns>
-    /// <exception cref="EArgumentOutOfRangeHashLibException">bc must be greater than zero.</exception>
+    /// <exception cref="EArgumentOutOfRangeHashLibException">AByteCount must be greater than zero.</exception>
     /// <exception cref="EArgumentHashLibException">invalid start index or end index of internal buffer.</exception>
-    function GetBytes(bc: Int32): THashLibByteArray;
+    function GetBytes(AByteCount: Int32): THashLibByteArray;
 
   end;
 

+ 21 - 23
src/libraries/hashlib4pascal/HlpJS.pas

@@ -15,14 +15,14 @@ uses
 type
   TJS = class sealed(THash, IHash32, ITransformBlock)
   strict private
-
-    Fm_hash: UInt32;
+  var
+    FHash: UInt32;
 
   public
     constructor Create();
     procedure Initialize(); override;
-    procedure TransformBytes(const a_data: THashLibByteArray;
-      a_index, a_length: Int32); override;
+    procedure TransformBytes(const AData: THashLibByteArray;
+      AIndex, ALength: Int32); override;
     function TransformFinal(): IHashResult; override;
     function Clone(): IHash; override;
   end;
@@ -33,48 +33,46 @@ implementation
 
 function TJS.Clone(): IHash;
 var
-  HashInstance: TJS;
+  LHashInstance: TJS;
 begin
-  HashInstance := TJS.Create();
-  HashInstance.Fm_hash := Fm_hash;
-  result := HashInstance as IHash;
+  LHashInstance := TJS.Create();
+  LHashInstance.FHash := FHash;
+  result := LHashInstance as IHash;
   result.BufferSize := BufferSize;
 end;
 
 constructor TJS.Create;
 begin
   Inherited Create(4, 1);
-
 end;
 
 procedure TJS.Initialize;
 begin
-  Fm_hash := 1315423911;
+  FHash := 1315423911;
 end;
 
-procedure TJS.TransformBytes(const a_data: THashLibByteArray;
-  a_index, a_length: Int32);
+procedure TJS.TransformBytes(const AData: THashLibByteArray;
+  AIndex, ALength: Int32);
 var
-  i: Int32;
+  LIdx: Int32;
 begin
 {$IFDEF DEBUG}
-  System.Assert(a_index >= 0);
-  System.Assert(a_length >= 0);
-  System.Assert(a_index + a_length <= System.Length(a_data));
+  System.Assert(AIndex >= 0);
+  System.Assert(ALength >= 0);
+  System.Assert(AIndex + ALength <= System.Length(AData));
 {$ENDIF DEBUG}
-  i := a_index;
-  while a_length > 0 do
+  LIdx := AIndex;
+  while ALength > 0 do
   begin
-    Fm_hash := Fm_hash xor ((Fm_hash shl 5) + a_data[i] + (Fm_hash shr 2));
-    System.Inc(i);
-    System.Dec(a_length);
+    FHash := FHash xor ((FHash shl 5) + AData[LIdx] + (FHash shr 2));
+    System.Inc(LIdx);
+    System.Dec(ALength);
   end;
-
 end;
 
 function TJS.TransformFinal: IHashResult;
 begin
-  result := THashResult.Create(Fm_hash);
+  result := THashResult.Create(FHash);
   Initialize();
 end;
 

+ 285 - 299
src/libraries/hashlib4pascal/HlpJenkins3.pas

@@ -24,7 +24,7 @@ type
     FInitialValue: Int32;
 
   strict protected
-    function ComputeAggregatedBytes(const a_data: THashLibByteArray)
+    function ComputeAggregatedBytes(const AData: THashLibByteArray)
       : IHashResult; override;
   public
     constructor Create(AInitialValue: Int32 = 0);
@@ -44,374 +44,360 @@ end;
 
 function TJenkins3.Clone(): IHash;
 var
-  HashInstance: TJenkins3;
+  LHashInstance: TJenkins3;
 begin
-  HashInstance := TJenkins3.Create();
+  LHashInstance := TJenkins3.Create();
   FBuffer.Position := 0;
-  HashInstance.FInitialValue := FInitialValue;
-  HashInstance.FBuffer.CopyFrom(FBuffer, FBuffer.Size);
-  result := HashInstance as IHash;
+  LHashInstance.FInitialValue := FInitialValue;
+  LHashInstance.FBuffer.CopyFrom(FBuffer, FBuffer.Size);
+  result := LHashInstance as IHash;
   result.BufferSize := BufferSize;
 end;
 
-function TJenkins3.ComputeAggregatedBytes(const a_data: THashLibByteArray)
+function TJenkins3.ComputeAggregatedBytes(const AData: THashLibByteArray)
   : IHashResult;
 var
-  &length, currentIndex, i1, i2, i3, i4: Int32;
-  a, b, c: UInt32;
+  LLength, LCurrentIndex, I1, I2, I3, I4: Int32;
+  LA, LB, LC: UInt32;
 begin
-  length := System.length(a_data);
-  a := UInt32($DEADBEEF) + UInt32(length) + UInt32(FInitialValue);
-  b := a;
-  c := b;
-  if (length = 0) then
+  LLength := System.length(AData);
+  LA := UInt32($DEADBEEF) + UInt32(LLength) + UInt32(FInitialValue);
+  LB := LA;
+  LC := LB;
+  if (LLength = 0) then
   begin
-    result := THashResult.Create(c);
+    result := THashResult.Create(LC);
     Exit;
   end;
 
-  currentIndex := 0;
-  while (length > 12) do
+  LCurrentIndex := 0;
+  while (LLength > 12) do
   begin
-
-    i1 := a_data[currentIndex];
-    System.Inc(currentIndex);
-    i2 := a_data[currentIndex] shl 8;
-    System.Inc(currentIndex);
-    i3 := a_data[currentIndex] shl 16;
-    System.Inc(currentIndex);
-    i4 := a_data[currentIndex] shl 24;
-    System.Inc(currentIndex);
-
-    a := a + UInt32(i1 or i2 or i3 or i4);
-
-    i1 := a_data[currentIndex];
-    System.Inc(currentIndex);
-    i2 := a_data[currentIndex] shl 8;
-    System.Inc(currentIndex);
-    i3 := a_data[currentIndex] shl 16;
-    System.Inc(currentIndex);
-    i4 := a_data[currentIndex] shl 24;
-    System.Inc(currentIndex);
-
-    b := b + UInt32(i1 or i2 or i3 or i4);
-
-    i1 := a_data[currentIndex];
-    System.Inc(currentIndex);
-    i2 := a_data[currentIndex] shl 8;
-    System.Inc(currentIndex);
-    i3 := a_data[currentIndex] shl 16;
-    System.Inc(currentIndex);
-    i4 := a_data[currentIndex] shl 24;
-    System.Inc(currentIndex);
-
-    c := c + UInt32(i1 or i2 or i3 or i4);
-
-    a := a - c;
-    a := a xor TBits.RotateLeft32(c, 4);
-    c := c + b;
-    b := b - a;
-    b := b xor TBits.RotateLeft32(a, 6);
-    a := a + c;
-    c := c - b;
-    c := c xor TBits.RotateLeft32(b, 8);
-    b := b + a;
-    a := a - c;
-    a := a xor TBits.RotateLeft32(c, 16);
-    c := c + b;
-    b := b - a;
-    b := b xor TBits.RotateLeft32(a, 19);
-    a := a + c;
-    c := c - b;
-    c := c xor TBits.RotateLeft32(b, 4);
-    b := b + a;
-
-    System.Dec(length, 12);
+    I1 := AData[LCurrentIndex];
+    System.Inc(LCurrentIndex);
+    I2 := AData[LCurrentIndex] shl 8;
+    System.Inc(LCurrentIndex);
+    I3 := AData[LCurrentIndex] shl 16;
+    System.Inc(LCurrentIndex);
+    I4 := AData[LCurrentIndex] shl 24;
+    System.Inc(LCurrentIndex);
+
+    LA := LA + UInt32(I1 or I2 or I3 or I4);
+
+    I1 := AData[LCurrentIndex];
+    System.Inc(LCurrentIndex);
+    I2 := AData[LCurrentIndex] shl 8;
+    System.Inc(LCurrentIndex);
+    I3 := AData[LCurrentIndex] shl 16;
+    System.Inc(LCurrentIndex);
+    I4 := AData[LCurrentIndex] shl 24;
+    System.Inc(LCurrentIndex);
+
+    LB := LB + UInt32(I1 or I2 or I3 or I4);
+
+    I1 := AData[LCurrentIndex];
+    System.Inc(LCurrentIndex);
+    I2 := AData[LCurrentIndex] shl 8;
+    System.Inc(LCurrentIndex);
+    I3 := AData[LCurrentIndex] shl 16;
+    System.Inc(LCurrentIndex);
+    I4 := AData[LCurrentIndex] shl 24;
+    System.Inc(LCurrentIndex);
+
+    LC := LC + UInt32(I1 or I2 or I3 or I4);
+
+    LA := LA - LC;
+    LA := LA xor TBits.RotateLeft32(LC, 4);
+    LC := LC + LB;
+    LB := LB - LA;
+    LB := LB xor TBits.RotateLeft32(LA, 6);
+    LA := LA + LC;
+    LC := LC - LB;
+    LC := LC xor TBits.RotateLeft32(LB, 8);
+    LB := LB + LA;
+    LA := LA - LC;
+    LA := LA xor TBits.RotateLeft32(LC, 16);
+    LC := LC + LB;
+    LB := LB - LA;
+    LB := LB xor TBits.RotateLeft32(LA, 19);
+    LA := LA + LC;
+    LC := LC - LB;
+    LC := LC xor TBits.RotateLeft32(LB, 4);
+    LB := LB + LA;
+
+    System.Dec(LLength, 12);
   end;
 
-  case length of
+  case LLength of
     12:
       begin
-        i1 := a_data[currentIndex];
-        System.Inc(currentIndex);
-        i2 := a_data[currentIndex] shl 8;
-        System.Inc(currentIndex);
-        i3 := a_data[currentIndex] shl 16;
-        System.Inc(currentIndex);
-        i4 := a_data[currentIndex] shl 24;
-        System.Inc(currentIndex);
-
-        a := a + UInt32(i1 or i2 or i3 or i4);
-
-        i1 := a_data[currentIndex];
-        System.Inc(currentIndex);
-        i2 := a_data[currentIndex] shl 8;
-        System.Inc(currentIndex);
-        i3 := a_data[currentIndex] shl 16;
-        System.Inc(currentIndex);
-        i4 := a_data[currentIndex] shl 24;
-        System.Inc(currentIndex);
-
-        b := b + UInt32(i1 or i2 or i3 or i4);
-
-        i1 := a_data[currentIndex];
-        System.Inc(currentIndex);
-        i2 := a_data[currentIndex] shl 8;
-        System.Inc(currentIndex);
-        i3 := a_data[currentIndex] shl 16;
-        System.Inc(currentIndex);
-        i4 := a_data[currentIndex] shl 24;
-
-        c := c + UInt32(i1 or i2 or i3 or i4);
+        I1 := AData[LCurrentIndex];
+        System.Inc(LCurrentIndex);
+        I2 := AData[LCurrentIndex] shl 8;
+        System.Inc(LCurrentIndex);
+        I3 := AData[LCurrentIndex] shl 16;
+        System.Inc(LCurrentIndex);
+        I4 := AData[LCurrentIndex] shl 24;
+        System.Inc(LCurrentIndex);
+
+        LA := LA + UInt32(I1 or I2 or I3 or I4);
+
+        I1 := AData[LCurrentIndex];
+        System.Inc(LCurrentIndex);
+        I2 := AData[LCurrentIndex] shl 8;
+        System.Inc(LCurrentIndex);
+        I3 := AData[LCurrentIndex] shl 16;
+        System.Inc(LCurrentIndex);
+        I4 := AData[LCurrentIndex] shl 24;
+        System.Inc(LCurrentIndex);
+
+        LB := LB + UInt32(I1 or I2 or I3 or I4);
+
+        I1 := AData[LCurrentIndex];
+        System.Inc(LCurrentIndex);
+        I2 := AData[LCurrentIndex] shl 8;
+        System.Inc(LCurrentIndex);
+        I3 := AData[LCurrentIndex] shl 16;
+        System.Inc(LCurrentIndex);
+        I4 := AData[LCurrentIndex] shl 24;
+
+        LC := LC + UInt32(I1 or I2 or I3 or I4);
       end;
 
     11:
       begin
-        i1 := a_data[currentIndex];
-        System.Inc(currentIndex);
-        i2 := a_data[currentIndex] shl 8;
-        System.Inc(currentIndex);
-        i3 := a_data[currentIndex] shl 16;
-        System.Inc(currentIndex);
-        i4 := a_data[currentIndex] shl 24;
-        System.Inc(currentIndex);
-
-        a := a + UInt32(i1 or i2 or i3 or i4);
-
-        i1 := a_data[currentIndex];
-        System.Inc(currentIndex);
-        i2 := a_data[currentIndex] shl 8;
-        System.Inc(currentIndex);
-        i3 := a_data[currentIndex] shl 16;
-        System.Inc(currentIndex);
-        i4 := a_data[currentIndex] shl 24;
-        System.Inc(currentIndex);
-
-        b := b + UInt32(i1 or i2 or i3 or i4);
-
-        i1 := a_data[currentIndex];
-        System.Inc(currentIndex);
-        i2 := a_data[currentIndex] shl 8;
-        System.Inc(currentIndex);
-        i3 := a_data[currentIndex] shl 16;
-
-        c := c + UInt32(i1 or i2 or i3);
-
+        I1 := AData[LCurrentIndex];
+        System.Inc(LCurrentIndex);
+        I2 := AData[LCurrentIndex] shl 8;
+        System.Inc(LCurrentIndex);
+        I3 := AData[LCurrentIndex] shl 16;
+        System.Inc(LCurrentIndex);
+        I4 := AData[LCurrentIndex] shl 24;
+        System.Inc(LCurrentIndex);
+
+        LA := LA + UInt32(I1 or I2 or I3 or I4);
+
+        I1 := AData[LCurrentIndex];
+        System.Inc(LCurrentIndex);
+        I2 := AData[LCurrentIndex] shl 8;
+        System.Inc(LCurrentIndex);
+        I3 := AData[LCurrentIndex] shl 16;
+        System.Inc(LCurrentIndex);
+        I4 := AData[LCurrentIndex] shl 24;
+        System.Inc(LCurrentIndex);
+
+        LB := LB + UInt32(I1 or I2 or I3 or I4);
+
+        I1 := AData[LCurrentIndex];
+        System.Inc(LCurrentIndex);
+        I2 := AData[LCurrentIndex] shl 8;
+        System.Inc(LCurrentIndex);
+        I3 := AData[LCurrentIndex] shl 16;
+
+        LC := LC + UInt32(I1 or I2 or I3);
       end;
 
     10:
       begin
-        i1 := a_data[currentIndex];
-        System.Inc(currentIndex);
-        i2 := a_data[currentIndex] shl 8;
-        System.Inc(currentIndex);
-        i3 := a_data[currentIndex] shl 16;
-        System.Inc(currentIndex);
-        i4 := a_data[currentIndex] shl 24;
-        System.Inc(currentIndex);
-
-        a := a + UInt32(i1 or i2 or i3 or i4);
-
-        i1 := a_data[currentIndex];
-        System.Inc(currentIndex);
-        i2 := a_data[currentIndex] shl 8;
-        System.Inc(currentIndex);
-        i3 := a_data[currentIndex] shl 16;
-        System.Inc(currentIndex);
-        i4 := a_data[currentIndex] shl 24;
-        System.Inc(currentIndex);
-
-        b := b + UInt32(i1 or i2 or i3 or i4);
-
-        i1 := a_data[currentIndex];
-        System.Inc(currentIndex);
-        i2 := a_data[currentIndex] shl 8;
-
-        c := c + UInt32(i1 or i2);
-
+        I1 := AData[LCurrentIndex];
+        System.Inc(LCurrentIndex);
+        I2 := AData[LCurrentIndex] shl 8;
+        System.Inc(LCurrentIndex);
+        I3 := AData[LCurrentIndex] shl 16;
+        System.Inc(LCurrentIndex);
+        I4 := AData[LCurrentIndex] shl 24;
+        System.Inc(LCurrentIndex);
+
+        LA := LA + UInt32(I1 or I2 or I3 or I4);
+
+        I1 := AData[LCurrentIndex];
+        System.Inc(LCurrentIndex);
+        I2 := AData[LCurrentIndex] shl 8;
+        System.Inc(LCurrentIndex);
+        I3 := AData[LCurrentIndex] shl 16;
+        System.Inc(LCurrentIndex);
+        I4 := AData[LCurrentIndex] shl 24;
+        System.Inc(LCurrentIndex);
+
+        LB := LB + UInt32(I1 or I2 or I3 or I4);
+
+        I1 := AData[LCurrentIndex];
+        System.Inc(LCurrentIndex);
+        I2 := AData[LCurrentIndex] shl 8;
+
+        LC := LC + UInt32(I1 or I2);
       end;
 
     9:
       begin
-        i1 := a_data[currentIndex];
-        System.Inc(currentIndex);
-        i2 := a_data[currentIndex] shl 8;
-        System.Inc(currentIndex);
-        i3 := a_data[currentIndex] shl 16;
-        System.Inc(currentIndex);
-        i4 := a_data[currentIndex] shl 24;
-        System.Inc(currentIndex);
-
-        a := a + UInt32(i1 or i2 or i3 or i4);
-
-        i1 := a_data[currentIndex];
-        System.Inc(currentIndex);
-        i2 := a_data[currentIndex] shl 8;
-        System.Inc(currentIndex);
-        i3 := a_data[currentIndex] shl 16;
-        System.Inc(currentIndex);
-        i4 := a_data[currentIndex] shl 24;
-        System.Inc(currentIndex);
-
-        b := b + UInt32(i1 or i2 or i3 or i4);
-
-        i1 := a_data[currentIndex];
-
-        c := c + UInt32(i1);
-
+        I1 := AData[LCurrentIndex];
+        System.Inc(LCurrentIndex);
+        I2 := AData[LCurrentIndex] shl 8;
+        System.Inc(LCurrentIndex);
+        I3 := AData[LCurrentIndex] shl 16;
+        System.Inc(LCurrentIndex);
+        I4 := AData[LCurrentIndex] shl 24;
+        System.Inc(LCurrentIndex);
+
+        LA := LA + UInt32(I1 or I2 or I3 or I4);
+
+        I1 := AData[LCurrentIndex];
+        System.Inc(LCurrentIndex);
+        I2 := AData[LCurrentIndex] shl 8;
+        System.Inc(LCurrentIndex);
+        I3 := AData[LCurrentIndex] shl 16;
+        System.Inc(LCurrentIndex);
+        I4 := AData[LCurrentIndex] shl 24;
+        System.Inc(LCurrentIndex);
+
+        LB := LB + UInt32(I1 or I2 or I3 or I4);
+
+        I1 := AData[LCurrentIndex];
+
+        LC := LC + UInt32(I1);
       end;
 
     8:
       begin
-        i1 := a_data[currentIndex];
-        System.Inc(currentIndex);
-        i2 := a_data[currentIndex] shl 8;
-        System.Inc(currentIndex);
-        i3 := a_data[currentIndex] shl 16;
-        System.Inc(currentIndex);
-        i4 := a_data[currentIndex] shl 24;
-        System.Inc(currentIndex);
-
-        a := a + UInt32(i1 or i2 or i3 or i4);
-
-        i1 := a_data[currentIndex];
-        System.Inc(currentIndex);
-        i2 := a_data[currentIndex] shl 8;
-        System.Inc(currentIndex);
-        i3 := a_data[currentIndex] shl 16;
-        System.Inc(currentIndex);
-        i4 := a_data[currentIndex] shl 24;
-
-        b := b + UInt32(i1 or i2 or i3 or i4);
-
+        I1 := AData[LCurrentIndex];
+        System.Inc(LCurrentIndex);
+        I2 := AData[LCurrentIndex] shl 8;
+        System.Inc(LCurrentIndex);
+        I3 := AData[LCurrentIndex] shl 16;
+        System.Inc(LCurrentIndex);
+        I4 := AData[LCurrentIndex] shl 24;
+        System.Inc(LCurrentIndex);
+
+        LA := LA + UInt32(I1 or I2 or I3 or I4);
+
+        I1 := AData[LCurrentIndex];
+        System.Inc(LCurrentIndex);
+        I2 := AData[LCurrentIndex] shl 8;
+        System.Inc(LCurrentIndex);
+        I3 := AData[LCurrentIndex] shl 16;
+        System.Inc(LCurrentIndex);
+        I4 := AData[LCurrentIndex] shl 24;
+
+        LB := LB + UInt32(I1 or I2 or I3 or I4);
       end;
 
     7:
       begin
-        i1 := a_data[currentIndex];
-        System.Inc(currentIndex);
-        i2 := a_data[currentIndex] shl 8;
-        System.Inc(currentIndex);
-        i3 := a_data[currentIndex] shl 16;
-        System.Inc(currentIndex);
-        i4 := a_data[currentIndex] shl 24;
-        System.Inc(currentIndex);
-
-        a := a + UInt32(i1 or i2 or i3 or i4);
-
-        i1 := a_data[currentIndex];
-        System.Inc(currentIndex);
-        i2 := a_data[currentIndex] shl 8;
-        System.Inc(currentIndex);
-        i3 := a_data[currentIndex] shl 16;
-
-        b := b + UInt32(i1 or i2 or i3);
-
+        I1 := AData[LCurrentIndex];
+        System.Inc(LCurrentIndex);
+        I2 := AData[LCurrentIndex] shl 8;
+        System.Inc(LCurrentIndex);
+        I3 := AData[LCurrentIndex] shl 16;
+        System.Inc(LCurrentIndex);
+        I4 := AData[LCurrentIndex] shl 24;
+        System.Inc(LCurrentIndex);
+
+        LA := LA + UInt32(I1 or I2 or I3 or I4);
+
+        I1 := AData[LCurrentIndex];
+        System.Inc(LCurrentIndex);
+        I2 := AData[LCurrentIndex] shl 8;
+        System.Inc(LCurrentIndex);
+        I3 := AData[LCurrentIndex] shl 16;
+
+        LB := LB + UInt32(I1 or I2 or I3);
       end;
 
     6:
       begin
-        i1 := a_data[currentIndex];
-        System.Inc(currentIndex);
-        i2 := a_data[currentIndex] shl 8;
-        System.Inc(currentIndex);
-        i3 := a_data[currentIndex] shl 16;
-        System.Inc(currentIndex);
-        i4 := a_data[currentIndex] shl 24;
-        System.Inc(currentIndex);
-
-        a := a + UInt32(i1 or i2 or i3 or i4);
-
-        i1 := a_data[currentIndex];
-        System.Inc(currentIndex);
-        i2 := a_data[currentIndex] shl 8;
-
-        b := b + UInt32(i1 or i2);
-
+        I1 := AData[LCurrentIndex];
+        System.Inc(LCurrentIndex);
+        I2 := AData[LCurrentIndex] shl 8;
+        System.Inc(LCurrentIndex);
+        I3 := AData[LCurrentIndex] shl 16;
+        System.Inc(LCurrentIndex);
+        I4 := AData[LCurrentIndex] shl 24;
+        System.Inc(LCurrentIndex);
+
+        LA := LA + UInt32(I1 or I2 or I3 or I4);
+
+        I1 := AData[LCurrentIndex];
+        System.Inc(LCurrentIndex);
+        I2 := AData[LCurrentIndex] shl 8;
+
+        LB := LB + UInt32(I1 or I2);
       end;
 
     5:
       begin
-        i1 := a_data[currentIndex];
-        System.Inc(currentIndex);
-        i2 := a_data[currentIndex] shl 8;
-        System.Inc(currentIndex);
-        i3 := a_data[currentIndex] shl 16;
-        System.Inc(currentIndex);
-        i4 := a_data[currentIndex] shl 24;
-        System.Inc(currentIndex);
-
-        a := a + UInt32(i1 or i2 or i3 or i4);
+        I1 := AData[LCurrentIndex];
+        System.Inc(LCurrentIndex);
+        I2 := AData[LCurrentIndex] shl 8;
+        System.Inc(LCurrentIndex);
+        I3 := AData[LCurrentIndex] shl 16;
+        System.Inc(LCurrentIndex);
+        I4 := AData[LCurrentIndex] shl 24;
+        System.Inc(LCurrentIndex);
 
-        i1 := a_data[currentIndex];
+        LA := LA + UInt32(I1 or I2 or I3 or I4);
 
-        b := b + UInt32(i1);
+        I1 := AData[LCurrentIndex];
 
+        LB := LB + UInt32(I1);
       end;
 
     4:
       begin
-        i1 := a_data[currentIndex];
-        System.Inc(currentIndex);
-        i2 := a_data[currentIndex] shl 8;
-        System.Inc(currentIndex);
-        i3 := a_data[currentIndex] shl 16;
-        System.Inc(currentIndex);
-        i4 := a_data[currentIndex] shl 24;
-
-        a := a + UInt32(i1 or i2 or i3 or i4);
-
+        I1 := AData[LCurrentIndex];
+        System.Inc(LCurrentIndex);
+        I2 := AData[LCurrentIndex] shl 8;
+        System.Inc(LCurrentIndex);
+        I3 := AData[LCurrentIndex] shl 16;
+        System.Inc(LCurrentIndex);
+        I4 := AData[LCurrentIndex] shl 24;
+
+        LA := LA + UInt32(I1 or I2 or I3 or I4);
       end;
 
     3:
       begin
-        i1 := a_data[currentIndex];
-        System.Inc(currentIndex);
-        i2 := a_data[currentIndex] shl 8;
-        System.Inc(currentIndex);
-        i3 := a_data[currentIndex] shl 16;
-
-        a := a + UInt32(i1 or i2 or i3);
+        I1 := AData[LCurrentIndex];
+        System.Inc(LCurrentIndex);
+        I2 := AData[LCurrentIndex] shl 8;
+        System.Inc(LCurrentIndex);
+        I3 := AData[LCurrentIndex] shl 16;
 
+        LA := LA + UInt32(I1 or I2 or I3);
       end;
 
     2:
       begin
-        i1 := a_data[currentIndex];
-        System.Inc(currentIndex);
-        i2 := a_data[currentIndex] shl 8;
-
-        a := a + UInt32(i1 or i2);
+        I1 := AData[LCurrentIndex];
+        System.Inc(LCurrentIndex);
+        I2 := AData[LCurrentIndex] shl 8;
 
+        LA := LA + UInt32(I1 or I2);
       end;
 
     1:
       begin
-        i1 := a_data[currentIndex];
-
-        a := a + UInt32(i1);
+        I1 := AData[LCurrentIndex];
 
+        LA := LA + UInt32(I1);
       end;
-
   end;
 
-  c := c xor b;
-  c := c - TBits.RotateLeft32(b, 14);
-  a := a xor c;
-  a := a - TBits.RotateLeft32(c, 11);
-  b := b xor a;
-  b := b - TBits.RotateLeft32(a, 25);
-  c := c xor b;
-  c := c - TBits.RotateLeft32(b, 16);
-  a := a xor c;
-  a := a - TBits.RotateLeft32(c, 4);
-  b := b xor a;
-  b := b - TBits.RotateLeft32(a, 14);
-  c := c xor b;
-  c := c - TBits.RotateLeft32(b, 24);
-
-  result := THashResult.Create(c);
-
+  LC := LC xor LB;
+  LC := LC - TBits.RotateLeft32(LB, 14);
+  LA := LA xor LC;
+  LA := LA - TBits.RotateLeft32(LC, 11);
+  LB := LB xor LA;
+  LB := LB - TBits.RotateLeft32(LA, 25);
+  LC := LC xor LB;
+  LC := LC - TBits.RotateLeft32(LB, 16);
+  LA := LA xor LC;
+  LA := LA - TBits.RotateLeft32(LC, 4);
+  LB := LB xor LA;
+  LB := LB - TBits.RotateLeft32(LA, 14);
+  LC := LC xor LB;
+  LC := LC - TBits.RotateLeft32(LB, 24);
+
+  result := THashResult.Create(LC);
 end;
 
 end.

+ 2 - 2
src/libraries/hashlib4pascal/HlpKDF.pas

@@ -28,11 +28,11 @@ type
     /// <summary>
     /// Returns the pseudo-random bytes for this object.
     /// </summary>
-    /// <param name="bc">The number of pseudo-random key bytes to generate.</param>
+    /// <param name="AByteCount">The number of pseudo-random key bytes to generate.</param>
     /// <returns>A byte array filled with pseudo-random key bytes.</returns>
     /// <exception cref="EArgumentOutOfRangeHashLibException">bc must be greater than zero.</exception>
     /// <exception cref="EArgumentHashLibException">invalid start index or end index of internal buffer.</exception>
-    function GetBytes(bc: Int32): THashLibByteArray; virtual; abstract;
+    function GetBytes(AByteCount: Int32): THashLibByteArray; virtual; abstract;
 
   end;
 

+ 47 - 56
src/libraries/hashlib4pascal/HlpMD2.pas

@@ -19,13 +19,13 @@ type
   TMD2 = class sealed(TBlockHash, ICryptoNotBuildIn, ITransformBlock)
 
   strict private
-    Fm_state, Fm_checksum: THashLibByteArray;
+  var
+    FState, FChecksum: THashLibByteArray;
 
 {$REGION 'Consts'}
 
   const
-
-    s_pi: array [0 .. 255] of Byte = (41, 46, 67, 201, 162, 216, 124, 1, 61, 54,
+    SPi: array [0 .. 255] of Byte = (41, 46, 67, 201, 162, 216, 124, 1, 61, 54,
       84, 161, 236, 240, 6, 19,
 
       98, 167, 5, 243, 192, 199, 115, 140, 152, 147, 43, 217, 188, 76, 130, 202,
@@ -65,8 +65,8 @@ type
   strict protected
     procedure Finish(); override;
     function GetResult(): THashLibByteArray; override;
-    procedure TransformBlock(a_data: PByte; a_data_length: Int32;
-      a_index: Int32); override;
+    procedure TransformBlock(AData: PByte; ADataLength: Int32;
+      AIndex: Int32); override;
 
   public
     constructor Create();
@@ -81,104 +81,95 @@ implementation
 
 function TMD2.Clone(): IHash;
 var
-  HashInstance: TMD2;
+  LHashInstance: TMD2;
 begin
-  HashInstance := TMD2.Create();
-  HashInstance.Fm_state := System.Copy(Fm_state);
-  HashInstance.Fm_checksum := System.Copy(Fm_checksum);
-  HashInstance.Fm_buffer := Fm_buffer.Clone();
-  HashInstance.Fm_processed_bytes := Fm_processed_bytes;
-  result := HashInstance as IHash;
+  LHashInstance := TMD2.Create();
+  LHashInstance.FState := System.Copy(FState);
+  LHashInstance.FChecksum := System.Copy(FChecksum);
+  LHashInstance.FBuffer := FBuffer.Clone();
+  LHashInstance.FProcessedBytesCount := FProcessedBytesCount;
+  result := LHashInstance as IHash;
   result.BufferSize := BufferSize;
 end;
 
 constructor TMD2.Create;
 begin
   Inherited Create(16, 16);
-  System.SetLength(Fm_state, 16);
-  System.SetLength(Fm_checksum, 16);
-
+  System.SetLength(FState, 16);
+  System.SetLength(FChecksum, 16);
 end;
 
 procedure TMD2.Finish;
 var
-  padLen, i: Int32;
-  pad: THashLibByteArray;
+  LPadLength, LIdx: Int32;
+  LPad: THashLibByteArray;
 begin
-  padLen := 16 - Fm_buffer.Pos;
-  System.SetLength(pad, padLen);
+  LPadLength := 16 - FBuffer.Position;
+  System.SetLength(LPad, LPadLength);
 
-  i := 0;
-  while i < padLen do
+  LIdx := 0;
+  while LIdx < LPadLength do
   begin
-    pad[i] := Byte(padLen);
-    System.Inc(i);
+    LPad[LIdx] := Byte(LPadLength);
+    System.Inc(LIdx);
   end;
 
-  TransformBytes(pad, 0, padLen);
-  TransformBytes(Fm_checksum, 0, 16);
+  TransformBytes(LPad, 0, LPadLength);
+  TransformBytes(FChecksum, 0, 16);
 end;
 
 function TMD2.GetResult: THashLibByteArray;
 begin
-  result := System.Copy(Fm_state);
+  result := System.Copy(FState);
 end;
 
 procedure TMD2.Initialize;
 begin
-
-  TArrayUtils.ZeroFill(Fm_state);
-  TArrayUtils.ZeroFill(Fm_checksum);
-
+  TArrayUtils.ZeroFill(FState);
+  TArrayUtils.ZeroFill(FChecksum);
   Inherited Initialize();
-
 end;
 
-procedure TMD2.TransformBlock(a_data: PByte; a_data_length: Int32;
-  a_index: Int32);
+procedure TMD2.TransformBlock(AData: PByte; ADataLength: Int32; AIndex: Int32);
 var
-  i, j: Int32;
-  t: UInt32;
-  temp: array [0 .. 47] of Byte;
-
+  LIdx, LJdx: Int32;
+  LT: UInt32;
+  LTemp: array [0 .. 47] of Byte;
 begin
+  System.Move(FState[0], LTemp[0], ADataLength);
 
-  System.Move(Fm_state[0], temp[0], a_data_length);
-
-  System.Move(a_data[a_index], temp[a_data_length], a_data_length);
+  System.Move(AData[AIndex], LTemp[ADataLength], ADataLength);
 
-  for i := 0 to 15 do
+  for LIdx := 0 to 15 do
   begin
-    temp[i + 32] := Byte(Fm_state[i] xor a_data[i + a_index]);
+    LTemp[LIdx + 32] := Byte(FState[LIdx] xor AData[LIdx + AIndex]);
   end;
 
-  t := 0;
+  LT := 0;
 
-  for i := 0 to 17 do
+  for LIdx := 0 to 17 do
   begin
 
-    for j := 0 to 47 do
+    for LJdx := 0 to 47 do
     begin
-      temp[j] := Byte(temp[j] xor s_pi[t]);
-      t := temp[j];
+      LTemp[LJdx] := Byte(LTemp[LJdx] xor SPi[LT]);
+      LT := LTemp[LJdx];
     end;
 
-    t := Byte(t + UInt32(i));
+    LT := Byte(LT + UInt32(LIdx));
   end;
 
-  System.Move(temp[0], Fm_state[0], 16);
+  System.Move(LTemp[0], FState[0], 16);
 
-  t := Fm_checksum[15];
+  LT := FChecksum[15];
 
-  for i := 0 to 15 do
+  for LIdx := 0 to 15 do
   begin
-
-    Fm_checksum[i] := Fm_checksum[i] xor (s_pi[a_data[i + a_index] xor t]);
-    t := Fm_checksum[i];
+    FChecksum[LIdx] := FChecksum[LIdx] xor (SPi[AData[LIdx + AIndex] xor LT]);
+    LT := FChecksum[LIdx];
   end;
 
-  System.FillChar(temp, System.SizeOf(temp), Byte(0));
-
+  System.FillChar(LTemp, System.SizeOf(LTemp), Byte(0));
 end;
 
 end.

+ 68 - 70
src/libraries/hashlib4pascal/HlpMD4.pas

@@ -23,8 +23,8 @@ type
   TMD4 = class sealed(TMDBase, ITransformBlock)
 
   strict protected
-    procedure TransformBlock(a_data: PByte; a_data_length: Int32;
-      a_index: Int32); override;
+    procedure TransformBlock(AData: PByte; ADataLength: Int32;
+      AIndex: Int32); override;
 
   public
     constructor Create();
@@ -38,13 +38,13 @@ implementation
 
 function TMD4.Clone(): IHash;
 var
-  HashInstance: TMD4;
+  LHashInstance: TMD4;
 begin
-  HashInstance := TMD4.Create();
-  HashInstance.Fm_state := System.Copy(Fm_state);
-  HashInstance.Fm_buffer := Fm_buffer.Clone();
-  HashInstance.Fm_processed_bytes := Fm_processed_bytes;
-  result := HashInstance as IHash;
+  LHashInstance := TMD4.Create();
+  LHashInstance.FState := System.Copy(FState);
+  LHashInstance.FBuffer := FBuffer.Clone();
+  LHashInstance.FProcessedBytesCount := FProcessedBytesCount;
+  result := LHashInstance as IHash;
   result.BufferSize := BufferSize;
 end;
 
@@ -53,125 +53,123 @@ begin
   Inherited Create(4, 16);
 end;
 
-procedure TMD4.TransformBlock(a_data: PByte; a_data_length: Int32;
-  a_index: Int32);
+procedure TMD4.TransformBlock(AData: PByte; ADataLength: Int32; AIndex: Int32);
 var
   a, b, c, d: UInt32;
-  data: array [0 .. 15] of UInt32;
+  LData: array [0 .. 15] of UInt32;
 begin
+  TConverters.le32_copy(AData, AIndex, @(LData[0]), 0, ADataLength);
 
-  TConverters.le32_copy(a_data, a_index, @(data[0]), 0, a_data_length);
+  a := FState[0];
+  b := FState[1];
+  c := FState[2];
+  d := FState[3];
 
-  a := Fm_state[0];
-  b := Fm_state[1];
-  c := Fm_state[2];
-  d := Fm_state[3];
-
-  a := a + (data[0] + ((b and c) or ((not b) and d)));
+  a := a + (LData[0] + ((b and c) or ((not b) and d)));
   a := TBits.RotateLeft32(a, 3);
-  d := d + (data[1] + ((a and b) or ((not a) and c)));
+  d := d + (LData[1] + ((a and b) or ((not a) and c)));
   d := TBits.RotateLeft32(d, 7);
-  c := c + (data[2] + ((d and a) or ((not d) and b)));
+  c := c + (LData[2] + ((d and a) or ((not d) and b)));
   c := TBits.RotateLeft32(c, 11);
-  b := b + (data[3] + ((c and d) or ((not c) and a)));
+  b := b + (LData[3] + ((c and d) or ((not c) and a)));
   b := TBits.RotateLeft32(b, 19);
-  a := a + (data[4] + ((b and c) or ((not b) and d)));
+  a := a + (LData[4] + ((b and c) or ((not b) and d)));
   a := TBits.RotateLeft32(a, 3);
-  d := d + (data[5] + ((a and b) or ((not a) and c)));
+  d := d + (LData[5] + ((a and b) or ((not a) and c)));
   d := TBits.RotateLeft32(d, 7);
-  c := c + (data[6] + ((d and a) or ((not d) and b)));
+  c := c + (LData[6] + ((d and a) or ((not d) and b)));
   c := TBits.RotateLeft32(c, 11);
-  b := b + (data[7] + ((c and d) or ((not c) and a)));
+  b := b + (LData[7] + ((c and d) or ((not c) and a)));
   b := TBits.RotateLeft32(b, 19);
-  a := a + (data[8] + ((b and c) or ((not b) and d)));
+  a := a + (LData[8] + ((b and c) or ((not b) and d)));
   a := TBits.RotateLeft32(a, 3);
-  d := d + (data[9] + ((a and b) or ((not a) and c)));
+  d := d + (LData[9] + ((a and b) or ((not a) and c)));
   d := TBits.RotateLeft32(d, 7);
-  c := c + (data[10] + ((d and a) or ((not d) and b)));
+  c := c + (LData[10] + ((d and a) or ((not d) and b)));
   c := TBits.RotateLeft32(c, 11);
-  b := b + (data[11] + ((c and d) or ((not c) and a)));
+  b := b + (LData[11] + ((c and d) or ((not c) and a)));
   b := TBits.RotateLeft32(b, 19);
-  a := a + (data[12] + ((b and c) or ((not b) and d)));
+  a := a + (LData[12] + ((b and c) or ((not b) and d)));
   a := TBits.RotateLeft32(a, 3);
-  d := d + (data[13] + ((a and b) or ((not a) and c)));
+  d := d + (LData[13] + ((a and b) or ((not a) and c)));
   d := TBits.RotateLeft32(d, 7);
-  c := c + (data[14] + ((d and a) or ((not d) and b)));
+  c := c + (LData[14] + ((d and a) or ((not d) and b)));
   c := TBits.RotateLeft32(c, 11);
-  b := b + (data[15] + ((c and d) or ((not c) and a)));
+  b := b + (LData[15] + ((c and d) or ((not c) and a)));
   b := TBits.RotateLeft32(b, 19);
 
-  a := a + (data[0] + C2 + ((b and (c or d)) or (c and d)));
+  a := a + (LData[0] + C2 + ((b and (c or d)) or (c and d)));
   a := TBits.RotateLeft32(a, 3);
-  d := d + (data[4] + C2 + ((a and (b or c)) or (b and c)));
+  d := d + (LData[4] + C2 + ((a and (b or c)) or (b and c)));
   d := TBits.RotateLeft32(d, 5);
-  c := c + (data[8] + C2 + ((d and (a or b)) or (a and b)));
+  c := c + (LData[8] + C2 + ((d and (a or b)) or (a and b)));
   c := TBits.RotateLeft32(c, 9);
-  b := b + (data[12] + C2 + ((c and (d or a)) or (d and a)));
+  b := b + (LData[12] + C2 + ((c and (d or a)) or (d and a)));
   b := TBits.RotateLeft32(b, 13);
-  a := a + (data[1] + C2 + ((b and (c or d)) or (c and d)));
+  a := a + (LData[1] + C2 + ((b and (c or d)) or (c and d)));
   a := TBits.RotateLeft32(a, 3);
-  d := d + (data[5] + C2 + ((a and (b or c)) or (b and c)));
+  d := d + (LData[5] + C2 + ((a and (b or c)) or (b and c)));
   d := TBits.RotateLeft32(d, 5);
-  c := c + (data[9] + C2 + ((d and (a or b)) or (a and b)));
+  c := c + (LData[9] + C2 + ((d and (a or b)) or (a and b)));
   c := TBits.RotateLeft32(c, 9);
-  b := b + (data[13] + C2 + ((c and (d or a)) or (d and a)));
+  b := b + (LData[13] + C2 + ((c and (d or a)) or (d and a)));
   b := TBits.RotateLeft32(b, 13);
-  a := a + (data[2] + C2 + ((b and (c or d)) or (c and d)));
+  a := a + (LData[2] + C2 + ((b and (c or d)) or (c and d)));
   a := TBits.RotateLeft32(a, 3);
-  d := d + (data[6] + C2 + ((a and (b or c)) or (b and c)));
+  d := d + (LData[6] + C2 + ((a and (b or c)) or (b and c)));
   d := TBits.RotateLeft32(d, 5);
-  c := c + (data[10] + C2 + ((d and (a or b)) or (a and b)));
+  c := c + (LData[10] + C2 + ((d and (a or b)) or (a and b)));
   c := TBits.RotateLeft32(c, 9);
-  b := b + (data[14] + C2 + ((c and (d or a)) or (d and a)));
+  b := b + (LData[14] + C2 + ((c and (d or a)) or (d and a)));
   b := TBits.RotateLeft32(b, 13);
-  a := a + (data[3] + C2 + ((b and (c or d)) or (c and d)));
+  a := a + (LData[3] + C2 + ((b and (c or d)) or (c and d)));
   a := TBits.RotateLeft32(a, 3);
-  d := d + (data[7] + C2 + ((a and (b or c)) or (b and c)));
+  d := d + (LData[7] + C2 + ((a and (b or c)) or (b and c)));
   d := TBits.RotateLeft32(d, 5);
-  c := c + (data[11] + C2 + ((d and (a or b)) or (a and b)));
+  c := c + (LData[11] + C2 + ((d and (a or b)) or (a and b)));
   c := TBits.RotateLeft32(c, 9);
-  b := b + (data[15] + C2 + ((c and (d or a)) or (d and a)));
+  b := b + (LData[15] + C2 + ((c and (d or a)) or (d and a)));
   b := TBits.RotateLeft32(b, 13);
 
-  a := a + (data[0] + C4 + (b xor c xor d));
+  a := a + (LData[0] + C4 + (b xor c xor d));
   a := TBits.RotateLeft32(a, 3);
-  d := d + (data[8] + C4 + (a xor b xor c));
+  d := d + (LData[8] + C4 + (a xor b xor c));
   d := TBits.RotateLeft32(d, 9);
-  c := c + (data[4] + C4 + (d xor a xor b));
+  c := c + (LData[4] + C4 + (d xor a xor b));
   c := TBits.RotateLeft32(c, 11);
-  b := b + (data[12] + C4 + (c xor d xor a));
+  b := b + (LData[12] + C4 + (c xor d xor a));
   b := TBits.RotateLeft32(b, 15);
-  a := a + (data[2] + C4 + (b xor c xor d));
+  a := a + (LData[2] + C4 + (b xor c xor d));
   a := TBits.RotateLeft32(a, 3);
-  d := d + (data[10] + C4 + (a xor b xor c));
+  d := d + (LData[10] + C4 + (a xor b xor c));
   d := TBits.RotateLeft32(d, 9);
-  c := c + (data[6] + C4 + (d xor a xor b));
+  c := c + (LData[6] + C4 + (d xor a xor b));
   c := TBits.RotateLeft32(c, 11);
-  b := b + (data[14] + C4 + (c xor d xor a));
+  b := b + (LData[14] + C4 + (c xor d xor a));
   b := TBits.RotateLeft32(b, 15);
-  a := a + (data[1] + C4 + (b xor c xor d));
+  a := a + (LData[1] + C4 + (b xor c xor d));
   a := TBits.RotateLeft32(a, 3);
-  d := d + (data[9] + C4 + (a xor b xor c));
+  d := d + (LData[9] + C4 + (a xor b xor c));
   d := TBits.RotateLeft32(d, 9);
-  c := c + (data[5] + C4 + (d xor a xor b));
+  c := c + (LData[5] + C4 + (d xor a xor b));
   c := TBits.RotateLeft32(c, 11);
-  b := b + (data[13] + C4 + (c xor d xor a));
+  b := b + (LData[13] + C4 + (c xor d xor a));
   b := TBits.RotateLeft32(b, 15);
-  a := a + (data[3] + C4 + (b xor c xor d));
+  a := a + (LData[3] + C4 + (b xor c xor d));
   a := TBits.RotateLeft32(a, 3);
-  d := d + (data[11] + C4 + (a xor b xor c));
+  d := d + (LData[11] + C4 + (a xor b xor c));
   d := TBits.RotateLeft32(d, 9);
-  c := c + (data[7] + C4 + (d xor a xor b));
+  c := c + (LData[7] + C4 + (d xor a xor b));
   c := TBits.RotateLeft32(c, 11);
-  b := b + (data[15] + C4 + (c xor d xor a));
+  b := b + (LData[15] + C4 + (c xor d xor a));
   b := TBits.RotateLeft32(b, 15);
 
-  Fm_state[0] := Fm_state[0] + a;
-  Fm_state[1] := Fm_state[1] + b;
-  Fm_state[2] := Fm_state[2] + c;
-  Fm_state[3] := Fm_state[3] + d;
+  FState[0] := FState[0] + a;
+  FState[1] := FState[1] + b;
+  FState[2] := FState[2] + c;
+  FState[3] := FState[3] + d;
 
-  System.FillChar(data, System.SizeOf(data), UInt32(0));
+  System.FillChar(LData, System.SizeOf(LData), UInt32(0));
 end;
 
 end.

+ 84 - 87
src/libraries/hashlib4pascal/HlpMD5.pas

@@ -23,8 +23,8 @@ type
   TMD5 = class sealed(TMDBase, ITransformBlock)
 
   strict protected
-    procedure TransformBlock(a_data: PByte; a_data_length: Int32;
-      a_index: Int32); override;
+    procedure TransformBlock(AData: PByte; ADataLength: Int32;
+      AIndex: Int32); override;
 
   public
     constructor Create();
@@ -38,13 +38,13 @@ implementation
 
 function TMD5.Clone(): IHash;
 var
-  HashInstance: TMD5;
+  LHashInstance: TMD5;
 begin
-  HashInstance := TMD5.Create();
-  HashInstance.Fm_state := System.Copy(Fm_state);
-  HashInstance.Fm_buffer := Fm_buffer.Clone();
-  HashInstance.Fm_processed_bytes := Fm_processed_bytes;
-  result := HashInstance as IHash;
+  LHashInstance := TMD5.Create();
+  LHashInstance.FState := System.Copy(FState);
+  LHashInstance.FBuffer := FBuffer.Clone();
+  LHashInstance.FProcessedBytesCount := FProcessedBytesCount;
+  result := LHashInstance as IHash;
   result.BufferSize := BufferSize;
 end;
 
@@ -53,159 +53,156 @@ begin
   Inherited Create(4, 16);
 end;
 
-procedure TMD5.TransformBlock(a_data: PByte; a_data_length: Int32;
-  a_index: Int32);
+procedure TMD5.TransformBlock(AData: PByte; ADataLength: Int32; AIndex: Int32);
 var
   A, B, C, D: UInt32;
-  data: array [0 .. 15] of UInt32;
+  LData: array [0 .. 15] of UInt32;
 begin
+  TConverters.le32_copy(AData, AIndex, @(LData[0]), 0, ADataLength);
 
-  TConverters.le32_copy(a_data, a_index, @(data[0]), 0, a_data_length);
+  A := FState[0];
+  B := FState[1];
+  C := FState[2];
+  D := FState[3];
 
-  A := Fm_state[0];
-  B := Fm_state[1];
-  C := Fm_state[2];
-  D := Fm_state[3];
-
-  A := data[0] + $D76AA478 + A + ((B and C) or (not B and D));
+  A := LData[0] + $D76AA478 + A + ((B and C) or (not B and D));
   A := TBits.RotateLeft32(A, 7) + B;
-  D := data[1] + $E8C7B756 + D + ((A and B) or (not A and C));
+  D := LData[1] + $E8C7B756 + D + ((A and B) or (not A and C));
   D := TBits.RotateLeft32(D, 12) + A;
-  C := data[2] + $242070DB + C + ((D and A) or (not D and B));
+  C := LData[2] + $242070DB + C + ((D and A) or (not D and B));
   C := TBits.RotateLeft32(C, 17) + D;
-  B := data[3] + $C1BDCEEE + B + ((C and D) or (not C and A));
+  B := LData[3] + $C1BDCEEE + B + ((C and D) or (not C and A));
   B := TBits.RotateLeft32(B, 22) + C;
-  A := data[4] + $F57C0FAF + A + ((B and C) or (not B and D));
+  A := LData[4] + $F57C0FAF + A + ((B and C) or (not B and D));
   A := TBits.RotateLeft32(A, 7) + B;
-  D := data[5] + $4787C62A + D + ((A and B) or (not A and C));
+  D := LData[5] + $4787C62A + D + ((A and B) or (not A and C));
   D := TBits.RotateLeft32(D, 12) + A;
-  C := data[6] + $A8304613 + C + ((D and A) or (not D and B));
+  C := LData[6] + $A8304613 + C + ((D and A) or (not D and B));
   C := TBits.RotateLeft32(C, 17) + D;
-  B := data[7] + $FD469501 + B + ((C and D) or (not C and A));
+  B := LData[7] + $FD469501 + B + ((C and D) or (not C and A));
   B := TBits.RotateLeft32(B, 22) + C;
-  A := data[8] + $698098D8 + A + ((B and C) or (not B and D));
+  A := LData[8] + $698098D8 + A + ((B and C) or (not B and D));
   A := TBits.RotateLeft32(A, 7) + B;
-  D := data[9] + $8B44F7AF + D + ((A and B) or (not A and C));
+  D := LData[9] + $8B44F7AF + D + ((A and B) or (not A and C));
   D := TBits.RotateLeft32(D, 12) + A;
-  C := data[10] + $FFFF5BB1 + C + ((D and A) or (not D and B));
+  C := LData[10] + $FFFF5BB1 + C + ((D and A) or (not D and B));
   C := TBits.RotateLeft32(C, 17) + D;
-  B := data[11] + $895CD7BE + B + ((C and D) or (not C and A));
+  B := LData[11] + $895CD7BE + B + ((C and D) or (not C and A));
   B := TBits.RotateLeft32(B, 22) + C;
-  A := data[12] + $6B901122 + A + ((B and C) or (not B and D));
+  A := LData[12] + $6B901122 + A + ((B and C) or (not B and D));
   A := TBits.RotateLeft32(A, 7) + B;
-  D := data[13] + $FD987193 + D + ((A and B) or (not A and C));
+  D := LData[13] + $FD987193 + D + ((A and B) or (not A and C));
   D := TBits.RotateLeft32(D, 12) + A;
-  C := data[14] + $A679438E + C + ((D and A) or (not D and B));
+  C := LData[14] + $A679438E + C + ((D and A) or (not D and B));
   C := TBits.RotateLeft32(C, 17) + D;
-  B := data[15] + $49B40821 + B + ((C and D) or (not C and A));
+  B := LData[15] + $49B40821 + B + ((C and D) or (not C and A));
   B := TBits.RotateLeft32(B, 22) + C;
 
-  A := data[1] + $F61E2562 + A + ((B and D) or (C and not D));
+  A := LData[1] + $F61E2562 + A + ((B and D) or (C and not D));
   A := TBits.RotateLeft32(A, 5) + B;
-  D := data[6] + $C040B340 + D + ((A and C) or (B and not C));
+  D := LData[6] + $C040B340 + D + ((A and C) or (B and not C));
   D := TBits.RotateLeft32(D, 9) + A;
-  C := data[11] + $265E5A51 + C + ((D and B) or (A and not B));
+  C := LData[11] + $265E5A51 + C + ((D and B) or (A and not B));
   C := TBits.RotateLeft32(C, 14) + D;
-  B := data[0] + $E9B6C7AA + B + ((C and A) or (D and not A));
+  B := LData[0] + $E9B6C7AA + B + ((C and A) or (D and not A));
   B := TBits.RotateLeft32(B, 20) + C;
-  A := data[5] + $D62F105D + A + ((B and D) or (C and not D));
+  A := LData[5] + $D62F105D + A + ((B and D) or (C and not D));
   A := TBits.RotateLeft32(A, 5) + B;
-  D := data[10] + $2441453 + D + ((A and C) or (B and not C));
+  D := LData[10] + $2441453 + D + ((A and C) or (B and not C));
   D := TBits.RotateLeft32(D, 9) + A;
-  C := data[15] + $D8A1E681 + C + ((D and B) or (A and not B));
+  C := LData[15] + $D8A1E681 + C + ((D and B) or (A and not B));
   C := TBits.RotateLeft32(C, 14) + D;
-  B := data[4] + $E7D3FBC8 + B + ((C and A) or (D and not A));
+  B := LData[4] + $E7D3FBC8 + B + ((C and A) or (D and not A));
   B := TBits.RotateLeft32(B, 20) + C;
-  A := data[9] + $21E1CDE6 + A + ((B and D) or (C and not D));
+  A := LData[9] + $21E1CDE6 + A + ((B and D) or (C and not D));
   A := TBits.RotateLeft32(A, 5) + B;
-  D := data[14] + $C33707D6 + D + ((A and C) or (B and not C));
+  D := LData[14] + $C33707D6 + D + ((A and C) or (B and not C));
   D := TBits.RotateLeft32(D, 9) + A;
-  C := data[3] + $F4D50D87 + C + ((D and B) or (A and not B));
+  C := LData[3] + $F4D50D87 + C + ((D and B) or (A and not B));
   C := TBits.RotateLeft32(C, 14) + D;
-  B := data[8] + $455A14ED + B + ((C and A) or (D and not A));
+  B := LData[8] + $455A14ED + B + ((C and A) or (D and not A));
   B := TBits.RotateLeft32(B, 20) + C;
-  A := data[13] + $A9E3E905 + A + ((B and D) or (C and not D));
+  A := LData[13] + $A9E3E905 + A + ((B and D) or (C and not D));
   A := TBits.RotateLeft32(A, 5) + B;
-  D := data[2] + $FCEFA3F8 + D + ((A and C) or (B and not C));
+  D := LData[2] + $FCEFA3F8 + D + ((A and C) or (B and not C));
   D := TBits.RotateLeft32(D, 9) + A;
-  C := data[7] + $676F02D9 + C + ((D and B) or (A and not B));
+  C := LData[7] + $676F02D9 + C + ((D and B) or (A and not B));
   C := TBits.RotateLeft32(C, 14) + D;
-  B := data[12] + $8D2A4C8A + B + ((C and A) or (D and not A));
+  B := LData[12] + $8D2A4C8A + B + ((C and A) or (D and not A));
   B := TBits.RotateLeft32(B, 20) + C;
 
-  A := data[5] + $FFFA3942 + A + (B xor C xor D);
+  A := LData[5] + $FFFA3942 + A + (B xor C xor D);
   A := TBits.RotateLeft32(A, 4) + B;
-  D := data[8] + $8771F681 + D + (A xor B xor C);
+  D := LData[8] + $8771F681 + D + (A xor B xor C);
   D := TBits.RotateLeft32(D, 11) + A;
-  C := data[11] + $6D9D6122 + C + (D xor A xor B);
+  C := LData[11] + $6D9D6122 + C + (D xor A xor B);
   C := TBits.RotateLeft32(C, 16) + D;
-  B := data[14] + $FDE5380C + B + (C xor D xor A);
+  B := LData[14] + $FDE5380C + B + (C xor D xor A);
   B := TBits.RotateLeft32(B, 23) + C;
-  A := data[1] + $A4BEEA44 + A + (B xor C xor D);
+  A := LData[1] + $A4BEEA44 + A + (B xor C xor D);
   A := TBits.RotateLeft32(A, 4) + B;
-  D := data[4] + $4BDECFA9 + D + (A xor B xor C);
+  D := LData[4] + $4BDECFA9 + D + (A xor B xor C);
   D := TBits.RotateLeft32(D, 11) + A;
-  C := data[7] + $F6BB4B60 + C + (D xor A xor B);
+  C := LData[7] + $F6BB4B60 + C + (D xor A xor B);
   C := TBits.RotateLeft32(C, 16) + D;
-  B := data[10] + $BEBFBC70 + B + (C xor D xor A);
+  B := LData[10] + $BEBFBC70 + B + (C xor D xor A);
   B := TBits.RotateLeft32(B, 23) + C;
-  A := data[13] + $289B7EC6 + A + (B xor C xor D);
+  A := LData[13] + $289B7EC6 + A + (B xor C xor D);
   A := TBits.RotateLeft32(A, 4) + B;
-  D := data[0] + $EAA127FA + D + (A xor B xor C);
+  D := LData[0] + $EAA127FA + D + (A xor B xor C);
   D := TBits.RotateLeft32(D, 11) + A;
-  C := data[3] + $D4EF3085 + C + (D xor A xor B);
+  C := LData[3] + $D4EF3085 + C + (D xor A xor B);
   C := TBits.RotateLeft32(C, 16) + D;
-  B := data[6] + $4881D05 + B + (C xor D xor A);
+  B := LData[6] + $4881D05 + B + (C xor D xor A);
   B := TBits.RotateLeft32(B, 23) + C;
-  A := data[9] + $D9D4D039 + A + (B xor C xor D);
+  A := LData[9] + $D9D4D039 + A + (B xor C xor D);
   A := TBits.RotateLeft32(A, 4) + B;
-  D := data[12] + $E6DB99E5 + D + (A xor B xor C);
+  D := LData[12] + $E6DB99E5 + D + (A xor B xor C);
   D := TBits.RotateLeft32(D, 11) + A;
-  C := data[15] + $1FA27CF8 + C + (D xor A xor B);
+  C := LData[15] + $1FA27CF8 + C + (D xor A xor B);
   C := TBits.RotateLeft32(C, 16) + D;
-  B := data[2] + $C4AC5665 + B + (C xor D xor A);
+  B := LData[2] + $C4AC5665 + B + (C xor D xor A);
   B := TBits.RotateLeft32(B, 23) + C;
 
-  A := data[0] + $F4292244 + A + (C xor (B or not D));
+  A := LData[0] + $F4292244 + A + (C xor (B or not D));
   A := TBits.RotateLeft32(A, 6) + B;
-  D := data[7] + $432AFF97 + D + (B xor (A or not C));
+  D := LData[7] + $432AFF97 + D + (B xor (A or not C));
   D := TBits.RotateLeft32(D, 10) + A;
-  C := data[14] + $AB9423A7 + C + (A xor (D or not B));
+  C := LData[14] + $AB9423A7 + C + (A xor (D or not B));
   C := TBits.RotateLeft32(C, 15) + D;
-  B := data[5] + $FC93A039 + B + (D xor (C or not A));
+  B := LData[5] + $FC93A039 + B + (D xor (C or not A));
   B := TBits.RotateLeft32(B, 21) + C;
-  A := data[12] + $655B59C3 + A + (C xor (B or not D));
+  A := LData[12] + $655B59C3 + A + (C xor (B or not D));
   A := TBits.RotateLeft32(A, 6) + B;
-  D := data[3] + $8F0CCC92 + D + (B xor (A or not C));
+  D := LData[3] + $8F0CCC92 + D + (B xor (A or not C));
   D := TBits.RotateLeft32(D, 10) + A;
-  C := data[10] + $FFEFF47D + C + (A xor (D or not B));
+  C := LData[10] + $FFEFF47D + C + (A xor (D or not B));
   C := TBits.RotateLeft32(C, 15) + D;
-  B := data[1] + $85845DD1 + B + (D xor (C or not A));
+  B := LData[1] + $85845DD1 + B + (D xor (C or not A));
   B := TBits.RotateLeft32(B, 21) + C;
-  A := data[8] + $6FA87E4F + A + (C xor (B or not D));
+  A := LData[8] + $6FA87E4F + A + (C xor (B or not D));
   A := TBits.RotateLeft32(A, 6) + B;
-  D := data[15] + $FE2CE6E0 + D + (B xor (A or not C));
+  D := LData[15] + $FE2CE6E0 + D + (B xor (A or not C));
   D := TBits.RotateLeft32(D, 10) + A;
-  C := data[6] + $A3014314 + C + (A xor (D or not B));
+  C := LData[6] + $A3014314 + C + (A xor (D or not B));
   C := TBits.RotateLeft32(C, 15) + D;
-  B := data[13] + $4E0811A1 + B + (D xor (C or not A));
+  B := LData[13] + $4E0811A1 + B + (D xor (C or not A));
   B := TBits.RotateLeft32(B, 21) + C;
-  A := data[4] + $F7537E82 + A + (C xor (B or not D));
+  A := LData[4] + $F7537E82 + A + (C xor (B or not D));
   A := TBits.RotateLeft32(A, 6) + B;
-  D := data[11] + $BD3AF235 + D + (B xor (A or not C));
+  D := LData[11] + $BD3AF235 + D + (B xor (A or not C));
   D := TBits.RotateLeft32(D, 10) + A;
-  C := data[2] + $2AD7D2BB + C + (A xor (D or not B));
+  C := LData[2] + $2AD7D2BB + C + (A xor (D or not B));
   C := TBits.RotateLeft32(C, 15) + D;
-  B := data[9] + $EB86D391 + B + (D xor (C or not A));
+  B := LData[9] + $EB86D391 + B + (D xor (C or not A));
   B := TBits.RotateLeft32(B, 21) + C;
 
-  Fm_state[0] := Fm_state[0] + A;
-  Fm_state[1] := Fm_state[1] + B;
-  Fm_state[2] := Fm_state[2] + C;
-  Fm_state[3] := Fm_state[3] + D;
-
-  System.FillChar(data, System.SizeOf(data), UInt32(0));
+  FState[0] := FState[0] + A;
+  FState[1] := FState[1] + B;
+  FState[2] := FState[2] + C;
+  FState[3] := FState[3] + D;
 
+  System.FillChar(LData, System.SizeOf(LData), UInt32(0));
 end;
 
 end.

+ 29 - 29
src/libraries/hashlib4pascal/HlpMDBase.pas

@@ -21,7 +21,8 @@ type
   TMDBase = class abstract(TBlockHash, ICryptoNotBuildIn)
 
   strict protected
-    Fm_state: THashLibUInt32Array;
+  var
+    FState: THashLibUInt32Array;
 
   const
 
@@ -34,7 +35,7 @@ type
     C7 = UInt32($7A6D76E9);
     C8 = UInt32($A953FD4E);
 
-    constructor Create(a_state_length, a_hash_size: Int32);
+    constructor Create(AStateLength, AHashSize: Int32);
 
     function GetResult(): THashLibByteArray; override;
     procedure Finish(); override;
@@ -48,55 +49,54 @@ implementation
 
 { TMDBase }
 
-constructor TMDBase.Create(a_state_length, a_hash_size: Int32);
+constructor TMDBase.Create(AStateLength, AHashSize: Int32);
 begin
-  Inherited Create(a_hash_size, 64);
-  System.SetLength(Fm_state, a_state_length);
+  Inherited Create(AHashSize, 64);
+  System.SetLength(FState, AStateLength);
 end;
 
 procedure TMDBase.Finish;
 var
-  bits: UInt64;
-  padindex: Int32;
-  pad: THashLibByteArray;
+  LBits: UInt64;
+  LPadIndex: Int32;
+  LPad: THashLibByteArray;
 begin
-  bits := Fm_processed_bytes * 8;
-  if (Fm_buffer.Pos < 56) then
-    padindex := 56 - Fm_buffer.Pos
+  LBits := FProcessedBytesCount * 8;
+  if (FBuffer.Position < 56) then
+  begin
+    LPadIndex := 56 - FBuffer.Position
+  end
   else
-    padindex := 120 - Fm_buffer.Pos;
-  System.SetLength(pad, padindex + 8);
-
-  pad[0] := $80;
+  begin
+    LPadIndex := 120 - FBuffer.Position;
+  end;
+  System.SetLength(LPad, LPadIndex + 8);
 
-  bits := TConverters.le2me_64(bits);
+  LPad[0] := $80;
 
-  TConverters.ReadUInt64AsBytesLE(bits, pad, padindex);
+  LBits := TConverters.le2me_64(LBits);
 
-  padindex := padindex + 8;
+  TConverters.ReadUInt64AsBytesLE(LBits, LPad, LPadIndex);
 
-  TransformBytes(pad, 0, padindex);
+  LPadIndex := LPadIndex + 8;
 
+  TransformBytes(LPad, 0, LPadIndex);
 end;
 
 function TMDBase.GetResult: THashLibByteArray;
 begin
-
-  System.SetLength(result, System.Length(Fm_state) * System.SizeOf(UInt32));
-
-  TConverters.le32_copy(PCardinal(Fm_state), 0, PByte(result), 0,
+  System.SetLength(result, System.Length(FState) * System.SizeOf(UInt32));
+  TConverters.le32_copy(PCardinal(FState), 0, PByte(result), 0,
     System.Length(result));
-
 end;
 
 procedure TMDBase.Initialize;
 begin
-  Fm_state[0] := $67452301;
-  Fm_state[1] := $EFCDAB89;
-  Fm_state[2] := $98BADCFE;
-  Fm_state[3] := $10325476;
+  FState[0] := $67452301;
+  FState[1] := $EFCDAB89;
+  FState[2] := $98BADCFE;
+  FState[3] := $10325476;
   inherited Initialize();
-
 end;
 
 end.

+ 18 - 21
src/libraries/hashlib4pascal/HlpMultipleTransformNonBlock.pas

@@ -5,11 +5,7 @@ unit HlpMultipleTransformNonBlock;
 interface
 
 uses
-{$IFDEF HAS_UNITSCOPE}
-  System.Classes,
-{$ELSE}
   Classes,
-{$ENDIF HAS_UNITSCOPE}
   HlpHashLibTypes,
   HlpHash,
   HlpIHashInfo,
@@ -24,20 +20,21 @@ type
     function Aggregate(): THashLibByteArray;
 
   strict protected
+  var
     FBuffer: TMemoryStream;
 
-    function ComputeAggregatedBytes(const a_data: THashLibByteArray)
+    function ComputeAggregatedBytes(const AData: THashLibByteArray)
       : IHashResult; virtual; abstract;
 
   public
-    constructor Create(a_hash_size, a_block_size: Int32);
+    constructor Create(AHashSize, ABlockSize: Int32);
     destructor Destroy; override;
     procedure Initialize(); override;
-    procedure TransformBytes(const a_data: THashLibByteArray;
-      a_index, a_length: Int32); override;
+    procedure TransformBytes(const AData: THashLibByteArray;
+      AIndex, ALength: Int32); override;
     function TransformFinal(): IHashResult; override;
-    function ComputeBytes(const a_data: THashLibByteArray)
-      : IHashResult; override;
+    function ComputeBytes(const AData: THashLibByteArray): IHashResult;
+      override;
 
   end;
 
@@ -56,9 +53,9 @@ begin
   end;
 end;
 
-constructor TMultipleTransformNonBlock.Create(a_hash_size, a_block_size: Int32);
+constructor TMultipleTransformNonBlock.Create(AHashSize, ABlockSize: Int32);
 begin
-  Inherited Create(a_hash_size, a_block_size);
+  Inherited Create(AHashSize, ABlockSize);
   FBuffer := TMemoryStream.Create();
 end;
 
@@ -74,15 +71,15 @@ begin
   FBuffer.SetSize(Int64(0));
 end;
 
-procedure TMultipleTransformNonBlock.TransformBytes(const a_data
-  : THashLibByteArray; a_index, a_length: Int32);
+procedure TMultipleTransformNonBlock.TransformBytes
+  (const AData: THashLibByteArray; AIndex, ALength: Int32);
 begin
 {$IFDEF DEBUG}
-  System.Assert(a_index >= 0);
-  System.Assert(a_length >= 0);
-  System.Assert(a_index + a_length <= System.Length(a_data));
+  System.Assert(AIndex >= 0);
+  System.Assert(ALength >= 0);
+  System.Assert(AIndex + ALength <= System.Length(AData));
 {$ENDIF DEBUG}
-  FBuffer.Write(a_data[a_index], a_length);
+  FBuffer.Write(AData[AIndex], ALength);
 end;
 
 function TMultipleTransformNonBlock.TransformFinal: IHashResult;
@@ -91,11 +88,11 @@ begin
   Initialize();
 end;
 
-function TMultipleTransformNonBlock.ComputeBytes(const a_data
-  : THashLibByteArray): IHashResult;
+function TMultipleTransformNonBlock.ComputeBytes(const AData: THashLibByteArray)
+  : IHashResult;
 begin
   Initialize();
-  Result := ComputeAggregatedBytes(a_data);
+  Result := ComputeAggregatedBytes(AData);
 end;
 
 end.

+ 59 - 65
src/libraries/hashlib4pascal/HlpMurmur2.pas

@@ -29,22 +29,22 @@ type
     ITransformBlock)
 
   strict private
-
-    Fm_key, Fm_working_key, Fm_h: UInt32;
+  var
+    FKey, FWorkingKey, FH: UInt32;
 
   const
     CKEY = UInt32($0);
     M = UInt32($5BD1E995);
     R = Int32(24);
 
-    function InternalComputeBytes(const a_data: THashLibByteArray): Int32;
-    procedure TransformUInt32Fast(a_data: UInt32); inline;
+    function InternalComputeBytes(const AData: THashLibByteArray): Int32;
+    procedure TransformUInt32Fast(ABlock: UInt32); inline;
     function GetKeyLength(): TNullableInteger;
     function GetKey: THashLibByteArray; inline;
-    procedure SetKey(const value: THashLibByteArray); inline;
+    procedure SetKey(const AValue: THashLibByteArray); inline;
 
   strict protected
-    function ComputeAggregatedBytes(const a_data: THashLibByteArray)
+    function ComputeAggregatedBytes(const AData: THashLibByteArray)
       : IHashResult; override;
 
   public
@@ -63,38 +63,39 @@ implementation
 constructor TMurmur2.Create;
 begin
   Inherited Create(4, 4);
-  Fm_key := CKEY;
-
+  FKey := CKEY;
 end;
 
 function TMurmur2.GetKey: THashLibByteArray;
 begin
-  result := TConverters.ReadUInt32AsBytesLE(Fm_key);
+  result := TConverters.ReadUInt32AsBytesLE(FKey);
 end;
 
-procedure TMurmur2.SetKey(const value: THashLibByteArray);
+procedure TMurmur2.SetKey(const AValue: THashLibByteArray);
 begin
-  if (value = Nil) then
+  if (AValue = Nil) then
   begin
-    Fm_key := CKEY;
+    FKey := CKEY;
   end
   else
   begin
-    if System.Length(value) <> KeyLength.value then
+    if System.Length(AValue) <> KeyLength.value then
+    begin
       raise EArgumentHashLibException.CreateResFmt(@SInvalidKeyLength,
         [KeyLength.value]);
-    Fm_key := TConverters.ReadBytesAsUInt32LE(PByte(value), 0);
+    end;
+    FKey := TConverters.ReadBytesAsUInt32LE(PByte(AValue), 0);
   end;
 end;
 
-procedure TMurmur2.TransformUInt32Fast(a_data: UInt32);
+procedure TMurmur2.TransformUInt32Fast(ABlock: UInt32);
 begin
-  a_data := a_data * M;
-  a_data := a_data xor (a_data shr R);
-  a_data := a_data * M;
+  ABlock := ABlock * M;
+  ABlock := ABlock xor (ABlock shr R);
+  ABlock := ABlock * M;
 
-  Fm_h := Fm_h * M;
-  Fm_h := Fm_h xor a_data;
+  FH := FH * M;
+  FH := FH xor ABlock;
 end;
 
 function TMurmur2.GetKeyLength: TNullableInteger;
@@ -104,98 +105,91 @@ end;
 
 procedure TMurmur2.Initialize;
 begin
-  Fm_working_key := Fm_key;
+  FWorkingKey := FKey;
   inherited Initialize();
 end;
 
-function TMurmur2.InternalComputeBytes(const a_data: THashLibByteArray): Int32;
+function TMurmur2.InternalComputeBytes(const AData: THashLibByteArray): Int32;
 var
-  &length, current_index: Int32;
-  k: UInt32;
-  ptr_a_data: PByte;
+  LLength, LCurrentIndex: Int32;
+  LBlock: UInt32;
+  LPtrData: PByte;
 begin
-  Length := System.Length(a_data);
-  ptr_a_data := PByte(a_data);
+  LLength := System.Length(AData);
+  LPtrData := PByte(AData);
 
-  if (Length = 0) then
+  if (LLength = 0) then
   begin
     result := 0;
     Exit;
   end;
 
-  Fm_h := Fm_working_key xor UInt32(Length);
-  current_index := 0;
+  FH := FWorkingKey xor UInt32(LLength);
+  LCurrentIndex := 0;
 
-  while (Length >= 4) do
+  while (LLength >= 4) do
   begin
-
-    k := TConverters.ReadBytesAsUInt32LE(ptr_a_data, current_index);
-
-    TransformUInt32Fast(k);
-    System.Inc(current_index, 4);
-    System.Dec(Length, 4);
+    LBlock := TConverters.ReadBytesAsUInt32LE(LPtrData, LCurrentIndex);
+    TransformUInt32Fast(LBlock);
+    System.Inc(LCurrentIndex, 4);
+    System.Dec(LLength, 4);
   end;
 
-  case Length of
+  case LLength of
     3:
       begin
+        FH := FH xor (AData[LCurrentIndex + 2] shl 16);
 
-        Fm_h := Fm_h xor (a_data[current_index + 2] shl 16);
-
-        Fm_h := Fm_h xor (a_data[current_index + 1] shl 8);
+        FH := FH xor (AData[LCurrentIndex + 1] shl 8);
 
-        Fm_h := Fm_h xor (a_data[current_index]);
+        FH := FH xor (AData[LCurrentIndex]);
 
-        Fm_h := Fm_h * M;
+        FH := FH * M;
       end;
 
     2:
       begin
+        FH := FH xor (AData[LCurrentIndex + 1] shl 8);
 
-        Fm_h := Fm_h xor (a_data[current_index + 1] shl 8);
+        FH := FH xor (AData[LCurrentIndex]);
 
-        Fm_h := Fm_h xor (a_data[current_index]);
-
-        Fm_h := Fm_h * M;
+        FH := FH * M;
       end;
 
     1:
       begin
+        FH := FH xor (AData[LCurrentIndex]);
 
-        Fm_h := Fm_h xor (a_data[current_index]);
-
-        Fm_h := Fm_h * M;
+        FH := FH * M;
       end;
-
   end;
 
-  Fm_h := Fm_h xor (Fm_h shr 13);
+  FH := FH xor (FH shr 13);
 
-  Fm_h := Fm_h * M;
-  Fm_h := Fm_h xor (Fm_h shr 15);
+  FH := FH * M;
+  FH := FH xor (FH shr 15);
 
-  result := Int32(Fm_h);
+  result := Int32(FH);
 end;
 
 function TMurmur2.Clone(): IHash;
 var
-  HashInstance: TMurmur2;
+  LHashInstance: TMurmur2;
 begin
-  HashInstance := TMurmur2.Create();
-  HashInstance.Fm_key := Fm_key;
-  HashInstance.Fm_working_key := Fm_working_key;
-  HashInstance.Fm_h := Fm_h;
+  LHashInstance := TMurmur2.Create();
+  LHashInstance.FKey := FKey;
+  LHashInstance.FWorkingKey := FWorkingKey;
+  LHashInstance.FH := FH;
   FBuffer.Position := 0;
-  HashInstance.FBuffer.CopyFrom(FBuffer, FBuffer.Size);
-  result := HashInstance as IHash;
+  LHashInstance.FBuffer.CopyFrom(FBuffer, FBuffer.Size);
+  result := LHashInstance as IHash;
   result.BufferSize := BufferSize;
 end;
 
-function TMurmur2.ComputeAggregatedBytes(const a_data: THashLibByteArray)
+function TMurmur2.ComputeAggregatedBytes(const AData: THashLibByteArray)
   : IHashResult;
-
 begin
-  result := THashResult.Create(InternalComputeBytes(a_data));
+  result := THashResult.Create(InternalComputeBytes(AData));
 end;
 
 end.

+ 99 - 110
src/libraries/hashlib4pascal/HlpMurmur2_64.pas

@@ -26,8 +26,8 @@ type
     ITransformBlock)
 
   strict private
-
-    Fm_key, Fm_working_key: UInt32;
+  var
+    FKey, FWorkingKey: UInt32;
 
   const
     CKEY = UInt32($0);
@@ -43,10 +43,10 @@ type
 
     function GetKeyLength(): TNullableInteger;
     function GetKey: THashLibByteArray; inline;
-    procedure SetKey(const value: THashLibByteArray); inline;
+    procedure SetKey(const AValue: THashLibByteArray); inline;
 
   strict protected
-    function ComputeAggregatedBytes(const a_data: THashLibByteArray)
+    function ComputeAggregatedBytes(const AData: THashLibByteArray)
       : IHashResult; override;
 
   public
@@ -64,191 +64,181 @@ implementation
 
 function TMurmur2_64.Clone(): IHash;
 var
-  HashInstance: TMurmur2_64;
+  LHashInstance: TMurmur2_64;
 begin
-  HashInstance := TMurmur2_64.Create();
-  HashInstance.Fm_key := Fm_key;
-  HashInstance.Fm_working_key := Fm_working_key;
+  LHashInstance := TMurmur2_64.Create();
+  LHashInstance.FKey := FKey;
+  LHashInstance.FWorkingKey := FWorkingKey;
   FBuffer.Position := 0;
-  HashInstance.FBuffer.CopyFrom(FBuffer, FBuffer.Size);
-  result := HashInstance as IHash;
+  LHashInstance.FBuffer.CopyFrom(FBuffer, FBuffer.Size);
+  result := LHashInstance as IHash;
   result.BufferSize := BufferSize;
 end;
 
-function TMurmur2_64.ComputeAggregatedBytes(const a_data: THashLibByteArray)
+function TMurmur2_64.ComputeAggregatedBytes(const AData: THashLibByteArray)
   : IHashResult;
 var
-  &length, current_index: Int32;
-  h, k: UInt64;
-  ptr_a_data: PByte;
+  LLength, LCurrentIndex: Int32;
+  LH, LK: UInt64;
+  LPtrData: PByte;
 begin
+  LLength := System.length(AData);
+  LPtrData := PByte(AData);
 
-  length := System.length(a_data);
-  ptr_a_data := PByte(a_data);
-
-  if (length = 0) then
+  if (LLength = 0) then
   begin
     result := THashResult.Create(UInt64(0));
     Exit;
   end;
 
-  h := Fm_working_key xor UInt64(length);
-  current_index := 0;
+  LH := FWorkingKey xor UInt64(LLength);
+  LCurrentIndex := 0;
 
-  while (length >= 8) do
+  while (LLength >= 8) do
   begin
 
-    k := TConverters.ReadBytesAsUInt64LE(ptr_a_data, current_index);
+    LK := TConverters.ReadBytesAsUInt64LE(LPtrData, LCurrentIndex);
 
-    k := k * M;
-    k := k xor (k shr R);
-    k := k * M;
+    LK := LK * M;
+    LK := LK xor (LK shr R);
+    LK := LK * M;
 
-    h := h xor k;
-    h := h * M;
+    LH := LH xor LK;
+    LH := LH * M;
 
-    System.Inc(current_index, 8);
-    System.Dec(length, 8);
+    System.Inc(LCurrentIndex, 8);
+    System.Dec(LLength, 8);
 
   end;
 
-  case length of
+  case LLength of
     7:
       begin
+        LH := LH xor ((UInt64(AData[LCurrentIndex]) shl 48));
+        System.Inc(LCurrentIndex);
 
-        h := h xor ((UInt64(a_data[current_index]) shl 48));
-        System.Inc(current_index);
+        LH := LH xor (UInt64(AData[LCurrentIndex]) shl 40);
+        System.Inc(LCurrentIndex);
 
-        h := h xor (UInt64(a_data[current_index]) shl 40);
-        System.Inc(current_index);
+        LH := LH xor (UInt64(AData[LCurrentIndex]) shl 32);
+        System.Inc(LCurrentIndex);
 
-        h := h xor (UInt64(a_data[current_index]) shl 32);
-        System.Inc(current_index);
+        LH := LH xor (UInt64(AData[LCurrentIndex]) shl 24);
+        System.Inc(LCurrentIndex);
 
-        h := h xor (UInt64(a_data[current_index]) shl 24);
-        System.Inc(current_index);
+        LH := LH xor (UInt64(AData[LCurrentIndex]) shl 16);
+        System.Inc(LCurrentIndex);
 
-        h := h xor (UInt64(a_data[current_index]) shl 16);
-        System.Inc(current_index);
+        LH := LH xor (UInt64(AData[LCurrentIndex]) shl 8);
+        System.Inc(LCurrentIndex);
 
-        h := h xor (UInt64(a_data[current_index]) shl 8);
-        System.Inc(current_index);
+        LH := LH xor UInt64(AData[LCurrentIndex]);
 
-        h := h xor UInt64(a_data[current_index]);
-
-        h := h * M;
+        LH := LH * M;
       end;
 
     6:
       begin
+        LH := LH xor (UInt64(AData[LCurrentIndex]) shl 40);
+        System.Inc(LCurrentIndex);
 
-        h := h xor (UInt64(a_data[current_index]) shl 40);
-        System.Inc(current_index);
-
-        h := h xor (UInt64(a_data[current_index]) shl 32);
-        System.Inc(current_index);
+        LH := LH xor (UInt64(AData[LCurrentIndex]) shl 32);
+        System.Inc(LCurrentIndex);
 
-        h := h xor (UInt64(a_data[current_index]) shl 24);
-        System.Inc(current_index);
+        LH := LH xor (UInt64(AData[LCurrentIndex]) shl 24);
+        System.Inc(LCurrentIndex);
 
-        h := h xor (UInt64(a_data[current_index]) shl 16);
-        System.Inc(current_index);
+        LH := LH xor (UInt64(AData[LCurrentIndex]) shl 16);
+        System.Inc(LCurrentIndex);
 
-        h := h xor (UInt64(a_data[current_index]) shl 8);
-        System.Inc(current_index);
+        LH := LH xor (UInt64(AData[LCurrentIndex]) shl 8);
+        System.Inc(LCurrentIndex);
 
-        h := h xor UInt64(a_data[current_index]);
+        LH := LH xor UInt64(AData[LCurrentIndex]);
 
-        h := h * M;
+        LH := LH * M;
       end;
 
     5:
       begin
+        LH := LH xor (UInt64(AData[LCurrentIndex]) shl 32);
+        System.Inc(LCurrentIndex);
 
-        h := h xor (UInt64(a_data[current_index]) shl 32);
-        System.Inc(current_index);
+        LH := LH xor (UInt64(AData[LCurrentIndex]) shl 24);
+        System.Inc(LCurrentIndex);
 
-        h := h xor (UInt64(a_data[current_index]) shl 24);
-        System.Inc(current_index);
+        LH := LH xor (UInt64(AData[LCurrentIndex]) shl 16);
+        System.Inc(LCurrentIndex);
 
-        h := h xor (UInt64(a_data[current_index]) shl 16);
-        System.Inc(current_index);
+        LH := LH xor (UInt64(AData[LCurrentIndex]) shl 8);
+        System.Inc(LCurrentIndex);
 
-        h := h xor (UInt64(a_data[current_index]) shl 8);
-        System.Inc(current_index);
-
-        h := h xor UInt64(a_data[current_index]);
-        h := h * M;
+        LH := LH xor UInt64(AData[LCurrentIndex]);
+        LH := LH * M;
       end;
 
     4:
       begin
+        LH := LH xor (UInt64(AData[LCurrentIndex]) shl 24);
+        System.Inc(LCurrentIndex);
 
-        h := h xor (UInt64(a_data[current_index]) shl 24);
-        System.Inc(current_index);
-
-        h := h xor (UInt64(a_data[current_index]) shl 16);
-        System.Inc(current_index);
+        LH := LH xor (UInt64(AData[LCurrentIndex]) shl 16);
+        System.Inc(LCurrentIndex);
 
-        h := h xor (UInt64(a_data[current_index]) shl 8);
-        System.Inc(current_index);
+        LH := LH xor (UInt64(AData[LCurrentIndex]) shl 8);
+        System.Inc(LCurrentIndex);
 
-        h := h xor UInt64(a_data[current_index]);
-        h := h * M;
+        LH := LH xor UInt64(AData[LCurrentIndex]);
+        LH := LH * M;
       end;
 
     3:
       begin
+        LH := LH xor (UInt64(AData[LCurrentIndex]) shl 16);
+        System.Inc(LCurrentIndex);
 
-        h := h xor (UInt64(a_data[current_index]) shl 16);
-        System.Inc(current_index);
-
-        h := h xor (UInt64(a_data[current_index]) shl 8);
-        System.Inc(current_index);
+        LH := LH xor (UInt64(AData[LCurrentIndex]) shl 8);
+        System.Inc(LCurrentIndex);
 
-        h := h xor UInt64(a_data[current_index]);
-        h := h * M;
+        LH := LH xor UInt64(AData[LCurrentIndex]);
+        LH := LH * M;
       end;
 
     2:
       begin
+        LH := LH xor (UInt64(AData[LCurrentIndex]) shl 8);
+        System.Inc(LCurrentIndex);
 
-        h := h xor (UInt64(a_data[current_index]) shl 8);
-        System.Inc(current_index);
+        LH := LH xor UInt64(AData[LCurrentIndex]);
 
-        h := h xor UInt64(a_data[current_index]);
-
-        h := h * M;
+        LH := LH * M;
       end;
 
     1:
       begin
+        LH := LH xor UInt64(AData[LCurrentIndex]);
 
-        h := h xor UInt64(a_data[current_index]);
-
-        h := h * M;
+        LH := LH * M;
       end;
 
   end;
 
-  h := h xor (h shr R);
-  h := h * M;
-  h := h xor (h shr R);
-
-  result := THashResult.Create(h);
+  LH := LH xor (LH shr R);
+  LH := LH * M;
+  LH := LH xor (LH shr R);
 
+  result := THashResult.Create(LH);
 end;
 
 constructor TMurmur2_64.Create;
 begin
   Inherited Create(8, 8);
-  Fm_key := CKEY;
-
+  FKey := CKEY;
 end;
 
 function TMurmur2_64.GetKey: THashLibByteArray;
 begin
-  result := TConverters.ReadUInt32AsBytesLE(Fm_key);
+  result := TConverters.ReadUInt32AsBytesLE(FKey);
 end;
 
 function TMurmur2_64.GetKeyLength: TNullableInteger;
@@ -258,26 +248,25 @@ end;
 
 procedure TMurmur2_64.Initialize;
 begin
-  Fm_working_key := Fm_key;
-
+  FWorkingKey := FKey;
   Inherited Initialize();
-
 end;
 
-procedure TMurmur2_64.SetKey(const value: THashLibByteArray);
+procedure TMurmur2_64.SetKey(const AValue: THashLibByteArray);
 begin
-  if (value = Nil) then
+  if (AValue = Nil) then
   begin
-    Fm_key := CKEY;
+    FKey := CKEY;
   end
   else
   begin
-    if System.length(value) <> KeyLength.value then
+    if System.length(AValue) <> KeyLength.value then
+    begin
       raise EArgumentHashLibException.CreateResFmt(@SInvalidKeyLength,
         [KeyLength.value]);
-    Fm_key := TConverters.ReadBytesAsUInt32LE(PByte(value), 0);
+    end;
+    FKey := TConverters.ReadBytesAsUInt32LE(PByte(AValue), 0);
   end;
-
 end;
 
 end.

+ 262 - 284
src/libraries/hashlib4pascal/HlpMurmurHash3_x64_128.pas

@@ -29,13 +29,13 @@ type
     ITransformBlock)
 
   strict private
+  var
+    FH1, FH2, FTotalLength: UInt64;
+    FKey: UInt32;
+    FIdx: Int32;
+    FBuffer: THashLibByteArray;
 
-    Fm_h1, Fm_h2, Fm_total_length: UInt64;
-    Fm_key: UInt32;
-    Fm_idx: Int32;
-    Fm_buf: THashLibByteArray;
-
-    procedure ByteUpdate(a_b: Byte); inline;
+    procedure ByteUpdate(AByte: Byte); inline;
     procedure Finish();
     procedure ProcessPendings();
 
@@ -62,13 +62,13 @@ type
 {$ENDREGION}
     function GetKeyLength(): TNullableInteger;
     function GetKey: THashLibByteArray; inline;
-    procedure SetKey(const value: THashLibByteArray); inline;
+    procedure SetKey(const AValue: THashLibByteArray); inline;
 
   public
     constructor Create();
     procedure Initialize(); override;
-    procedure TransformBytes(const a_data: THashLibByteArray;
-      a_index, a_length: Int32); override;
+    procedure TransformBytes(const AData: THashLibByteArray;
+      AIndex, ALength: Int32); override;
     function TransformFinal: IHashResult; override;
     function Clone(): IHash; override;
     property KeyLength: TNullableInteger read GetKeyLength;
@@ -81,319 +81,304 @@ implementation
 
 procedure TMurmurHash3_x64_128.ProcessPendings;
 var
-  k1, k2: UInt64;
-  ptr_Fm_buf: PByte;
+  LK1, LK2: UInt64;
+  LPtrBuffer: PByte;
 begin
-  if Fm_idx >= 16 then
+  if FIdx >= 16 then
   begin
-    ptr_Fm_buf := PByte(Fm_buf);
-    k1 := TConverters.ReadBytesAsUInt64LE(ptr_Fm_buf, 0);
-    k2 := TConverters.ReadBytesAsUInt64LE(ptr_Fm_buf, 8);
+    LPtrBuffer := PByte(FBuffer);
+    LK1 := TConverters.ReadBytesAsUInt64LE(LPtrBuffer, 0);
+    LK2 := TConverters.ReadBytesAsUInt64LE(LPtrBuffer, 8);
 
-    k1 := k1 * C1;
-    k1 := TBits.RotateLeft64(k1, 31);
-    k1 := k1 * C2;
-    Fm_h1 := Fm_h1 xor k1;
+    LK1 := LK1 * C1;
+    LK1 := TBits.RotateLeft64(LK1, 31);
+    LK1 := LK1 * C2;
+    FH1 := FH1 xor LK1;
 
-    Fm_h1 := TBits.RotateLeft64(Fm_h1, 27);
-    Fm_h1 := Fm_h1 + Fm_h2;
-    Fm_h1 := Fm_h1 * 5 + C3;
+    FH1 := TBits.RotateLeft64(FH1, 27);
+    FH1 := FH1 + FH2;
+    FH1 := FH1 * 5 + C3;
 
-    k2 := k2 * C2;
-    k2 := TBits.RotateLeft64(k2, 33);
-    k2 := k2 * C1;
-    Fm_h2 := Fm_h2 xor k2;
+    LK2 := LK2 * C2;
+    LK2 := TBits.RotateLeft64(LK2, 33);
+    LK2 := LK2 * C1;
+    FH2 := FH2 xor LK2;
 
-    Fm_h2 := TBits.RotateLeft64(Fm_h2, 31);
-    Fm_h2 := Fm_h2 + Fm_h1;
-    Fm_h2 := Fm_h2 * 5 + C4;
+    FH2 := TBits.RotateLeft64(FH2, 31);
+    FH2 := FH2 + FH1;
+    FH2 := FH2 * 5 + C4;
 
-    Fm_idx := 0;
+    FIdx := 0;
   end;
 end;
 
-procedure TMurmurHash3_x64_128.ByteUpdate(a_b: Byte);
+procedure TMurmurHash3_x64_128.ByteUpdate(AByte: Byte);
 begin
-  Fm_buf[Fm_idx] := a_b;
-  System.Inc(Fm_idx);
+  FBuffer[FIdx] := AByte;
+  System.Inc(FIdx);
   ProcessPendings();
 end;
 
 function TMurmurHash3_x64_128.Clone(): IHash;
 var
-  HashInstance: TMurmurHash3_x64_128;
+  LHashInstance: TMurmurHash3_x64_128;
 begin
-  HashInstance := TMurmurHash3_x64_128.Create();
-  HashInstance.Fm_h1 := Fm_h1;
-  HashInstance.Fm_h2 := Fm_h2;
-  HashInstance.Fm_total_length := Fm_total_length;
-  HashInstance.Fm_key := Fm_key;
-  HashInstance.Fm_idx := Fm_idx;
-  HashInstance.Fm_buf := System.Copy(Fm_buf);
-  result := HashInstance as IHash;
+  LHashInstance := TMurmurHash3_x64_128.Create();
+  LHashInstance.FH1 := FH1;
+  LHashInstance.FH2 := FH2;
+  LHashInstance.FTotalLength := FTotalLength;
+  LHashInstance.FKey := FKey;
+  LHashInstance.FIdx := FIdx;
+  LHashInstance.FBuffer := System.Copy(FBuffer);
+  result := LHashInstance as IHash;
   result.BufferSize := BufferSize;
 end;
 
 constructor TMurmurHash3_x64_128.Create;
 begin
   Inherited Create(16, 16);
-  Fm_key := CKEY;
-  System.SetLength(Fm_buf, 16);
-
+  FKey := CKEY;
+  System.SetLength(FBuffer, 16);
 end;
 
 procedure TMurmurHash3_x64_128.Finish;
 var
-  &length: Int32;
-  k2, k1: UInt64;
+  LLength: Int32;
+  LK1, LK2: UInt64;
 begin
 
   // tail
 
-  k1 := 0;
-  k2 := 0;
+  LK1 := 0;
+  LK2 := 0;
 
-  length := Fm_idx;
+  LLength := FIdx;
 
-  if (length <> 0) then
+  if (LLength <> 0) then
   begin
 
-    case length of
+    case LLength of
       15:
         begin
-
-          k2 := k2 xor (UInt64(Fm_buf[14]) shl 48);
-          k2 := k2 xor (UInt64(Fm_buf[13]) shl 40);
-          k2 := k2 xor (UInt64(Fm_buf[12]) shl 32);
-          k2 := k2 xor (UInt64(Fm_buf[11]) shl 24);
-          k2 := k2 xor (UInt64(Fm_buf[10]) shl 16);
-          k2 := k2 xor (UInt64(Fm_buf[9]) shl 8);
-          k2 := k2 xor (UInt64(Fm_buf[8]) shl 0);
-          k2 := k2 * C2;
-          k2 := TBits.RotateLeft64(k2, 33);
-          k2 := k2 * C1;
-          Fm_h2 := Fm_h2 xor k2;
+          LK2 := LK2 xor (UInt64(FBuffer[14]) shl 48);
+          LK2 := LK2 xor (UInt64(FBuffer[13]) shl 40);
+          LK2 := LK2 xor (UInt64(FBuffer[12]) shl 32);
+          LK2 := LK2 xor (UInt64(FBuffer[11]) shl 24);
+          LK2 := LK2 xor (UInt64(FBuffer[10]) shl 16);
+          LK2 := LK2 xor (UInt64(FBuffer[9]) shl 8);
+          LK2 := LK2 xor (UInt64(FBuffer[8]) shl 0);
+          LK2 := LK2 * C2;
+          LK2 := TBits.RotateLeft64(LK2, 33);
+          LK2 := LK2 * C1;
+          FH2 := FH2 xor LK2;
         end;
 
       14:
         begin
-
-          k2 := k2 xor (UInt64(Fm_buf[13]) shl 40);
-          k2 := k2 xor (UInt64(Fm_buf[12]) shl 32);
-          k2 := k2 xor (UInt64(Fm_buf[11]) shl 24);
-          k2 := k2 xor (UInt64(Fm_buf[10]) shl 16);
-          k2 := k2 xor (UInt64(Fm_buf[9]) shl 8);
-          k2 := k2 xor (UInt64(Fm_buf[8]) shl 0);
-          k2 := k2 * C2;
-          k2 := TBits.RotateLeft64(k2, 33);
-          k2 := k2 * C1;
-          Fm_h2 := Fm_h2 xor k2;
+          LK2 := LK2 xor (UInt64(FBuffer[13]) shl 40);
+          LK2 := LK2 xor (UInt64(FBuffer[12]) shl 32);
+          LK2 := LK2 xor (UInt64(FBuffer[11]) shl 24);
+          LK2 := LK2 xor (UInt64(FBuffer[10]) shl 16);
+          LK2 := LK2 xor (UInt64(FBuffer[9]) shl 8);
+          LK2 := LK2 xor (UInt64(FBuffer[8]) shl 0);
+          LK2 := LK2 * C2;
+          LK2 := TBits.RotateLeft64(LK2, 33);
+          LK2 := LK2 * C1;
+          FH2 := FH2 xor LK2;
         end;
 
       13:
         begin
-
-          k2 := k2 xor (UInt64(Fm_buf[12]) shl 32);
-          k2 := k2 xor (UInt64(Fm_buf[11]) shl 24);
-          k2 := k2 xor (UInt64(Fm_buf[10]) shl 16);
-          k2 := k2 xor (UInt64(Fm_buf[9]) shl 8);
-          k2 := k2 xor (UInt64(Fm_buf[8]) shl 0);
-          k2 := k2 * C2;
-          k2 := TBits.RotateLeft64(k2, 33);
-          k2 := k2 * C1;
-          Fm_h2 := Fm_h2 xor k2;
+          LK2 := LK2 xor (UInt64(FBuffer[12]) shl 32);
+          LK2 := LK2 xor (UInt64(FBuffer[11]) shl 24);
+          LK2 := LK2 xor (UInt64(FBuffer[10]) shl 16);
+          LK2 := LK2 xor (UInt64(FBuffer[9]) shl 8);
+          LK2 := LK2 xor (UInt64(FBuffer[8]) shl 0);
+          LK2 := LK2 * C2;
+          LK2 := TBits.RotateLeft64(LK2, 33);
+          LK2 := LK2 * C1;
+          FH2 := FH2 xor LK2;
         end;
 
       12:
         begin
-
-          k2 := k2 xor (UInt64(Fm_buf[11]) shl 24);
-          k2 := k2 xor (UInt64(Fm_buf[10]) shl 16);
-          k2 := k2 xor (UInt64(Fm_buf[9]) shl 8);
-          k2 := k2 xor (UInt64(Fm_buf[8]) shl 0);
-          k2 := k2 * C2;
-          k2 := TBits.RotateLeft64(k2, 33);
-          k2 := k2 * C1;
-          Fm_h2 := Fm_h2 xor k2;
+          LK2 := LK2 xor (UInt64(FBuffer[11]) shl 24);
+          LK2 := LK2 xor (UInt64(FBuffer[10]) shl 16);
+          LK2 := LK2 xor (UInt64(FBuffer[9]) shl 8);
+          LK2 := LK2 xor (UInt64(FBuffer[8]) shl 0);
+          LK2 := LK2 * C2;
+          LK2 := TBits.RotateLeft64(LK2, 33);
+          LK2 := LK2 * C1;
+          FH2 := FH2 xor LK2;
         end;
 
       11:
         begin
-
-          k2 := k2 xor (UInt64(Fm_buf[10]) shl 16);
-          k2 := k2 xor (UInt64(Fm_buf[9]) shl 8);
-          k2 := k2 xor (UInt64(Fm_buf[8]) shl 0);
-          k2 := k2 * C2;
-          k2 := TBits.RotateLeft64(k2, 33);
-          k2 := k2 * C1;
-          Fm_h2 := Fm_h2 xor k2;
+          LK2 := LK2 xor (UInt64(FBuffer[10]) shl 16);
+          LK2 := LK2 xor (UInt64(FBuffer[9]) shl 8);
+          LK2 := LK2 xor (UInt64(FBuffer[8]) shl 0);
+          LK2 := LK2 * C2;
+          LK2 := TBits.RotateLeft64(LK2, 33);
+          LK2 := LK2 * C1;
+          FH2 := FH2 xor LK2;
         end;
 
       10:
         begin
-
-          k2 := k2 xor (UInt64(Fm_buf[9]) shl 8);
-          k2 := k2 xor (UInt64(Fm_buf[8]) shl 0);
-          k2 := k2 * C2;
-          k2 := TBits.RotateLeft64(k2, 33);
-          k2 := k2 * C1;
-          Fm_h2 := Fm_h2 xor k2;
+          LK2 := LK2 xor (UInt64(FBuffer[9]) shl 8);
+          LK2 := LK2 xor (UInt64(FBuffer[8]) shl 0);
+          LK2 := LK2 * C2;
+          LK2 := TBits.RotateLeft64(LK2, 33);
+          LK2 := LK2 * C1;
+          FH2 := FH2 xor LK2;
         end;
 
       9:
         begin
-
-          k2 := k2 xor (UInt64(Fm_buf[8]) shl 0);
-          k2 := k2 * C2;
-          k2 := TBits.RotateLeft64(k2, 33);
-          k2 := k2 * C1;
-          Fm_h2 := Fm_h2 xor k2;
+          LK2 := LK2 xor (UInt64(FBuffer[8]) shl 0);
+          LK2 := LK2 * C2;
+          LK2 := TBits.RotateLeft64(LK2, 33);
+          LK2 := LK2 * C1;
+          FH2 := FH2 xor LK2;
         end;
 
     end;
 
-    if (length > 8) then
-      length := 8;
+    if (LLength > 8) then
+    begin
+      LLength := 8;
+    end;
 
-    case length of
+    case LLength of
       8:
         begin
-
-          k1 := k1 xor (UInt64(Fm_buf[7]) shl 56);
-          k1 := k1 xor (UInt64(Fm_buf[6]) shl 48);
-          k1 := k1 xor (UInt64(Fm_buf[5]) shl 40);
-          k1 := k1 xor (UInt64(Fm_buf[4]) shl 32);
-          k1 := k1 xor (UInt64(Fm_buf[3]) shl 24);
-          k1 := k1 xor (UInt64(Fm_buf[2]) shl 16);
-          k1 := k1 xor (UInt64(Fm_buf[1]) shl 8);
-          k1 := k1 xor (UInt64(Fm_buf[0]) shl 0);
-          k1 := k1 * C1;
-          k1 := TBits.RotateLeft64(k1, 31);
-          k1 := k1 * C2;
-          Fm_h1 := Fm_h1 xor k1;
+          LK1 := LK1 xor (UInt64(FBuffer[7]) shl 56);
+          LK1 := LK1 xor (UInt64(FBuffer[6]) shl 48);
+          LK1 := LK1 xor (UInt64(FBuffer[5]) shl 40);
+          LK1 := LK1 xor (UInt64(FBuffer[4]) shl 32);
+          LK1 := LK1 xor (UInt64(FBuffer[3]) shl 24);
+          LK1 := LK1 xor (UInt64(FBuffer[2]) shl 16);
+          LK1 := LK1 xor (UInt64(FBuffer[1]) shl 8);
+          LK1 := LK1 xor (UInt64(FBuffer[0]) shl 0);
+          LK1 := LK1 * C1;
+          LK1 := TBits.RotateLeft64(LK1, 31);
+          LK1 := LK1 * C2;
+          FH1 := FH1 xor LK1;
         end;
 
       7:
         begin
-
-          k1 := k1 xor (UInt64(Fm_buf[6]) shl 48);
-          k1 := k1 xor (UInt64(Fm_buf[5]) shl 40);
-          k1 := k1 xor (UInt64(Fm_buf[4]) shl 32);
-          k1 := k1 xor (UInt64(Fm_buf[3]) shl 24);
-          k1 := k1 xor (UInt64(Fm_buf[2]) shl 16);
-          k1 := k1 xor (UInt64(Fm_buf[1]) shl 8);
-          k1 := k1 xor (UInt64(Fm_buf[0]) shl 0);
-          k1 := k1 * C1;
-          k1 := TBits.RotateLeft64(k1, 31);
-          k1 := k1 * C2;
-          Fm_h1 := Fm_h1 xor k1;
+          LK1 := LK1 xor (UInt64(FBuffer[6]) shl 48);
+          LK1 := LK1 xor (UInt64(FBuffer[5]) shl 40);
+          LK1 := LK1 xor (UInt64(FBuffer[4]) shl 32);
+          LK1 := LK1 xor (UInt64(FBuffer[3]) shl 24);
+          LK1 := LK1 xor (UInt64(FBuffer[2]) shl 16);
+          LK1 := LK1 xor (UInt64(FBuffer[1]) shl 8);
+          LK1 := LK1 xor (UInt64(FBuffer[0]) shl 0);
+          LK1 := LK1 * C1;
+          LK1 := TBits.RotateLeft64(LK1, 31);
+          LK1 := LK1 * C2;
+          FH1 := FH1 xor LK1;
         end;
 
       6:
         begin
-
-          k1 := k1 xor (UInt64(Fm_buf[5]) shl 40);
-          k1 := k1 xor (UInt64(Fm_buf[4]) shl 32);
-          k1 := k1 xor (UInt64(Fm_buf[3]) shl 24);
-          k1 := k1 xor (UInt64(Fm_buf[2]) shl 16);
-          k1 := k1 xor (UInt64(Fm_buf[1]) shl 8);
-          k1 := k1 xor (UInt64(Fm_buf[0]) shl 0);
-          k1 := k1 * C1;
-          k1 := TBits.RotateLeft64(k1, 31);
-          k1 := k1 * C2;
-          Fm_h1 := Fm_h1 xor k1;
+          LK1 := LK1 xor (UInt64(FBuffer[5]) shl 40);
+          LK1 := LK1 xor (UInt64(FBuffer[4]) shl 32);
+          LK1 := LK1 xor (UInt64(FBuffer[3]) shl 24);
+          LK1 := LK1 xor (UInt64(FBuffer[2]) shl 16);
+          LK1 := LK1 xor (UInt64(FBuffer[1]) shl 8);
+          LK1 := LK1 xor (UInt64(FBuffer[0]) shl 0);
+          LK1 := LK1 * C1;
+          LK1 := TBits.RotateLeft64(LK1, 31);
+          LK1 := LK1 * C2;
+          FH1 := FH1 xor LK1;
         end;
 
       5:
         begin
-
-          k1 := k1 xor (UInt64(Fm_buf[4]) shl 32);
-          k1 := k1 xor (UInt64(Fm_buf[3]) shl 24);
-          k1 := k1 xor (UInt64(Fm_buf[2]) shl 16);
-          k1 := k1 xor (UInt64(Fm_buf[1]) shl 8);
-          k1 := k1 xor (UInt64(Fm_buf[0]) shl 0);
-          k1 := k1 * C1;
-          k1 := TBits.RotateLeft64(k1, 31);
-          k1 := k1 * C2;
-          Fm_h1 := Fm_h1 xor k1;
+          LK1 := LK1 xor (UInt64(FBuffer[4]) shl 32);
+          LK1 := LK1 xor (UInt64(FBuffer[3]) shl 24);
+          LK1 := LK1 xor (UInt64(FBuffer[2]) shl 16);
+          LK1 := LK1 xor (UInt64(FBuffer[1]) shl 8);
+          LK1 := LK1 xor (UInt64(FBuffer[0]) shl 0);
+          LK1 := LK1 * C1;
+          LK1 := TBits.RotateLeft64(LK1, 31);
+          LK1 := LK1 * C2;
+          FH1 := FH1 xor LK1;
         end;
 
       4:
         begin
-
-          k1 := k1 xor (UInt64(Fm_buf[3]) shl 24);
-          k1 := k1 xor (UInt64(Fm_buf[2]) shl 16);
-          k1 := k1 xor (UInt64(Fm_buf[1]) shl 8);
-          k1 := k1 xor (UInt64(Fm_buf[0]) shl 0);
-          k1 := k1 * C1;
-          k1 := TBits.RotateLeft64(k1, 31);
-          k1 := k1 * C2;
-          Fm_h1 := Fm_h1 xor k1;
+          LK1 := LK1 xor (UInt64(FBuffer[3]) shl 24);
+          LK1 := LK1 xor (UInt64(FBuffer[2]) shl 16);
+          LK1 := LK1 xor (UInt64(FBuffer[1]) shl 8);
+          LK1 := LK1 xor (UInt64(FBuffer[0]) shl 0);
+          LK1 := LK1 * C1;
+          LK1 := TBits.RotateLeft64(LK1, 31);
+          LK1 := LK1 * C2;
+          FH1 := FH1 xor LK1;
         end;
 
       3:
         begin
-
-          k1 := k1 xor (UInt64(Fm_buf[2]) shl 16);
-          k1 := k1 xor (UInt64(Fm_buf[1]) shl 8);
-          k1 := k1 xor (UInt64(Fm_buf[0]) shl 0);
-          k1 := k1 * C1;
-          k1 := TBits.RotateLeft64(k1, 31);
-          k1 := k1 * C2;
-          Fm_h1 := Fm_h1 xor k1;
+          LK1 := LK1 xor (UInt64(FBuffer[2]) shl 16);
+          LK1 := LK1 xor (UInt64(FBuffer[1]) shl 8);
+          LK1 := LK1 xor (UInt64(FBuffer[0]) shl 0);
+          LK1 := LK1 * C1;
+          LK1 := TBits.RotateLeft64(LK1, 31);
+          LK1 := LK1 * C2;
+          FH1 := FH1 xor LK1;
         end;
 
       2:
         begin
-
-          k1 := k1 xor (UInt64(Fm_buf[1]) shl 8);
-          k1 := k1 xor (UInt64(Fm_buf[0]) shl 0);
-          k1 := k1 * C1;
-          k1 := TBits.RotateLeft64(k1, 31);
-          k1 := k1 * C2;
-          Fm_h1 := Fm_h1 xor k1;
+          LK1 := LK1 xor (UInt64(FBuffer[1]) shl 8);
+          LK1 := LK1 xor (UInt64(FBuffer[0]) shl 0);
+          LK1 := LK1 * C1;
+          LK1 := TBits.RotateLeft64(LK1, 31);
+          LK1 := LK1 * C2;
+          FH1 := FH1 xor LK1;
         end;
 
       1:
         begin
-
-          k1 := k1 xor (UInt64(Fm_buf[0]) shl 0);
-          k1 := k1 * C1;
-          k1 := TBits.RotateLeft64(k1, 31);
-          k1 := k1 * C2;
-          Fm_h1 := Fm_h1 xor k1;
+          LK1 := LK1 xor (UInt64(FBuffer[0]) shl 0);
+          LK1 := LK1 * C1;
+          LK1 := TBits.RotateLeft64(LK1, 31);
+          LK1 := LK1 * C2;
+          FH1 := FH1 xor LK1;
         end;
 
     end;
 
   end;
 
-  Fm_h1 := Fm_h1 xor Fm_total_length;
-  Fm_h2 := Fm_h2 xor Fm_total_length;
-
-  Fm_h1 := Fm_h1 + Fm_h2;
-  Fm_h2 := Fm_h2 + Fm_h1;
+  FH1 := FH1 xor FTotalLength;
+  FH2 := FH2 xor FTotalLength;
 
-  Fm_h1 := Fm_h1 xor (Fm_h1 shr 33);
-  Fm_h1 := Fm_h1 * C5;
-  Fm_h1 := Fm_h1 xor (Fm_h1 shr 33);
-  Fm_h1 := Fm_h1 * C6;
-  Fm_h1 := Fm_h1 xor (Fm_h1 shr 33);
+  FH1 := FH1 + FH2;
+  FH2 := FH2 + FH1;
 
-  Fm_h2 := Fm_h2 xor (Fm_h2 shr 33);
-  Fm_h2 := Fm_h2 * C5;
-  Fm_h2 := Fm_h2 xor (Fm_h2 shr 33);
-  Fm_h2 := Fm_h2 * C6;
-  Fm_h2 := Fm_h2 xor (Fm_h2 shr 33);
+  FH1 := FH1 xor (FH1 shr 33);
+  FH1 := FH1 * C5;
+  FH1 := FH1 xor (FH1 shr 33);
+  FH1 := FH1 * C6;
+  FH1 := FH1 xor (FH1 shr 33);
 
-  Fm_h1 := Fm_h1 + Fm_h2;
-  Fm_h2 := Fm_h2 + Fm_h1;
+  FH2 := FH2 xor (FH2 shr 33);
+  FH2 := FH2 * C5;
+  FH2 := FH2 xor (FH2 shr 33);
+  FH2 := FH2 * C6;
+  FH2 := FH2 xor (FH2 shr 33);
 
+  FH1 := FH1 + FH2;
+  FH2 := FH2 + FH1;
 end;
 
 function TMurmurHash3_x64_128.GetKey: THashLibByteArray;
 begin
-  result := TConverters.ReadUInt32AsBytesLE(Fm_key);
+  result := TConverters.ReadUInt32AsBytesLE(FKey);
 end;
 
 function TMurmurHash3_x64_128.GetKeyLength: TNullableInteger;
@@ -403,137 +388,130 @@ end;
 
 procedure TMurmurHash3_x64_128.Initialize;
 begin
-  Fm_h1 := Fm_key;
-  Fm_h2 := Fm_key;
-
-  Fm_total_length := 0;
-  Fm_idx := 0;
+  FH1 := FKey;
+  FH2 := FKey;
 
+  FTotalLength := 0;
+  FIdx := 0;
 end;
 
-procedure TMurmurHash3_x64_128.SetKey(const value: THashLibByteArray);
+procedure TMurmurHash3_x64_128.SetKey(const AValue: THashLibByteArray);
 begin
-  if (value = Nil) then
+  if (AValue = Nil) then
   begin
-    Fm_key := CKEY;
+    FKey := CKEY;
   end
-
   else
   begin
-    if System.length(value) <> KeyLength.value then
+    if System.length(AValue) <> KeyLength.value then
+    begin
       raise EArgumentHashLibException.CreateResFmt(@SInvalidKeyLength,
         [KeyLength.value]);
-
-    Fm_key := TConverters.ReadBytesAsUInt32LE(PByte(value), 0);
-
+    end;
+    FKey := TConverters.ReadBytesAsUInt32LE(PByte(AValue), 0);
   end;
 end;
 
-procedure TMurmurHash3_x64_128.TransformBytes(const a_data: THashLibByteArray;
-  a_index, a_length: Int32);
+procedure TMurmurHash3_x64_128.TransformBytes(const AData: THashLibByteArray;
+  AIndex, ALength: Int32);
 var
-  len, nBlocks, i, offset, lIdx: Int32;
-  k1, k2: UInt64;
-  ptr_a_data: PByte;
+  LLength, LNBlocks, LIndex, LOffset, LIdx: Int32;
+  LK1, LK2: UInt64;
+  LPtrData: PByte;
 begin
 {$IFDEF DEBUG}
-  System.Assert(a_index >= 0);
-  System.Assert(a_length >= 0);
-  System.Assert(a_index + a_length <= System.length(a_data));
+  System.Assert(AIndex >= 0);
+  System.Assert(ALength >= 0);
+  System.Assert(AIndex + ALength <= System.length(AData));
 {$ENDIF DEBUG}
-  len := a_length;
-  i := a_index;
-  lIdx := 0;
-  System.Inc(Fm_total_length, len);
-  ptr_a_data := PByte(a_data);
+  LLength := ALength;
+  LIndex := AIndex;
+  LIdx := 0;
+  System.Inc(FTotalLength, LLength);
+  LPtrData := PByte(AData);
 
   // consume last pending bytes
 
-  if ((Fm_idx <> 0) and (a_length <> 0)) then
+  if ((FIdx <> 0) and (ALength <> 0)) then
   begin
-
 {$IFDEF DEBUG}
-    System.Assert(a_index = 0); // nothing would work anyways if a_index is !=0
+    System.Assert(AIndex = 0); // nothing would work anyways if AIndex <> 0
 {$ENDIF DEBUG}
-    while ((Fm_idx < 16) and (len <> 0)) do
+    while ((FIdx < 16) and (LLength <> 0)) do
     begin
-      Fm_buf[Fm_idx] := (ptr_a_data + a_index)^;
-      System.Inc(Fm_idx);
-      System.Inc(a_index);
-      System.Dec(len);
+      FBuffer[FIdx] := (LPtrData + AIndex)^;
+      System.Inc(FIdx);
+      System.Inc(AIndex);
+      System.Dec(LLength);
     end;
-    if (Fm_idx = 16) then
+    if (FIdx = 16) then
     begin
       ProcessPendings;
     end;
   end
   else
   begin
-    i := 0;
+    LIndex := 0;
   end;
 
-  nBlocks := len shr 4;
+  LNBlocks := LLength shr 4;
 
   // body
 
-  while i < nBlocks do
+  while LIndex < LNBlocks do
   begin
 
-    k1 := TConverters.ReadBytesAsUInt64LE(ptr_a_data, a_index + lIdx);
+    LK1 := TConverters.ReadBytesAsUInt64LE(LPtrData, AIndex + LIdx);
 
-    System.Inc(lIdx, 8);
+    System.Inc(LIdx, 8);
 
-    k2 := TConverters.ReadBytesAsUInt64LE(ptr_a_data, a_index + lIdx);
+    LK2 := TConverters.ReadBytesAsUInt64LE(LPtrData, AIndex + LIdx);
 
-    System.Inc(lIdx, 8);
+    System.Inc(LIdx, 8);
 
-    k1 := k1 * C1;
-    k1 := TBits.RotateLeft64(k1, 31);
-    k1 := k1 * C2;
-    Fm_h1 := Fm_h1 xor k1;
+    LK1 := LK1 * C1;
+    LK1 := TBits.RotateLeft64(LK1, 31);
+    LK1 := LK1 * C2;
+    FH1 := FH1 xor LK1;
 
-    Fm_h1 := TBits.RotateLeft64(Fm_h1, 27);
-    Fm_h1 := Fm_h1 + Fm_h2;
-    Fm_h1 := Fm_h1 * 5 + C3;
+    FH1 := TBits.RotateLeft64(FH1, 27);
+    FH1 := FH1 + FH2;
+    FH1 := FH1 * 5 + C3;
 
-    k2 := k2 * C2;
-    k2 := TBits.RotateLeft64(k2, 33);
-    k2 := k2 * C1;
-    Fm_h2 := Fm_h2 xor k2;
+    LK2 := LK2 * C2;
+    LK2 := TBits.RotateLeft64(LK2, 33);
+    LK2 := LK2 * C1;
+    FH2 := FH2 xor LK2;
 
-    Fm_h2 := TBits.RotateLeft64(Fm_h2, 31);
-    Fm_h2 := Fm_h2 + Fm_h1;
-    Fm_h2 := Fm_h2 * 5 + C4;
+    FH2 := TBits.RotateLeft64(FH2, 31);
+    FH2 := FH2 + FH1;
+    FH2 := FH2 * 5 + C4;
 
-    System.Inc(i);
+    System.Inc(LIndex);
   end;
 
-  offset := a_index + (i * 16);
+  LOffset := AIndex + (LIndex * 16);
 
-  while (offset < (a_index + len)) do
+  while (LOffset < (AIndex + LLength)) do
   begin
-
-    ByteUpdate(a_data[offset]);
-    System.Inc(offset);
-
+    ByteUpdate(AData[LOffset]);
+    System.Inc(LOffset);
   end;
-
 end;
 
 function TMurmurHash3_x64_128.TransformFinal: IHashResult;
 var
-  tempBufByte: THashLibByteArray;
-  tempBufUInt64: THashLibUInt64Array;
+  LBufferByte: THashLibByteArray;
+  LBufferUInt64: THashLibUInt64Array;
 begin
   Finish();
-
-  tempBufUInt64 := THashLibUInt64Array.Create(Fm_h1, Fm_h2);
-  System.SetLength(tempBufByte, System.length(tempBufUInt64) *
+  LBufferUInt64 := THashLibUInt64Array.Create(FH1, FH2);
+  System.SetLength(LBufferByte, System.length(LBufferUInt64) *
     System.SizeOf(UInt64));
-  TConverters.be64_copy(PUInt64(tempBufUInt64), 0, PByte(tempBufByte), 0,
-    System.length(tempBufByte));
+  TConverters.be64_copy(PUInt64(LBufferUInt64), 0, PByte(LBufferByte), 0,
+    System.length(LBufferByte));
 
-  result := THashResult.Create(tempBufByte);
+  result := THashResult.Create(LBufferByte);
 
   Initialize();
 end;

+ 316 - 329
src/libraries/hashlib4pascal/HlpMurmurHash3_x86_128.pas

@@ -29,12 +29,12 @@ type
     ITransformBlock)
 
   strict private
+  var
+    FKey, FH1, FH2, FH3, FH4, FTotalLength: UInt32;
+    FIdx: Int32;
+    FBuffer: THashLibByteArray;
 
-    Fm_key, Fm_h1, Fm_h2, Fm_h3, Fm_h4, Fm_total_length: UInt32;
-    Fm_idx: Int32;
-    Fm_buf: THashLibByteArray;
-
-    procedure ByteUpdate(a_b: Byte); inline;
+    procedure ByteUpdate(AByte: Byte); inline;
     procedure Finish();
     procedure ProcessPendings();
 
@@ -58,13 +58,13 @@ type
 {$ENDREGION}
     function GetKeyLength(): TNullableInteger;
     function GetKey: THashLibByteArray; inline;
-    procedure SetKey(const value: THashLibByteArray); inline;
+    procedure SetKey(const AValue: THashLibByteArray); inline;
 
   public
     constructor Create();
     procedure Initialize(); override;
-    procedure TransformBytes(const a_data: THashLibByteArray;
-      a_index, a_length: Int32); override;
+    procedure TransformBytes(const AData: THashLibByteArray;
+      AIndex, ALength: Int32); override;
     function TransformFinal: IHashResult; override;
     function Clone(): IHash; override;
     property KeyLength: TNullableInteger read GetKeyLength;
@@ -77,313 +77,304 @@ implementation
 
 procedure TMurmurHash3_x86_128.ProcessPendings;
 var
-  k1, k2, k3, k4: UInt32;
-  ptr_Fm_buf: PByte;
+  LK1, LK2, LK3, LK4: UInt32;
+  LPtrBuffer: PByte;
 begin
-  if Fm_idx >= 16 then
+  if FIdx >= 16 then
   begin
-    ptr_Fm_buf := PByte(Fm_buf);
-    k1 := TConverters.ReadBytesAsUInt32LE(ptr_Fm_buf, 0);
-    k2 := TConverters.ReadBytesAsUInt32LE(ptr_Fm_buf, 4);
-    k3 := TConverters.ReadBytesAsUInt32LE(ptr_Fm_buf, 8);
-    k4 := TConverters.ReadBytesAsUInt32LE(ptr_Fm_buf, 12);
+    LPtrBuffer := PByte(FBuffer);
+    LK1 := TConverters.ReadBytesAsUInt32LE(LPtrBuffer, 0);
+    LK2 := TConverters.ReadBytesAsUInt32LE(LPtrBuffer, 4);
+    LK3 := TConverters.ReadBytesAsUInt32LE(LPtrBuffer, 8);
+    LK4 := TConverters.ReadBytesAsUInt32LE(LPtrBuffer, 12);
 
-    k1 := k1 * C1;
-    k1 := TBits.RotateLeft32(k1, 15);
-    k1 := k1 * C2;
-    Fm_h1 := Fm_h1 xor k1;
+    LK1 := LK1 * C1;
+    LK1 := TBits.RotateLeft32(LK1, 15);
+    LK1 := LK1 * C2;
+    FH1 := FH1 xor LK1;
 
-    Fm_h1 := TBits.RotateLeft32(Fm_h1, 19);
+    FH1 := TBits.RotateLeft32(FH1, 19);
 
-    Fm_h1 := Fm_h1 + Fm_h2;
-    Fm_h1 := Fm_h1 * 5 + C7;
+    FH1 := FH1 + FH2;
+    FH1 := FH1 * 5 + C7;
 
-    k2 := k2 * C2;
-    k2 := TBits.RotateLeft32(k2, 16);
-    k2 := k2 * C3;
-    Fm_h2 := Fm_h2 xor k2;
+    LK2 := LK2 * C2;
+    LK2 := TBits.RotateLeft32(LK2, 16);
+    LK2 := LK2 * C3;
+    FH2 := FH2 xor LK2;
 
-    Fm_h2 := TBits.RotateLeft32(Fm_h2, 17);
+    FH2 := TBits.RotateLeft32(FH2, 17);
 
-    Fm_h2 := Fm_h2 + Fm_h3;
-    Fm_h2 := Fm_h2 * 5 + C8;
+    FH2 := FH2 + FH3;
+    FH2 := FH2 * 5 + C8;
 
-    k3 := k3 * C3;
-    k3 := TBits.RotateLeft32(k3, 17);
-    k3 := k3 * C4;
-    Fm_h3 := Fm_h3 xor k3;
+    LK3 := LK3 * C3;
+    LK3 := TBits.RotateLeft32(LK3, 17);
+    LK3 := LK3 * C4;
+    FH3 := FH3 xor LK3;
 
-    Fm_h3 := TBits.RotateLeft32(Fm_h3, 15);
+    FH3 := TBits.RotateLeft32(FH3, 15);
 
-    Fm_h3 := Fm_h3 + Fm_h4;
-    Fm_h3 := Fm_h3 * 5 + C9;
+    FH3 := FH3 + FH4;
+    FH3 := FH3 * 5 + C9;
 
-    k4 := k4 * C4;
-    k4 := TBits.RotateLeft32(k4, 18);
-    k4 := k4 * C1;
-    Fm_h4 := Fm_h4 xor k4;
+    LK4 := LK4 * C4;
+    LK4 := TBits.RotateLeft32(LK4, 18);
+    LK4 := LK4 * C1;
+    FH4 := FH4 xor LK4;
 
-    Fm_h4 := TBits.RotateLeft32(Fm_h4, 13);
+    FH4 := TBits.RotateLeft32(FH4, 13);
 
-    Fm_h4 := Fm_h4 + Fm_h1;
-    Fm_h4 := Fm_h4 * 5 + C10;
+    FH4 := FH4 + FH1;
+    FH4 := FH4 * 5 + C10;
 
-    Fm_idx := 0;
+    FIdx := 0;
   end;
 end;
 
-procedure TMurmurHash3_x86_128.ByteUpdate(a_b: Byte);
+procedure TMurmurHash3_x86_128.ByteUpdate(AByte: Byte);
 begin
-  Fm_buf[Fm_idx] := a_b;
-  System.Inc(Fm_idx);
+  FBuffer[FIdx] := AByte;
+  System.Inc(FIdx);
   ProcessPendings();
 end;
 
 function TMurmurHash3_x86_128.Clone(): IHash;
 var
-  HashInstance: TMurmurHash3_x86_128;
+  LHashInstance: TMurmurHash3_x86_128;
 begin
-  HashInstance := TMurmurHash3_x86_128.Create();
-    HashInstance.Fm_key := Fm_key;
-  HashInstance.Fm_h1 := Fm_h1;
-  HashInstance.Fm_h2 := Fm_h2;
-  HashInstance.Fm_h3 := Fm_h3;
-  HashInstance.Fm_h4 := Fm_h4;
-  HashInstance.Fm_total_length := Fm_total_length;
-  HashInstance.Fm_idx := Fm_idx;
-  HashInstance.Fm_buf := System.Copy(Fm_buf);
-  result := HashInstance as IHash;
+  LHashInstance := TMurmurHash3_x86_128.Create();
+  LHashInstance.FKey := FKey;
+  LHashInstance.FH1 := FH1;
+  LHashInstance.FH2 := FH2;
+  LHashInstance.FH3 := FH3;
+  LHashInstance.FH4 := FH4;
+  LHashInstance.FTotalLength := FTotalLength;
+  LHashInstance.FIdx := FIdx;
+  LHashInstance.FBuffer := System.Copy(FBuffer);
+  result := LHashInstance as IHash;
   result.BufferSize := BufferSize;
 end;
 
 constructor TMurmurHash3_x86_128.Create;
 begin
   Inherited Create(16, 16);
-  Fm_key := CKEY;
-  System.SetLength(Fm_buf, 16);
-
+  FKey := CKEY;
+  System.SetLength(FBuffer, 16);
 end;
 
 procedure TMurmurHash3_x86_128.Finish;
 var
-  k1, k2, k3, k4: UInt32;
-  &length: Int32;
+  LK1, LK2, LK3, LK4: UInt32;
+  LLength: Int32;
 begin
 
   // tail
 
-  k1 := 0;
-  k2 := 0;
-  k3 := 0;
-  k4 := 0;
+  LK1 := 0;
+  LK2 := 0;
+  LK3 := 0;
+  LK4 := 0;
 
-  length := Fm_idx;
-  if (length <> 0) then
+  LLength := FIdx;
+  if (LLength <> 0) then
   begin
-    case (length) of
+    case (LLength) of
       15:
         begin
-
-          k4 := k4 xor (Fm_buf[14] shl 16);
-          k4 := k4 xor (Fm_buf[13] shl 8);
-          k4 := k4 xor (Fm_buf[12] shl 0);
-
-          k4 := k4 * C4;
-          k4 := TBits.RotateLeft32(k4, 18);
-          k4 := k4 * C1;
-          Fm_h4 := Fm_h4 xor k4;
+          LK4 := LK4 xor (FBuffer[14] shl 16);
+          LK4 := LK4 xor (FBuffer[13] shl 8);
+          LK4 := LK4 xor (FBuffer[12] shl 0);
+
+          LK4 := LK4 * C4;
+          LK4 := TBits.RotateLeft32(LK4, 18);
+          LK4 := LK4 * C1;
+          FH4 := FH4 xor LK4;
         end;
 
       14:
         begin
-
-          k4 := k4 xor (Fm_buf[13] shl 8);
-          k4 := k4 xor (Fm_buf[12] shl 0);
-          k4 := k4 * C4;
-          k4 := TBits.RotateLeft32(k4, 18);
-          k4 := k4 * C1;
-          Fm_h4 := Fm_h4 xor k4;
+          LK4 := LK4 xor (FBuffer[13] shl 8);
+          LK4 := LK4 xor (FBuffer[12] shl 0);
+          LK4 := LK4 * C4;
+          LK4 := TBits.RotateLeft32(LK4, 18);
+          LK4 := LK4 * C1;
+          FH4 := FH4 xor LK4;
         end;
 
       13:
         begin
-
-          k4 := k4 xor (Fm_buf[12] shl 0);
-          k4 := k4 * C4;
-          k4 := TBits.RotateLeft32(k4, 18);
-          k4 := k4 * C1;
-          Fm_h4 := Fm_h4 xor k4;
+          LK4 := LK4 xor (FBuffer[12] shl 0);
+          LK4 := LK4 * C4;
+          LK4 := TBits.RotateLeft32(LK4, 18);
+          LK4 := LK4 * C1;
+          FH4 := FH4 xor LK4;
         end;
 
     end;
 
-    if (length > 12) then
-      length := 12;
+    if (LLength > 12) then
+    begin
+      LLength := 12;
+    end;
 
-    case length of
+    case LLength of
 
       12:
         begin
-
-          k3 := k3 xor (Fm_buf[11] shl 24);
-          k3 := k3 xor (Fm_buf[10] shl 16);
-          k3 := k3 xor (Fm_buf[9] shl 8);
-          k3 := k3 xor (Fm_buf[8] shl 0);
-
-          k3 := k3 * C3;
-          k3 := TBits.RotateLeft32(k3, 17);
-          k3 := k3 * C4;
-          Fm_h3 := Fm_h3 xor k3;
+          LK3 := LK3 xor (FBuffer[11] shl 24);
+          LK3 := LK3 xor (FBuffer[10] shl 16);
+          LK3 := LK3 xor (FBuffer[9] shl 8);
+          LK3 := LK3 xor (FBuffer[8] shl 0);
+
+          LK3 := LK3 * C3;
+          LK3 := TBits.RotateLeft32(LK3, 17);
+          LK3 := LK3 * C4;
+          FH3 := FH3 xor LK3;
         end;
 
       11:
         begin
-
-          k3 := k3 xor (Fm_buf[10] shl 16);
-          k3 := k3 xor (Fm_buf[9] shl 8);
-          k3 := k3 xor (Fm_buf[8] shl 0);
-
-          k3 := k3 * C3;
-          k3 := TBits.RotateLeft32(k3, 17);
-          k3 := k3 * C4;
-          Fm_h3 := Fm_h3 xor k3;
+          LK3 := LK3 xor (FBuffer[10] shl 16);
+          LK3 := LK3 xor (FBuffer[9] shl 8);
+          LK3 := LK3 xor (FBuffer[8] shl 0);
+
+          LK3 := LK3 * C3;
+          LK3 := TBits.RotateLeft32(LK3, 17);
+          LK3 := LK3 * C4;
+          FH3 := FH3 xor LK3;
         end;
 
       10:
         begin
+          LK3 := LK3 xor (FBuffer[9] shl 8);
+          LK3 := LK3 xor (FBuffer[8] shl 0);
 
-          k3 := k3 xor (Fm_buf[9] shl 8);
-          k3 := k3 xor (Fm_buf[8] shl 0);
-
-          k3 := k3 * C3;
-          k3 := TBits.RotateLeft32(k3, 17);
-          k3 := k3 * C4;
-          Fm_h3 := Fm_h3 xor k3;
+          LK3 := LK3 * C3;
+          LK3 := TBits.RotateLeft32(LK3, 17);
+          LK3 := LK3 * C4;
+          FH3 := FH3 xor LK3;
         end;
 
       9:
         begin
+          LK3 := LK3 xor (FBuffer[8] shl 0);
 
-          k3 := k3 xor (Fm_buf[8] shl 0);
-
-          k3 := k3 * C3;
-          k3 := TBits.RotateLeft32(k3, 17);
-          k3 := k3 * C4;
-          Fm_h3 := Fm_h3 xor k3;
+          LK3 := LK3 * C3;
+          LK3 := TBits.RotateLeft32(LK3, 17);
+          LK3 := LK3 * C4;
+          FH3 := FH3 xor LK3;
         end;
 
     end;
 
-    if (length > 8) then
-      length := 8;
+    if (LLength > 8) then
+    begin
+      LLength := 8;
+    end;
 
-    case length of
+    case LLength of
 
       8:
         begin
-
-          k2 := k2 xor (Fm_buf[7] shl 24);
-          k2 := k2 xor (Fm_buf[6] shl 16);
-          k2 := k2 xor (Fm_buf[5] shl 8);
-          k2 := k2 xor (Fm_buf[4] shl 0);
-
-          k2 := k2 * C2;
-          k2 := TBits.RotateLeft32(k2, 16);
-          k2 := k2 * C3;
-          Fm_h2 := Fm_h2 xor k2;
+          LK2 := LK2 xor (FBuffer[7] shl 24);
+          LK2 := LK2 xor (FBuffer[6] shl 16);
+          LK2 := LK2 xor (FBuffer[5] shl 8);
+          LK2 := LK2 xor (FBuffer[4] shl 0);
+
+          LK2 := LK2 * C2;
+          LK2 := TBits.RotateLeft32(LK2, 16);
+          LK2 := LK2 * C3;
+          FH2 := FH2 xor LK2;
         end;
 
       7:
         begin
-
-          k2 := k2 xor (Fm_buf[6] shl 16);
-          k2 := k2 xor (Fm_buf[5] shl 8);
-          k2 := k2 xor (Fm_buf[4] shl 0);
-
-          k2 := k2 * C2;
-          k2 := TBits.RotateLeft32(k2, 16);
-          k2 := k2 * C3;
-          Fm_h2 := Fm_h2 xor k2;
+          LK2 := LK2 xor (FBuffer[6] shl 16);
+          LK2 := LK2 xor (FBuffer[5] shl 8);
+          LK2 := LK2 xor (FBuffer[4] shl 0);
+
+          LK2 := LK2 * C2;
+          LK2 := TBits.RotateLeft32(LK2, 16);
+          LK2 := LK2 * C3;
+          FH2 := FH2 xor LK2;
         end;
 
       6:
         begin
+          LK2 := LK2 xor (FBuffer[5] shl 8);
+          LK2 := LK2 xor (FBuffer[4] shl 0);
 
-          k2 := k2 xor (Fm_buf[5] shl 8);
-          k2 := k2 xor (Fm_buf[4] shl 0);
-
-          k2 := k2 * C2;
-          k2 := TBits.RotateLeft32(k2, 16);
-          k2 := k2 * C3;
-          Fm_h2 := Fm_h2 xor k2;
+          LK2 := LK2 * C2;
+          LK2 := TBits.RotateLeft32(LK2, 16);
+          LK2 := LK2 * C3;
+          FH2 := FH2 xor LK2;
         end;
 
       5:
         begin
+          LK2 := LK2 xor (FBuffer[4] shl 0);
 
-          k2 := k2 xor (Fm_buf[4] shl 0);
-
-          k2 := k2 * C2;
-          k2 := TBits.RotateLeft32(k2, 16);
-          k2 := k2 * C3;
-          Fm_h2 := Fm_h2 xor k2;
+          LK2 := LK2 * C2;
+          LK2 := TBits.RotateLeft32(LK2, 16);
+          LK2 := LK2 * C3;
+          FH2 := FH2 xor LK2;
         end;
 
     end;
 
-    if (length > 4) then
-      length := 4;
+    if (LLength > 4) then
+    begin
+      LLength := 4;
+    end;
 
-    case length of
+    case LLength of
 
       4:
         begin
-
-          k1 := k1 xor (Fm_buf[3] shl 24);
-          k1 := k1 xor (Fm_buf[2] shl 16);
-          k1 := k1 xor (Fm_buf[1] shl 8);
-          k1 := k1 xor (Fm_buf[0] shl 0);
-
-          k1 := k1 * C1;
-          k1 := TBits.RotateLeft32(k1, 15);
-          k1 := k1 * C2;
-          Fm_h1 := Fm_h1 xor k1;
+          LK1 := LK1 xor (FBuffer[3] shl 24);
+          LK1 := LK1 xor (FBuffer[2] shl 16);
+          LK1 := LK1 xor (FBuffer[1] shl 8);
+          LK1 := LK1 xor (FBuffer[0] shl 0);
+
+          LK1 := LK1 * C1;
+          LK1 := TBits.RotateLeft32(LK1, 15);
+          LK1 := LK1 * C2;
+          FH1 := FH1 xor LK1;
         end;
 
       3:
         begin
-
-          k1 := k1 xor (Fm_buf[2] shl 16);
-          k1 := k1 xor (Fm_buf[1] shl 8);
-          k1 := k1 xor (Fm_buf[0] shl 0);
-
-          k1 := k1 * C1;
-          k1 := TBits.RotateLeft32(k1, 15);
-          k1 := k1 * C2;
-          Fm_h1 := Fm_h1 xor k1;
+          LK1 := LK1 xor (FBuffer[2] shl 16);
+          LK1 := LK1 xor (FBuffer[1] shl 8);
+          LK1 := LK1 xor (FBuffer[0] shl 0);
+
+          LK1 := LK1 * C1;
+          LK1 := TBits.RotateLeft32(LK1, 15);
+          LK1 := LK1 * C2;
+          FH1 := FH1 xor LK1;
         end;
 
       2:
         begin
 
-          k1 := k1 xor (Fm_buf[1] shl 8);
-          k1 := k1 xor (Fm_buf[0] shl 0);
+          LK1 := LK1 xor (FBuffer[1] shl 8);
+          LK1 := LK1 xor (FBuffer[0] shl 0);
 
-          k1 := k1 * C1;
-          k1 := TBits.RotateLeft32(k1, 15);
-          k1 := k1 * C2;
-          Fm_h1 := Fm_h1 xor k1;
+          LK1 := LK1 * C1;
+          LK1 := TBits.RotateLeft32(LK1, 15);
+          LK1 := LK1 * C2;
+          FH1 := FH1 xor LK1;
         end;
 
       1:
         begin
+          LK1 := LK1 xor (FBuffer[0] shl 0);
 
-          k1 := k1 xor (Fm_buf[0] shl 0);
-
-          k1 := k1 * C1;
-          k1 := TBits.RotateLeft32(k1, 15);
-          k1 := k1 * C2;
-          Fm_h1 := Fm_h1 xor k1;
+          LK1 := LK1 * C1;
+          LK1 := TBits.RotateLeft32(LK1, 15);
+          LK1 := LK1 * C2;
+          FH1 := FH1 xor LK1;
         end;
 
     end;
@@ -391,54 +382,53 @@ begin
 
   // finalization
 
-  Fm_h1 := Fm_h1 xor Fm_total_length;
-  Fm_h2 := Fm_h2 xor Fm_total_length;
-  Fm_h3 := Fm_h3 xor Fm_total_length;
-  Fm_h4 := Fm_h4 xor Fm_total_length;
-
-  Fm_h1 := Fm_h1 + Fm_h2;
-  Fm_h1 := Fm_h1 + Fm_h3;
-  Fm_h1 := Fm_h1 + Fm_h4;
-  Fm_h2 := Fm_h2 + Fm_h1;
-  Fm_h3 := Fm_h3 + Fm_h1;
-  Fm_h4 := Fm_h4 + Fm_h1;
-
-  Fm_h1 := Fm_h1 xor (Fm_h1 shr 16);
-  Fm_h1 := Fm_h1 * C5;
-  Fm_h1 := Fm_h1 xor (Fm_h1 shr 13);
-  Fm_h1 := Fm_h1 * C6;
-  Fm_h1 := Fm_h1 xor (Fm_h1 shr 16);
-
-  Fm_h2 := Fm_h2 xor (Fm_h2 shr 16);
-  Fm_h2 := Fm_h2 * C5;
-  Fm_h2 := Fm_h2 xor (Fm_h2 shr 13);
-  Fm_h2 := Fm_h2 * C6;
-  Fm_h2 := Fm_h2 xor (Fm_h2 shr 16);
-
-  Fm_h3 := Fm_h3 xor (Fm_h3 shr 16);
-  Fm_h3 := Fm_h3 * C5;
-  Fm_h3 := Fm_h3 xor (Fm_h3 shr 13);
-  Fm_h3 := Fm_h3 * C6;
-  Fm_h3 := Fm_h3 xor (Fm_h3 shr 16);
-
-  Fm_h4 := Fm_h4 xor (Fm_h4 shr 16);
-  Fm_h4 := Fm_h4 * C5;
-  Fm_h4 := Fm_h4 xor (Fm_h4 shr 13);
-  Fm_h4 := Fm_h4 * C6;
-  Fm_h4 := Fm_h4 xor (Fm_h4 shr 16);
-
-  Fm_h1 := Fm_h1 + Fm_h2;
-  Fm_h1 := Fm_h1 + Fm_h3;
-  Fm_h1 := Fm_h1 + Fm_h4;
-  Fm_h2 := Fm_h2 + Fm_h1;
-  Fm_h3 := Fm_h3 + Fm_h1;
-  Fm_h4 := Fm_h4 + Fm_h1;
-
+  FH1 := FH1 xor FTotalLength;
+  FH2 := FH2 xor FTotalLength;
+  FH3 := FH3 xor FTotalLength;
+  FH4 := FH4 xor FTotalLength;
+
+  FH1 := FH1 + FH2;
+  FH1 := FH1 + FH3;
+  FH1 := FH1 + FH4;
+  FH2 := FH2 + FH1;
+  FH3 := FH3 + FH1;
+  FH4 := FH4 + FH1;
+
+  FH1 := FH1 xor (FH1 shr 16);
+  FH1 := FH1 * C5;
+  FH1 := FH1 xor (FH1 shr 13);
+  FH1 := FH1 * C6;
+  FH1 := FH1 xor (FH1 shr 16);
+
+  FH2 := FH2 xor (FH2 shr 16);
+  FH2 := FH2 * C5;
+  FH2 := FH2 xor (FH2 shr 13);
+  FH2 := FH2 * C6;
+  FH2 := FH2 xor (FH2 shr 16);
+
+  FH3 := FH3 xor (FH3 shr 16);
+  FH3 := FH3 * C5;
+  FH3 := FH3 xor (FH3 shr 13);
+  FH3 := FH3 * C6;
+  FH3 := FH3 xor (FH3 shr 16);
+
+  FH4 := FH4 xor (FH4 shr 16);
+  FH4 := FH4 * C5;
+  FH4 := FH4 xor (FH4 shr 13);
+  FH4 := FH4 * C6;
+  FH4 := FH4 xor (FH4 shr 16);
+
+  FH1 := FH1 + FH2;
+  FH1 := FH1 + FH3;
+  FH1 := FH1 + FH4;
+  FH2 := FH2 + FH1;
+  FH3 := FH3 + FH1;
+  FH4 := FH4 + FH1;
 end;
 
 function TMurmurHash3_x86_128.GetKey: THashLibByteArray;
 begin
-  result := TConverters.ReadUInt32AsBytesLE(Fm_key);
+  result := TConverters.ReadUInt32AsBytesLE(FKey);
 end;
 
 function TMurmurHash3_x86_128.GetKeyLength: TNullableInteger;
@@ -448,159 +438,156 @@ end;
 
 procedure TMurmurHash3_x86_128.Initialize;
 begin
-  Fm_h1 := Fm_key;
-  Fm_h2 := Fm_key;
-  Fm_h3 := Fm_key;
-  Fm_h4 := Fm_key;
-
-  Fm_total_length := 0;
-  Fm_idx := 0;
+  FH1 := FKey;
+  FH2 := FKey;
+  FH3 := FKey;
+  FH4 := FKey;
 
+  FTotalLength := 0;
+  FIdx := 0;
 end;
 
-procedure TMurmurHash3_x86_128.SetKey(const value: THashLibByteArray);
+procedure TMurmurHash3_x86_128.SetKey(const AValue: THashLibByteArray);
 begin
-  if (value = Nil) then
+  if (AValue = Nil) then
   begin
-    Fm_key := CKEY;
+    FKey := CKEY;
   end
-
   else
   begin
-    if System.length(value) <> KeyLength.value then
+    if System.length(AValue) <> KeyLength.value then
+    begin
       raise EArgumentHashLibException.CreateResFmt(@SInvalidKeyLength,
         [KeyLength.value]);
-    Fm_key := TConverters.ReadBytesAsUInt32LE(PByte(value), 0);
-
+    end;
+    FKey := TConverters.ReadBytesAsUInt32LE(PByte(AValue), 0);
   end;
 end;
 
-procedure TMurmurHash3_x86_128.TransformBytes(const a_data: THashLibByteArray;
-  a_index, a_length: Int32);
+procedure TMurmurHash3_x86_128.TransformBytes(const AData: THashLibByteArray;
+  AIndex, ALength: Int32);
 var
-  len, nBlocks, i, offset, lIdx: Int32;
-  k1, k2, k3, k4: UInt32;
-  ptr_a_data: PByte;
+  LLength, LNBlocks, LIndex, LOffset, LIdx: Int32;
+  LK1, LK2, LK3, LK4: UInt32;
+  LPtrData: PByte;
 begin
 {$IFDEF DEBUG}
-  System.Assert(a_index >= 0);
-  System.Assert(a_length >= 0);
-  System.Assert(a_index + a_length <= System.length(a_data));
+  System.Assert(AIndex >= 0);
+  System.Assert(ALength >= 0);
+  System.Assert(AIndex + ALength <= System.length(AData));
 {$ENDIF DEBUG}
-  len := a_length;
-  i := a_index;
-  lIdx := 0;
-  System.Inc(Fm_total_length, len);
-  ptr_a_data := PByte(a_data);
+  LLength := ALength;
+  LIndex := AIndex;
+  LIdx := 0;
+  System.Inc(FTotalLength, LLength);
+  LPtrData := PByte(AData);
 
   // consume last pending bytes
 
-  if ((Fm_idx <> 0) and (a_length <> 0)) then
+  if ((FIdx <> 0) and (ALength <> 0)) then
   begin
-
 {$IFDEF DEBUG}
-    System.Assert(a_index = 0); // nothing would work anyways if a_index is !=0
+    System.Assert(AIndex = 0); // nothing would work anyways if AIndex <> 0
 {$ENDIF DEBUG}
-    while ((Fm_idx < 16) and (len <> 0)) do
+    while ((FIdx < 16) and (LLength <> 0)) do
     begin
-      Fm_buf[Fm_idx] := (ptr_a_data + a_index)^;
-      System.Inc(Fm_idx);
-      System.Inc(a_index);
-      System.Dec(len);
+      FBuffer[FIdx] := (LPtrData + AIndex)^;
+      System.Inc(FIdx);
+      System.Inc(AIndex);
+      System.Dec(LLength);
     end;
-    if (Fm_idx = 16) then
+    if (FIdx = 16) then
     begin
       ProcessPendings;
     end;
   end
   else
   begin
-    i := 0;
+    LIndex := 0;
   end;
 
-  nBlocks := len shr 4;
+  LNBlocks := LLength shr 4;
 
   // body
 
-  while i < nBlocks do
+  while LIndex < LNBlocks do
   begin
 
-    k1 := TConverters.ReadBytesAsUInt32LE(ptr_a_data, a_index + lIdx);
-    System.Inc(lIdx, 4);
-    k2 := TConverters.ReadBytesAsUInt32LE(ptr_a_data, a_index + lIdx);
-    System.Inc(lIdx, 4);
-    k3 := TConverters.ReadBytesAsUInt32LE(ptr_a_data, a_index + lIdx);
-    System.Inc(lIdx, 4);
-    k4 := TConverters.ReadBytesAsUInt32LE(ptr_a_data, a_index + lIdx);
-    System.Inc(lIdx, 4);
+    LK1 := TConverters.ReadBytesAsUInt32LE(LPtrData, AIndex + LIdx);
+    System.Inc(LIdx, 4);
+    LK2 := TConverters.ReadBytesAsUInt32LE(LPtrData, AIndex + LIdx);
+    System.Inc(LIdx, 4);
+    LK3 := TConverters.ReadBytesAsUInt32LE(LPtrData, AIndex + LIdx);
+    System.Inc(LIdx, 4);
+    LK4 := TConverters.ReadBytesAsUInt32LE(LPtrData, AIndex + LIdx);
+    System.Inc(LIdx, 4);
 
-    k1 := k1 * C1;
-    k1 := TBits.RotateLeft32(k1, 15);
-    k1 := k1 * C2;
-    Fm_h1 := Fm_h1 xor k1;
+    LK1 := LK1 * C1;
+    LK1 := TBits.RotateLeft32(LK1, 15);
+    LK1 := LK1 * C2;
+    FH1 := FH1 xor LK1;
 
-    Fm_h1 := TBits.RotateLeft32(Fm_h1, 19);
+    FH1 := TBits.RotateLeft32(FH1, 19);
 
-    Fm_h1 := Fm_h1 + Fm_h2;
-    Fm_h1 := Fm_h1 * 5 + C7;
+    FH1 := FH1 + FH2;
+    FH1 := FH1 * 5 + C7;
 
-    k2 := k2 * C2;
-    k2 := TBits.RotateLeft32(k2, 16);
-    k2 := k2 * C3;
-    Fm_h2 := Fm_h2 xor k2;
+    LK2 := LK2 * C2;
+    LK2 := TBits.RotateLeft32(LK2, 16);
+    LK2 := LK2 * C3;
+    FH2 := FH2 xor LK2;
 
-    Fm_h2 := TBits.RotateLeft32(Fm_h2, 17);
+    FH2 := TBits.RotateLeft32(FH2, 17);
 
-    Fm_h2 := Fm_h2 + Fm_h3;
-    Fm_h2 := Fm_h2 * 5 + C8;
+    FH2 := FH2 + FH3;
+    FH2 := FH2 * 5 + C8;
 
-    k3 := k3 * C3;
-    k3 := TBits.RotateLeft32(k3, 17);
-    k3 := k3 * C4;
-    Fm_h3 := Fm_h3 xor k3;
+    LK3 := LK3 * C3;
+    LK3 := TBits.RotateLeft32(LK3, 17);
+    LK3 := LK3 * C4;
+    FH3 := FH3 xor LK3;
 
-    Fm_h3 := TBits.RotateLeft32(Fm_h3, 15);
+    FH3 := TBits.RotateLeft32(FH3, 15);
 
-    Fm_h3 := Fm_h3 + Fm_h4;
-    Fm_h3 := Fm_h3 * 5 + C9;
+    FH3 := FH3 + FH4;
+    FH3 := FH3 * 5 + C9;
 
-    k4 := k4 * C4;
-    k4 := TBits.RotateLeft32(k4, 18);
-    k4 := k4 * C1;
-    Fm_h4 := Fm_h4 xor k4;
+    LK4 := LK4 * C4;
+    LK4 := TBits.RotateLeft32(LK4, 18);
+    LK4 := LK4 * C1;
+    FH4 := FH4 xor LK4;
 
-    Fm_h4 := TBits.RotateLeft32(Fm_h4, 13);
+    FH4 := TBits.RotateLeft32(FH4, 13);
 
-    Fm_h4 := Fm_h4 + Fm_h1;
-    Fm_h4 := Fm_h4 * 5 + C10;
+    FH4 := FH4 + FH1;
+    FH4 := FH4 * 5 + C10;
 
-    System.Inc(i);
+    System.Inc(LIndex);
   end;
 
-  offset := a_index + (i * 16);
+  LOffset := AIndex + (LIndex * 16);
 
-  while offset < (a_index + len) do
+  while LOffset < (AIndex + LLength) do
   begin
-    ByteUpdate(a_data[offset]);
-    System.Inc(offset);
+    ByteUpdate(AData[LOffset]);
+    System.Inc(LOffset);
   end;
 
 end;
 
 function TMurmurHash3_x86_128.TransformFinal: IHashResult;
 var
-  tempBufByte: THashLibByteArray;
-  tempBufUInt32: THashLibUInt32Array;
+  LBufferByte: THashLibByteArray;
+  LBufferUInt32: THashLibUInt32Array;
 begin
   Finish();
-
-  tempBufUInt32 := THashLibUInt32Array.Create(Fm_h1, Fm_h2, Fm_h3, Fm_h4);
-  System.SetLength(tempBufByte, System.length(tempBufUInt32) *
+  LBufferUInt32 := THashLibUInt32Array.Create(FH1, FH2, FH3, FH4);
+  System.SetLength(LBufferByte, System.length(LBufferUInt32) *
     System.SizeOf(UInt32));
-  TConverters.be32_copy(PCardinal(tempBufUInt32), 0, PByte(tempBufByte), 0,
-    System.length(tempBufByte));
+  TConverters.be32_copy(PCardinal(LBufferUInt32), 0, PByte(LBufferByte), 0,
+    System.length(LBufferByte));
 
-  result := THashResult.Create(tempBufByte);
+  result := THashResult.Create(LBufferByte);
 
   Initialize();
 end;

+ 118 - 124
src/libraries/hashlib4pascal/HlpMurmurHash3_x86_32.pas

@@ -30,13 +30,13 @@ type
     ITransformBlock)
 
   strict private
+  var
+    FKey, FH, FTotalLength: UInt32;
+    FIdx: Int32;
+    FBuffer: THashLibByteArray;
 
-    Fm_key, Fm_h, Fm_total_length: UInt32;
-    Fm_idx: Int32;
-    Fm_buf: THashLibByteArray;
-
-    procedure TransformUInt32Fast(a_data: UInt32); inline;
-    procedure ByteUpdate(a_b: Byte); inline;
+    procedure TransformUInt32Fast(ABlock: UInt32); inline;
+    procedure ByteUpdate(AByte: Byte); inline;
     procedure Finish();
 
   const
@@ -50,13 +50,13 @@ type
 
     function GetKeyLength(): TNullableInteger;
     function GetKey: THashLibByteArray; inline;
-    procedure SetKey(const value: THashLibByteArray); inline;
+    procedure SetKey(const AValue: THashLibByteArray); inline;
 
   public
     constructor Create();
     procedure Initialize(); override;
-    procedure TransformBytes(const a_data: THashLibByteArray;
-      a_index, a_length: Int32); override;
+    procedure TransformBytes(const AData: THashLibByteArray;
+      AIndex, ALength: Int32); override;
     function TransformFinal: IHashResult; override;
     function Clone(): IHash; override;
     property KeyLength: TNullableInteger read GetKeyLength;
@@ -70,70 +70,68 @@ implementation
 
 function TMurmurHash3_x86_32.Clone(): IHash;
 var
-  HashInstance: TMurmurHash3_x86_32;
+  LHashInstance: TMurmurHash3_x86_32;
 begin
-  HashInstance := TMurmurHash3_x86_32.Create();
-  HashInstance.Fm_key := Fm_key;
-  HashInstance.Fm_h := Fm_h;
-  HashInstance.Fm_total_length := Fm_total_length;
-  HashInstance.Fm_idx := Fm_idx;
-  HashInstance.Fm_buf := System.Copy(Fm_buf);
-  result := HashInstance as IHash;
+  LHashInstance := TMurmurHash3_x86_32.Create();
+  LHashInstance.FKey := FKey;
+  LHashInstance.FH := FH;
+  LHashInstance.FTotalLength := FTotalLength;
+  LHashInstance.FIdx := FIdx;
+  LHashInstance.FBuffer := System.Copy(FBuffer);
+  result := LHashInstance as IHash;
   result.BufferSize := BufferSize;
 end;
 
 constructor TMurmurHash3_x86_32.Create;
 begin
   Inherited Create(4, 4);
-  Fm_key := CKEY;
-  System.SetLength(Fm_buf, 4);
-
+  FKey := CKEY;
+  System.SetLength(FBuffer, 4);
 end;
 
 procedure TMurmurHash3_x86_32.Finish;
 var
-  k: UInt32;
+  LFinalBlock: UInt32;
 begin
 
   // tail
 
-  k := 0;
+  LFinalBlock := 0;
 
-  if (Fm_idx <> 0) then
+  if (FIdx <> 0) then
   begin
 
-    case (Fm_idx) of
-
+    case (FIdx) of
       3:
         begin
-          k := k xor (Fm_buf[2] shl 16);
-          k := k xor (Fm_buf[1] shl 8);
-          k := k xor Fm_buf[0];
-          k := k * C1;
-          k := TBits.RotateLeft32(k, 15);
-          k := k * C2;
-          Fm_h := Fm_h xor k;
+          LFinalBlock := LFinalBlock xor (FBuffer[2] shl 16);
+          LFinalBlock := LFinalBlock xor (FBuffer[1] shl 8);
+          LFinalBlock := LFinalBlock xor FBuffer[0];
+          LFinalBlock := LFinalBlock * C1;
+          LFinalBlock := TBits.RotateLeft32(LFinalBlock, 15);
+          LFinalBlock := LFinalBlock * C2;
+          FH := FH xor LFinalBlock;
 
         end;
       2:
         begin
 
-          k := k xor (Fm_buf[1] shl 8);
-          k := k xor Fm_buf[0];
-          k := k * C1;
-          k := TBits.RotateLeft32(k, 15);
-          k := k * C2;
-          Fm_h := Fm_h xor k;
+          LFinalBlock := LFinalBlock xor (FBuffer[1] shl 8);
+          LFinalBlock := LFinalBlock xor FBuffer[0];
+          LFinalBlock := LFinalBlock * C1;
+          LFinalBlock := TBits.RotateLeft32(LFinalBlock, 15);
+          LFinalBlock := LFinalBlock * C2;
+          FH := FH xor LFinalBlock;
 
         end;
       1:
         begin
 
-          k := k xor Fm_buf[0];
-          k := k * C1;
-          k := TBits.RotateLeft32(k, 15);
-          k := k * C2;
-          Fm_h := Fm_h xor k;
+          LFinalBlock := LFinalBlock xor FBuffer[0];
+          LFinalBlock := LFinalBlock * C1;
+          LFinalBlock := TBits.RotateLeft32(LFinalBlock, 15);
+          LFinalBlock := LFinalBlock * C2;
+          FH := FH xor LFinalBlock;
 
         end;
     end;
@@ -141,65 +139,65 @@ begin
 
   // finalization
 
-  Fm_h := Fm_h xor Fm_total_length;
+  FH := FH xor FTotalLength;
 
-  Fm_h := Fm_h xor (Fm_h shr 16);
-  Fm_h := Fm_h * C4;
-  Fm_h := Fm_h xor (Fm_h shr 13);
-  Fm_h := Fm_h * C5;
-  Fm_h := Fm_h xor (Fm_h shr 16);
+  FH := FH xor (FH shr 16);
+  FH := FH * C4;
+  FH := FH xor (FH shr 13);
+  FH := FH * C5;
+  FH := FH xor (FH shr 16);
 end;
 
-procedure TMurmurHash3_x86_32.TransformUInt32Fast(a_data: UInt32);
+procedure TMurmurHash3_x86_32.TransformUInt32Fast(ABlock: UInt32);
 var
-  k: UInt32;
+  LBlock: UInt32;
 begin
-  k := a_data;
+  LBlock := ABlock;
 
-  k := k * C1;
-  k := TBits.RotateLeft32(k, 15);
-  k := k * C2;
+  LBlock := LBlock * C1;
+  LBlock := TBits.RotateLeft32(LBlock, 15);
+  LBlock := LBlock * C2;
 
-  Fm_h := Fm_h xor k;
-  Fm_h := TBits.RotateLeft32(Fm_h, 13);
-  Fm_h := (Fm_h * 5) + C3;
+  FH := FH xor LBlock;
+  FH := TBits.RotateLeft32(FH, 13);
+  FH := (FH * 5) + C3;
 end;
 
-procedure TMurmurHash3_x86_32.ByteUpdate(a_b: Byte);
+procedure TMurmurHash3_x86_32.ByteUpdate(AByte: Byte);
 var
-  k: UInt32;
-  ptr_Fm_buf: PByte;
+  LBlock: UInt32;
+  LPtrBuffer: PByte;
 begin
-
-  Fm_buf[Fm_idx] := a_b;
-  System.Inc(Fm_idx);
-  if Fm_idx >= 4 then
+  FBuffer[FIdx] := AByte;
+  System.Inc(FIdx);
+  if FIdx >= 4 then
   begin
-    ptr_Fm_buf := PByte(Fm_buf);
-    k := TConverters.ReadBytesAsUInt32LE(ptr_Fm_buf, 0);
-    TransformUInt32Fast(k);
-    Fm_idx := 0;
+    LPtrBuffer := PByte(FBuffer);
+    LBlock := TConverters.ReadBytesAsUInt32LE(LPtrBuffer, 0);
+    TransformUInt32Fast(LBlock);
+    FIdx := 0;
   end;
-
 end;
 
 function TMurmurHash3_x86_32.GetKey: THashLibByteArray;
 begin
-  result := TConverters.ReadUInt32AsBytesLE(Fm_key);
+  result := TConverters.ReadUInt32AsBytesLE(FKey);
 end;
 
-procedure TMurmurHash3_x86_32.SetKey(const value: THashLibByteArray);
+procedure TMurmurHash3_x86_32.SetKey(const AValue: THashLibByteArray);
 begin
-  if (value = Nil) then
+  if (AValue = Nil) then
   begin
-    Fm_key := CKEY;
+    FKey := CKEY;
   end
   else
   begin
-    if System.Length(value) <> KeyLength.value then
+    if System.Length(AValue) <> KeyLength.value then
+    begin
       raise EArgumentHashLibException.CreateResFmt(@SInvalidKeyLength,
         [KeyLength.value]);
-    Fm_key := TConverters.ReadBytesAsUInt32LE(PByte(value), 0);
+    end;
+    FKey := TConverters.ReadBytesAsUInt32LE(PByte(AValue), 0);
   end;
 end;
 
@@ -210,32 +208,31 @@ end;
 
 procedure TMurmurHash3_x86_32.Initialize;
 begin
-  Fm_h := Fm_key;
-  Fm_total_length := 0;
-  Fm_idx := 0;
+  FH := FKey;
+  FTotalLength := 0;
+  FIdx := 0;
 end;
 
-procedure TMurmurHash3_x86_32.TransformBytes(const a_data: THashLibByteArray;
-  a_index, a_length: Int32);
+procedure TMurmurHash3_x86_32.TransformBytes(const AData: THashLibByteArray;
+  AIndex, ALength: Int32);
 var
-  len, nBlocks, i, offset: Int32;
-  k: UInt32;
-  ptr_a_data, ptr_Fm_buf: PByte;
-
+  LLength, LNBlocks, LIdx, LOffset: Int32;
+  LBlock: UInt32;
+  LPtrData, LPtrBuffer: PByte;
 begin
 {$IFDEF DEBUG}
-  System.Assert(a_index >= 0);
-  System.Assert(a_length >= 0);
-  System.Assert(a_index + a_length <= System.Length(a_data));
+  System.Assert(AIndex >= 0);
+  System.Assert(ALength >= 0);
+  System.Assert(AIndex + ALength <= System.Length(AData));
 {$ENDIF DEBUG}
-  len := a_length;
-  i := a_index;
-  ptr_a_data := PByte(a_data);
-  System.Inc(Fm_total_length, len);
+  LLength := ALength;
+  LIdx := AIndex;
+  LPtrData := PByte(AData);
+  System.Inc(FTotalLength, LLength);
 
   // consume last pending bytes
 
-  if ((Fm_idx <> 0) and (a_length <> 0)) then
+  if ((FIdx <> 0) and (ALength <> 0)) then
   begin
     { *                       buf    data
       idx = 1, len = 3 -> [0, 1[ + [0, 3[ => Block = [], buf []
@@ -249,66 +246,63 @@ begin
       idx = 2, len = 6 -> [0, 2[ + [0, 2[ => Block = [2,6[, buf []
       * }
 {$IFDEF DEBUG}
-    System.Assert(a_index = 0); // nothing would work anyways if a_index is !=0
+    System.Assert(AIndex = 0); // nothing would work anyways if AIndex is !=0
 {$ENDIF DEBUG}
-    while ((Fm_idx < 4) and (len <> 0)) do
+    while ((FIdx < 4) and (LLength <> 0)) do
     begin
-      Fm_buf[Fm_idx] := (ptr_a_data + a_index)^;
-      System.Inc(Fm_idx);
-      System.Inc(a_index);
-      System.Dec(len);
+      FBuffer[FIdx] := (LPtrData + AIndex)^;
+      System.Inc(FIdx);
+      System.Inc(AIndex);
+      System.Dec(LLength);
     end;
-    if (Fm_idx = 4) then
+    if (FIdx = 4) then
     begin
-      ptr_Fm_buf := PByte(Fm_buf);
-      k := TConverters.ReadBytesAsUInt32LE(ptr_Fm_buf, 0);
-      TransformUInt32Fast(k);
-      Fm_idx := 0;
+      LPtrBuffer := PByte(FBuffer);
+      LBlock := TConverters.ReadBytesAsUInt32LE(LPtrBuffer, 0);
+      TransformUInt32Fast(LBlock);
+      FIdx := 0;
     end;
   end
   else
   begin
-    i := 0;
+    LIdx := 0;
   end;
 
-  nBlocks := len shr 2;
-
+  LNBlocks := LLength shr 2;
 
   // body
 
-  while i < nBlocks do
+  while LIdx < LNBlocks do
   begin
-    k := TConverters.ReadBytesAsUInt32LE(ptr_a_data, a_index + (i * 4));
-    TransformUInt32Fast(k);
+    LBlock := TConverters.ReadBytesAsUInt32LE(LPtrData, AIndex + (LIdx * 4));
+    TransformUInt32Fast(LBlock);
 
-    System.Inc(i);
+    System.Inc(LIdx);
   end;
 
   // save pending end bytes
-  offset := a_index + (i * 4);
-  while offset < (len + a_index) do
+  LOffset := AIndex + (LIdx * 4);
+  while LOffset < (LLength + AIndex) do
   begin
-    ByteUpdate(a_data[offset]);
-    System.Inc(offset);
+    ByteUpdate(AData[LOffset]);
+    System.Inc(LOffset);
 
   end;
-
 end;
 
 function TMurmurHash3_x86_32.TransformFinal: IHashResult;
 var
-  tempBufByte: THashLibByteArray;
-  tempBufUInt32: THashLibUInt32Array;
+  LBufferByte: THashLibByteArray;
+  LBufferUInt32: THashLibUInt32Array;
 begin
   Finish();
-
-  tempBufUInt32 := THashLibUInt32Array.Create(Fm_h);
-  System.SetLength(tempBufByte, System.Length(tempBufUInt32) *
+  LBufferUInt32 := THashLibUInt32Array.Create(FH);
+  System.SetLength(LBufferByte, System.Length(LBufferUInt32) *
     System.SizeOf(UInt32));
-  TConverters.be32_copy(PCardinal(tempBufUInt32), 0, PByte(tempBufByte), 0,
-    System.Length(tempBufByte));
+  TConverters.be32_copy(PCardinal(LBufferUInt32), 0, PByte(LBufferByte), 0,
+    System.Length(LBufferByte));
 
-  result := THashResult.Create(tempBufByte);
+  result := THashResult.Create(LBufferByte);
 
   Initialize();
 end;

+ 23 - 23
src/libraries/hashlib4pascal/HlpNullDigest.pas

@@ -18,14 +18,14 @@ type
   TNullDigest = class sealed(THash, ITransformBlock)
   strict private
   var
-    FbOut: TMemoryStream;
+    FOut: TMemoryStream;
 
   public
     constructor Create();
     destructor Destroy(); override;
     procedure Initialize(); override;
-    procedure TransformBytes(const a_data: THashLibByteArray;
-      a_index, a_length: Int32); override;
+    procedure TransformBytes(const AData: THashLibByteArray;
+      AIndex, ALength: Int32); override;
     function TransformFinal(): IHashResult; override;
     function Clone(): IHash; override;
   end;
@@ -36,57 +36,57 @@ implementation
 
 function TNullDigest.Clone(): IHash;
 var
-  HashInstance: TNullDigest;
+  LHashInstance: TNullDigest;
 begin
-  HashInstance := TNullDigest.Create();
-  FbOut.Position := 0;
-  HashInstance.FbOut.CopyFrom(FbOut, FbOut.Size);
-  result := HashInstance as IHash;
+  LHashInstance := TNullDigest.Create();
+  FOut.Position := 0;
+  LHashInstance.FOut.CopyFrom(FOut, FOut.Size);
+  result := LHashInstance as IHash;
   result.BufferSize := BufferSize;
 end;
 
 constructor TNullDigest.Create;
 begin
   Inherited Create(-1, -1); // Dummy State
-  FbOut := TMemoryStream.Create();
+  FOut := TMemoryStream.Create();
 end;
 
 destructor TNullDigest.Destroy;
 begin
-  FbOut.Free;
+  FOut.Free;
   inherited Destroy;
 end;
 
 procedure TNullDigest.Initialize;
 begin
-  FbOut.Position := 0;
-  FbOut.Size := 0;
+  FOut.Position := 0;
+  FOut.Size := 0;
   HashSize := 0;
   BlockSize := 0;
 end;
 
-procedure TNullDigest.TransformBytes(const a_data: THashLibByteArray;
-  a_index, a_length: Int32);
+procedure TNullDigest.TransformBytes(const AData: THashLibByteArray;
+  AIndex, ALength: Int32);
 begin
-  if a_data <> Nil then
+  if AData <> Nil then
   begin
-    FbOut.Write(a_data[a_index], a_length);
-    HashSize := Int32(FbOut.Size);
+    FOut.Write(AData[AIndex], ALength);
+    HashSize := Int32(FOut.Size);
   end;
 end;
 
 function TNullDigest.TransformFinal: IHashResult;
 var
-  res: THashLibByteArray;
+  LResult: THashLibByteArray;
 begin
   try
-    if FbOut.Size > 0 then
+    if FOut.Size > 0 then
     begin
-      FbOut.Position := 0;
-      System.SetLength(res, FbOut.Size);
-      FbOut.Read(res[0], FbOut.Size);
+      FOut.Position := 0;
+      System.SetLength(LResult, FOut.Size);
+      FOut.Read(LResult[0], FOut.Size);
     end;
-    result := THashResult.Create(res);
+    result := THashResult.Create(LResult);
   finally
     Initialize();
   end;

+ 2 - 6
src/libraries/hashlib4pascal/HlpNullable.pas

@@ -8,12 +8,8 @@ unit HlpNullable;
 interface
 
 uses
-  HlpHashLibTypes,
-{$IFDEF HAS_UNITSCOPE}
-  System.TypInfo
-{$ELSE}
-  TypInfo
-{$ENDIF HAS_UNITSCOPE};
+  TypInfo,
+  HlpHashLibTypes;
 
 resourcestring
   SCannotAssignPointerToNullable =

+ 26 - 27
src/libraries/hashlib4pascal/HlpOneAtTime.pas

@@ -15,14 +15,14 @@ uses
 type
   TOneAtTime = class sealed(THash, IHash32, ITransformBlock)
   strict private
-
-    Fm_hash: UInt32;
+  var
+    FHash: UInt32;
 
   public
     constructor Create();
     procedure Initialize(); override;
-    procedure TransformBytes(const a_data: THashLibByteArray;
-      a_index, a_length: Int32); override;
+    procedure TransformBytes(const AData: THashLibByteArray;
+      AIndex, ALength: Int32); override;
     function TransformFinal(): IHashResult; override;
     function Clone(): IHash; override;
   end;
@@ -33,11 +33,11 @@ implementation
 
 function TOneAtTime.Clone(): IHash;
 var
-  HashInstance: TOneAtTime;
+  LHashInstance: TOneAtTime;
 begin
-  HashInstance := TOneAtTime.Create();
-  HashInstance.Fm_hash := Fm_hash;
-  result := HashInstance as IHash;
+  LHashInstance := TOneAtTime.Create();
+  LHashInstance.FHash := FHash;
+  result := LHashInstance as IHash;
   result.BufferSize := BufferSize;
 end;
 
@@ -48,38 +48,37 @@ end;
 
 procedure TOneAtTime.Initialize;
 begin
-  Fm_hash := 0;
+  FHash := 0;
 end;
 
-procedure TOneAtTime.TransformBytes(const a_data: THashLibByteArray;
-  a_index, a_length: Int32);
+procedure TOneAtTime.TransformBytes(const AData: THashLibByteArray;
+  AIndex, ALength: Int32);
 var
-  i: Int32;
+  LIdx: Int32;
 begin
 {$IFDEF DEBUG}
-  System.Assert(a_index >= 0);
-  System.Assert(a_length >= 0);
-  System.Assert(a_index + a_length <= System.Length(a_data));
+  System.Assert(AIndex >= 0);
+  System.Assert(ALength >= 0);
+  System.Assert(AIndex + ALength <= System.Length(AData));
 {$ENDIF DEBUG}
-  i := a_index;
-  while a_length > 0 do
+  LIdx := AIndex;
+  while ALength > 0 do
   begin
-    Fm_hash := Fm_hash + a_data[i];
-    Fm_hash := Fm_hash + (Fm_hash shl 10);
-    Fm_hash := Fm_hash xor (Fm_hash shr 6);
-    System.Inc(i);
-    System.Dec(a_length);
+    FHash := FHash + AData[LIdx];
+    FHash := FHash + (FHash shl 10);
+    FHash := FHash xor (FHash shr 6);
+    System.Inc(LIdx);
+    System.Dec(ALength);
   end;
-
 end;
 
 function TOneAtTime.TransformFinal: IHashResult;
 begin
-  Fm_hash := Fm_hash + (Fm_hash shl 3);
-  Fm_hash := Fm_hash xor (Fm_hash shr 11);
-  Fm_hash := Fm_hash + (Fm_hash shl 15);
+  FHash := FHash + (FHash shl 3);
+  FHash := FHash xor (FHash shr 11);
+  FHash := FHash + (FHash shl 15);
 
-  result := THashResult.Create(Fm_hash);
+  result := THashResult.Create(FHash);
   Initialize();
 end;
 

+ 67 - 57
src/libraries/hashlib4pascal/HlpPBKDF2_HMACNotBuildInAdapter.pas

@@ -15,7 +15,7 @@ uses
 
 resourcestring
   SInvalidByteCount =
-    '"bc (ByteCount)" Argument must be a value greater than zero.';
+    '"(AByteCount)" Argument must be a value greater than zero.';
   SInvalidIndex = 'Invalid start or end index in the internal buffer';
   SNotInitializedIHashInstance = '"IHash" instance is uninitialized';
   SIterationtooSmall = 'Iteration must be greater than zero.';
@@ -26,6 +26,7 @@ type
     IPBKDF2_HMACNotBuildIn)
 
   strict private
+  var
     FHash: IHash;
     FHMAC: IHMAC;
     FPassword, FSalt, FBuffer: THashLibByteArray;
@@ -41,17 +42,17 @@ type
     /// <summary>
     /// Encodes an integer into a 4-byte array, in big endian.
     /// </summary>
-    /// <param name="i">The integer to encode.</param>
+    /// <param name="AInput">The integer to encode.</param>
     /// <returns>array of bytes, in big endian.</returns>
-    class function GetBigEndianBytes(i: UInt32): THashLibByteArray;
+    class function GetBigEndianBytes(AInput: UInt32): THashLibByteArray;
       static; inline;
 
-    class procedure ValidatePBKDF2_HMACInputs(const a_hash: IHash;
-      a_iterations: UInt32); static;
+    class procedure ValidatePBKDF2_HMACInputs(const AHash: IHash;
+      AIterations: UInt32); static;
   public
 
-    constructor Create(const a_underlyingHash: IHash;
-      const a_password, a_salt: THashLibByteArray; a_iterations: UInt32);
+    constructor Create(const AUnderlyingHash: IHash;
+      const APassword, ASalt: THashLibByteArray; AIterations: UInt32);
 
     destructor Destroy; override;
 
@@ -60,11 +61,11 @@ type
     /// <summary>
     /// Returns the pseudo-random bytes for this object.
     /// </summary>
-    /// <param name="bc">The number of pseudo-random key bytes to generate.</param>
+    /// <param name="AByteCount">The number of pseudo-random key bytes to generate.</param>
     /// <returns>A byte array filled with pseudo-random key bytes.</returns>
-    /// <exception cref="EArgumentOutOfRangeHashLibException">bc must be greater than zero.</exception>
+    /// <exception cref="EArgumentOutOfRangeHashLibException">AByteCount must be greater than zero.</exception>
     /// <exception cref="EArgumentHashLibException">invalid start index or end index of internal buffer.</exception>
-    function GetBytes(bc: Int32): THashLibByteArray; override;
+    function GetBytes(AByteCount: Int32): THashLibByteArray; override;
 
   end;
 
@@ -73,12 +74,12 @@ implementation
 { TPBKDF2_HMACNotBuildInAdapter }
 
 class procedure TPBKDF2_HMACNotBuildInAdapter.ValidatePBKDF2_HMACInputs
-  (const a_hash: IHash; a_iterations: UInt32);
+  (const AHash: IHash; AIterations: UInt32);
 begin
-  if not(System.Assigned(a_hash)) then
+  if not(System.Assigned(AHash)) then
     raise EArgumentNilHashLibException.CreateRes(@SNotInitializedIHashInstance);
 
-  if (a_iterations < 1) then
+  if (AIterations < 1) then
     raise EArgumentHashLibException.CreateRes(@SIterationtooSmall);
 end;
 
@@ -88,15 +89,15 @@ begin
   TArrayUtils.ZeroFill(FSalt);
 end;
 
-constructor TPBKDF2_HMACNotBuildInAdapter.Create(const a_underlyingHash: IHash;
-  const a_password, a_salt: THashLibByteArray; a_iterations: UInt32);
+constructor TPBKDF2_HMACNotBuildInAdapter.Create(const AUnderlyingHash: IHash;
+  const APassword, ASalt: THashLibByteArray; AIterations: UInt32);
 begin
   Inherited Create();
-  ValidatePBKDF2_HMACInputs(a_underlyingHash, a_iterations);
-  FHash := a_underlyingHash;
-  FPassword := System.Copy(a_password);
-  FSalt := System.Copy(a_salt);
-  FIterationCount := a_iterations;
+  ValidatePBKDF2_HMACInputs(AUnderlyingHash, AIterations);
+  FHash := AUnderlyingHash;
+  FPassword := System.Copy(APassword);
+  FSalt := System.Copy(ASalt);
+  FIterationCount := AIterations;
   Initialize();
 end;
 
@@ -106,68 +107,76 @@ begin
   inherited Destroy;
 end;
 
-class function TPBKDF2_HMACNotBuildInAdapter.GetBigEndianBytes(i: UInt32)
+class function TPBKDF2_HMACNotBuildInAdapter.GetBigEndianBytes(AInput: UInt32)
   : THashLibByteArray;
 var
-  b, invertedBytes: THashLibByteArray;
+  LBytes, LInvertedBytes: THashLibByteArray;
 begin
-  b := TBitConverter.GetBytes(i);
-  invertedBytes := THashLibByteArray.Create(b[3], b[2], b[1], b[0]);
+  LBytes := TBitConverter.GetBytes(AInput);
+  LInvertedBytes := THashLibByteArray.Create(LBytes[3], LBytes[2], LBytes[1],
+    LBytes[0]);
   if TBitConverter.IsLittleEndian then
-    result := invertedBytes
+  begin
+    result := LInvertedBytes
+  end
   else
-    result := b;
+  begin
+    result := LBytes;
+  end;
 end;
 
 function TPBKDF2_HMACNotBuildInAdapter.Func: THashLibByteArray;
 var
-  INT_block, temp, ret: THashLibByteArray;
-  i: UInt32;
-  j: Int32;
+  LINT_Block, LTemp, LRet: THashLibByteArray;
+  LIdx: UInt32;
+  LJdx: Int32;
 begin
 
-  INT_block := TPBKDF2_HMACNotBuildInAdapter.GetBigEndianBytes(FBlock);
+  LINT_Block := TPBKDF2_HMACNotBuildInAdapter.GetBigEndianBytes(FBlock);
   FHMAC.Initialize();
 
   FHMAC.TransformBytes(FSalt, 0, System.Length(FSalt));
-  FHMAC.TransformBytes(INT_block, 0, System.Length(INT_block));
+  FHMAC.TransformBytes(LINT_Block, 0, System.Length(LINT_Block));
 
-  temp := FHMAC.TransformFinal().GetBytes();
+  LTemp := FHMAC.TransformFinal().GetBytes();
 
-  ret := temp;
+  LRet := LTemp;
 
-  i := 2;
-  while i <= FIterationCount do
+  LIdx := 2;
+  while LIdx <= FIterationCount do
   begin
-    temp := FHMAC.ComputeBytes(temp).GetBytes();
-    j := 0;
-    while j < FBlockSize do
+    LTemp := FHMAC.ComputeBytes(LTemp).GetBytes();
+    LJdx := 0;
+    while LJdx < FBlockSize do
     begin
-      ret[j] := ret[j] xor temp[j];
-      System.Inc(j);
+      LRet[LJdx] := LRet[LJdx] xor LTemp[LJdx];
+      System.Inc(LJdx);
     end;
-    System.Inc(i);
+    System.Inc(LIdx);
   end;
   System.Inc(FBlock);
-  result := ret;
+  result := LRet;
 end;
 
-function TPBKDF2_HMACNotBuildInAdapter.GetBytes(bc: Int32): THashLibByteArray;
+function TPBKDF2_HMACNotBuildInAdapter.GetBytes(AByteCount: Int32)
+  : THashLibByteArray;
 var
-  LKey, LT_block: THashLibByteArray;
+  LKey, LT_Block: THashLibByteArray;
   LOffset, LSize, LRemainder, LRemCount: Int32;
 begin
 
-  if (bc <= 0) then
+  if (AByteCount <= 0) then
+  begin
     raise EArgumentHashLibException.CreateRes(@SInvalidByteCount);
+  end;
 
-  System.SetLength(LKey, bc);
+  System.SetLength(LKey, AByteCount);
 
   LOffset := 0;
   LSize := FEndIndex - FStartIndex;
   if (LSize > 0) then
   begin
-    if (bc >= LSize) then
+    if (AByteCount >= LSize) then
     begin
       System.Move(FBuffer[FStartIndex], LKey[0], LSize);
       FStartIndex := 0;
@@ -176,35 +185,37 @@ begin
     end
     else
     begin
-      System.Move(FBuffer[FStartIndex], LKey[0], bc);
-      FStartIndex := FStartIndex + bc;
+      System.Move(FBuffer[FStartIndex], LKey[0], AByteCount);
+      FStartIndex := FStartIndex + AByteCount;
       result := LKey;
       Exit;
     end;
   end;
 
   if ((FStartIndex <> 0) and (FEndIndex <> 0)) then
+  begin
     raise EArgumentHashLibException.CreateRes(@SInvalidIndex);
+  end;
 
-  while (LOffset < bc) do
+  while (LOffset < AByteCount) do
   begin
-    LT_block := Func();
-    LRemainder := bc - LOffset;
+    LT_Block := Func();
+    LRemainder := AByteCount - LOffset;
     if (LRemainder > FBlockSize) then
     begin
-      System.Move(LT_block[0], LKey[LOffset], FBlockSize);
+      System.Move(LT_Block[0], LKey[LOffset], FBlockSize);
       LOffset := LOffset + FBlockSize;
     end
     else
     begin
-      if LRemainder > 0 then
+      if (LRemainder > 0) then
       begin
-        System.Move(LT_block[0], LKey[LOffset], LRemainder);
+        System.Move(LT_Block[0], LKey[LOffset], LRemainder);
       end;
       LRemCount := FBlockSize - LRemainder;
       if LRemCount > 0 then
       begin
-        System.Move(LT_block[LRemainder], FBuffer[FStartIndex], LRemCount);
+        System.Move(LT_Block[LRemainder], FBuffer[FStartIndex], LRemCount);
       end;
       FEndIndex := FEndIndex + LRemCount;
       result := LKey;
@@ -212,7 +223,6 @@ begin
     end;
   end;
   result := LKey;
-
 end;
 
 procedure TPBKDF2_HMACNotBuildInAdapter.Initialize;

+ 251 - 157
src/libraries/hashlib4pascal/HlpPBKDF_Argon2NotBuildInAdapter.pas

@@ -5,11 +5,11 @@
 interface
 
 uses
-{$IFDEF DELPHIXE7_UP}
+{$IFDEF HAS_DELPHI_PPL}
   System.Classes,
   System.SysUtils,
   System.Threading,
-{$ENDIF DELPHIXE7_UP}
+{$ENDIF HAS_DELPHI_PPL}
   HlpKDF,
   HlpBits,
   HlpIHash,
@@ -23,7 +23,7 @@ uses
   HlpHashLibTypes;
 
 resourcestring
-  SInvalidOutputByteCount = '"bc (ByteCount)" Argument Less Than "%d".';
+  SInvalidOutputByteCount = '"(AByteCount)" Argument Less Than "%d".';
   SBlockInstanceNotInitialized = 'Block Instance not Initialized';
   SInputLengthInvalid = 'Input Length "%d" is not Equal to BlockSize "%d"';
   SLanesTooSmall = 'Lanes Must be Greater Than "%d"';
@@ -166,10 +166,37 @@ type
     IPBKDF_Argon2NotBuildIn)
 
   strict private
+
+  const
+
+    ARGON2_BLOCK_SIZE = Int32(1024);
+    ARGON2_QWORDS_IN_BLOCK = Int32(ARGON2_BLOCK_SIZE div 8);
+
+    ARGON2_ADDRESSES_IN_BLOCK = Int32(128);
+
+    ARGON2_PREHASH_DIGEST_LENGTH = Int32(64);
+    ARGON2_PREHASH_SEED_LENGTH = Int32(72);
+
+    ARGON2_SYNC_POINTS = Int32(4);
+
+    // Minimum and maximum number of lanes (degree of parallelism)
+    MIN_PARALLELISM = Int32(1);
+    MAX_PARALLELISM = Int32(16777216);
+
+    // Minimum digest size in bytes
+    MIN_OUTLEN = Int32(4);
+
+    // Minimum and maximum number of passes
+    MIN_ITERATIONS = Int32(1);
+
   type
     TBlock = record
 
     private
+
+      const
+      SIZE = Int32(ARGON2_QWORDS_IN_BLOCK);
+
     var
       // 128 * 8 Byte QWords
       Fv: THashLibUInt64Array;
@@ -184,7 +211,7 @@ type
     public
       class function CreateBlock(): TBlock; static;
 
-      procedure Clear(); inline;
+      function Clear(): TBlock; inline;
       procedure &Xor(const AB1, AB2, AB3: TBlock); overload;
       procedure FromBytes(const AInput: THashLibByteArray);
 
@@ -201,32 +228,39 @@ type
       FPass, FLane, FSlice, FIndex: Int32;
 
     public
-      class function CreatePosition(APass, ALane, ASlice, AIndex: Int32)
-        : TPosition; static;
 
-    end;
+      class function CreatePosition(): TPosition; static;
 
-  const
+      procedure Update(APass, ALane, ASlice, AIndex: Int32);
 
-    ARGON2_BLOCK_SIZE = Int32(1024);
-    ARGON2_QWORDS_IN_BLOCK = Int32(ARGON2_BLOCK_SIZE div 8);
+    end;
 
-    ARGON2_ADDRESSES_IN_BLOCK = Int32(128);
+  type
+    TFillBlock = record
 
-    ARGON2_PREHASH_DIGEST_LENGTH = Int32(64);
-    ARGON2_PREHASH_SEED_LENGTH = Int32(72);
+    private
+    var
+      FR, FZ, FAddressBlock, FZeroBlock, FInputBlock: TBlock;
 
-    ARGON2_SYNC_POINTS = Int32(4);
+      function GetR: TBlock; inline;
+      function GetZ: TBlock; inline;
+      function GetAddressBlock: TBlock; inline;
+      function GetZeroBlock: TBlock; inline;
+      function GetInputBlock: TBlock; inline;
 
-    // Minimum and maximum number of lanes (degree of parallelism)
-    MIN_PARALLELISM = Int32(1);
-    MAX_PARALLELISM = Int32(16777216);
+      procedure ApplyBlake();
 
-    // Minimum digest size in bytes
-    MIN_OUTLEN = Int32(4);
+      procedure FillBlock(var Ax, Ay, ACurrentBlock: TBlock; AWithXor: Boolean);
 
-    // Minimum and maximum number of passes
-    MIN_ITERATIONS = Int32(1);
+    public
+      property R: TBlock read GetR;
+      property Z: TBlock read GetZ;
+      property AddressBlock: TBlock read GetAddressBlock;
+      property ZeroBlock: TBlock read GetZeroBlock;
+      property InputBlock: TBlock read GetInputBlock;
+
+      class function CreateFillBlock(): TFillBlock; static;
+    end;
 
   var
 
@@ -244,36 +278,42 @@ type
     class function MakeBlake2BInstanceAndInitialize(AHashSize: Int32): IHash;
       static; inline;
 
-    class function GetStartingIndex(const APosition: TPosition): Int32; inline;
+    class function GetStartingIndex(const APosition: TPosition): Int32;
+      static; inline;
 
-    procedure InitializeMemory(AMemoryBlocks: Int32);
-    procedure DoInit(const AParameters: IArgon2Parameters);
-    // Clear memory.
-    procedure Reset();
     {
       *designed by the Lyra PHC team */
       /* a <- a + b + 2*aL*bL
       * + == addition modulo 2^64
       * aL = least 32 bit
       * }
-    procedure fBlaMka(var ABlock: TBlock; Ax, Ay: Int32); inline;
-    procedure Rotr64(var ABlock: TBlock; Av, Aw, Ac: Int32); inline;
-    procedure F(var ABlock: TBlock; Aa, Ab, Ac, Ad: Int32); inline;
-    procedure RoundFunction(var ABlock: TBlock; Av0, Av1, Av2, Av3, Av4, Av5,
-      Av6, Av7, Av8, Av9, Av10, Av11, Av12, Av13, Av14, Av15: Int32); inline;
-    procedure FillBlock(var Ax, Ay, ACurrentBlock: TBlock; AWithXor: Boolean);
+    class procedure FBlaMka(var ABlock: TBlock; Ax, Ay: Int32); static; inline;
+    class procedure Rotr64(var ABlock: TBlock; Av, Aw, Ac: Int32);
+      static; inline;
+    class procedure F(var ABlock: TBlock; Aa, Ab, Ac, Ad: Int32);
+      static; inline;
+    class procedure RoundFunction(var ABlock: TBlock;
+      Av0, Av1, Av2, Av3, Av4, Av5, Av6, Av7, Av8, Av9, Av10, Av11, Av12, Av13,
+      Av14, Av15: Int32); static; inline;
+
+    procedure InitializeMemory(AMemoryBlocks: Int32);
+    procedure DoInit(const AParameters: IArgon2Parameters);
+    // Clear memory.
+    procedure Reset();
 
     function IsDataIndependentAddressing(const APosition: TPosition)
       : Boolean; inline;
-    procedure NextAddresses(var AZeroBlock, AInputBlock, AAddressBlock
-      : TBlock); inline;
+    procedure NextAddresses(const AFiller: TFillBlock;
+      var AZeroBlock, AInputBlock, AAddressBlock: TBlock); inline;
     function IntToUInt64(Ax: Int32): UInt64; inline;
-    procedure InitAddressBlocks(const APosition: TPosition;
-      var AZeroBlock, AInputBlock, AAddressBlock: TBlock);
+    procedure InitAddressBlocks(const AFiller: TFillBlock;
+      const APosition: TPosition; var AZeroBlock, AInputBlock,
+      AAddressBlock: TBlock);
     (* 1.2 Computing the index of the reference block
       1.2.1 Taking pseudo-random value from the previous block *)
-    function GetPseudoRandom(const APosition: TPosition;
-      var AAddressBlock, AInputBlock, AZeroBlock: TBlock; APrevOffset: Int32;
+    function GetPseudoRandom(const AFiller: TFillBlock;
+      const APosition: TPosition; var AAddressBlock, AInputBlock,
+      AZeroBlock: TBlock; APrevOffset: Int32;
       ADataIndependentAddressing: Boolean): UInt64;
     function GetRefLane(const APosition: TPosition; APseudoRandom: UInt64)
       : Int32; inline;
@@ -283,7 +323,7 @@ type
     function GetPrevOffset(ACurrentOffset: Int32): Int32; inline;
     function RotatePrevOffset(ACurrentOffset, APrevOffset: Int32)
       : Int32; inline;
-    procedure FillSegment(var APosition: TPosition);
+    procedure FillSegment(const AFiller: TFillBlock; var APosition: TPosition);
     procedure DoParallelFillMemoryBlocks();
 
     (* *
@@ -335,10 +375,10 @@ type
     /// <summary>
     /// Returns the pseudo-random bytes for this object.
     /// </summary>
-    /// <param name="bc">The number of pseudo-random key bytes to generate.</param>
+    /// <param name="AByteCount">The number of pseudo-random key bytes to generate.</param>
     /// <returns>A byte array filled with pseudo-random key bytes.</returns>
-    /// /// <exception cref="EArgumentOutOfRangeHashLibException">bc must be greater than zero.</exception>
-    function GetBytes(bc: Int32): THashLibByteArray; override;
+    /// /// <exception cref="EArgumentOutOfRangeHashLibException">AByteCount must be greater than MIN_OUTLEN.</exception>
+    function GetBytes(AByteCount: Int32): THashLibByteArray; override;
 
   end;
 
@@ -539,8 +579,10 @@ class procedure TPBKDF_Argon2NotBuildInAdapter.ValidatePBKDF_Argon2Inputs
   (const AArgon2Parameters: IArgon2Parameters);
 begin
   if not(System.Assigned(AArgon2Parameters)) then
+  begin
     raise EArgumentNilHashLibException.CreateRes
       (@SArgon2ParameterBuilderNotInitialized);
+  end;
 end;
 
 class procedure TPBKDF_Argon2NotBuildInAdapter.AddIntToLittleEndian
@@ -577,12 +619,10 @@ begin
   begin
     // we have already generated the first two blocks
     result := 2;
-    Exit;
   end
   else
   begin
     result := 0;
-    Exit;
   end;
 end;
 
@@ -632,10 +672,9 @@ begin
   end;
   FMemory := Nil;
   TArrayUtils.ZeroFill(FResult);
-  DoInit(FParameters);
 end;
 
-procedure TPBKDF_Argon2NotBuildInAdapter.fBlaMka(var ABlock: TBlock;
+class procedure TPBKDF_Argon2NotBuildInAdapter.FBlaMka(var ABlock: TBlock;
   Ax, Ay: Int32);
 var
   Lm: UInt32;
@@ -647,32 +686,32 @@ begin
   ABlock.Fv[Ax] := ABlock.Fv[Ax] + ABlock.Fv[Ay] + (2 * Lxy);
 end;
 
-procedure TPBKDF_Argon2NotBuildInAdapter.Rotr64(var ABlock: TBlock;
+class procedure TPBKDF_Argon2NotBuildInAdapter.Rotr64(var ABlock: TBlock;
   Av, Aw, Ac: Int32);
 var
-  Ltemp: UInt64;
+  LTemp: UInt64;
 begin
-  Ltemp := ABlock.Fv[Av] xor ABlock.Fv[Aw];
-  ABlock.Fv[Av] := TBits.RotateRight64(Ltemp, Ac);
+  LTemp := ABlock.Fv[Av] xor ABlock.Fv[Aw];
+  ABlock.Fv[Av] := TBits.RotateRight64(LTemp, Ac);
 end;
 
-procedure TPBKDF_Argon2NotBuildInAdapter.F(var ABlock: TBlock;
+class procedure TPBKDF_Argon2NotBuildInAdapter.F(var ABlock: TBlock;
   Aa, Ab, Ac, Ad: Int32);
 begin
-  fBlaMka(ABlock, Aa, Ab);
+  FBlaMka(ABlock, Aa, Ab);
   Rotr64(ABlock, Ad, Aa, 32);
 
-  fBlaMka(ABlock, Ac, Ad);
+  FBlaMka(ABlock, Ac, Ad);
   Rotr64(ABlock, Ab, Ac, 24);
 
-  fBlaMka(ABlock, Aa, Ab);
+  FBlaMka(ABlock, Aa, Ab);
   Rotr64(ABlock, Ad, Aa, 16);
 
-  fBlaMka(ABlock, Ac, Ad);
+  FBlaMka(ABlock, Ac, Ad);
   Rotr64(ABlock, Ab, Ac, 63);
 end;
 
-procedure TPBKDF_Argon2NotBuildInAdapter.RoundFunction(var ABlock: TBlock;
+class procedure TPBKDF_Argon2NotBuildInAdapter.RoundFunction(var ABlock: TBlock;
   Av0, Av1, Av2, Av3, Av4, Av5, Av6, Av7, Av8, Av9, Av10, Av11, Av12, Av13,
   Av14, Av15: Int32);
 begin
@@ -687,51 +726,6 @@ begin
   F(ABlock, Av3, Av4, Av9, Av14);
 end;
 
-procedure TPBKDF_Argon2NotBuildInAdapter.FillBlock(var Ax, Ay,
-  ACurrentBlock: TBlock; AWithXor: Boolean);
-var
-  R, Z: TBlock;
-  i: Int32;
-begin
-  R := TBlock.CreateBlock();
-  Z := TBlock.CreateBlock();
-
-  R.&Xor(Ax, Ay);
-  Z.CopyBlock(R);
-
-  (* Apply Blake2 on columns of 64-bit words: (0,1,...,15) , then
-    (16,17,..31)... finally (112,113,...127) *)
-
-  for i := 0 to System.Pred(8) do
-  begin
-
-    RoundFunction(Z, 16 * i, 16 * i + 1, 16 * i + 2, 16 * i + 3, 16 * i + 4,
-      16 * i + 5, 16 * i + 6, 16 * i + 7, 16 * i + 8, 16 * i + 9, 16 * i + 10,
-      16 * i + 11, 16 * i + 12, 16 * i + 13, 16 * i + 14, 16 * i + 15);
-  end;
-
-  (* Apply Blake2 on rows of 64-bit words: (0,1,16,17,...112,113), then
-    (2,3,18,19,...,114,115).. finally (14,15,30,31,...,126,127) *)
-
-  for i := 0 to System.Pred(8) do
-  begin
-
-    RoundFunction(Z, 2 * i, 2 * i + 1, 2 * i + 16, 2 * i + 17, 2 * i + 32,
-      2 * i + 33, 2 * i + 48, 2 * i + 49, 2 * i + 64, 2 * i + 65, 2 * i + 80,
-      2 * i + 81, 2 * i + 96, 2 * i + 97, 2 * i + 112, 2 * i + 113);
-
-  end;
-
-  if (AWithXor) then
-  begin
-    ACurrentBlock.&Xor(R, Z, ACurrentBlock);
-  end
-  else
-  begin
-    ACurrentBlock.&Xor(R, Z);
-  end;
-end;
-
 function TPBKDF_Argon2NotBuildInAdapter.InitialHash(const AParameters
   : IArgon2Parameters; AOutputLength: Int32; const APassword: THashLibByteArray)
   : THashLibByteArray;
@@ -893,12 +887,12 @@ begin
     and (APosition.FSlice < (ARGON2_SYNC_POINTS div 2)));
 end;
 
-procedure TPBKDF_Argon2NotBuildInAdapter.NextAddresses(var AZeroBlock,
-  AInputBlock, AAddressBlock: TBlock);
+procedure TPBKDF_Argon2NotBuildInAdapter.NextAddresses(const AFiller
+  : TFillBlock; var AZeroBlock, AInputBlock, AAddressBlock: TBlock);
 begin
   System.Inc(AInputBlock.Fv[6]);
-  FillBlock(AZeroBlock, AInputBlock, AAddressBlock, False);
-  FillBlock(AZeroBlock, AAddressBlock, AAddressBlock, False);
+  AFiller.FillBlock(AZeroBlock, AInputBlock, AAddressBlock, False);
+  AFiller.FillBlock(AZeroBlock, AAddressBlock, AAddressBlock, False);
 end;
 
 function TPBKDF_Argon2NotBuildInAdapter.IntToUInt64(Ax: Int32): UInt64;
@@ -906,8 +900,9 @@ begin
   result := UInt64((Ax and UInt32($FFFFFFFF)))
 end;
 
-procedure TPBKDF_Argon2NotBuildInAdapter.InitAddressBlocks(const APosition
-  : TPosition; var AZeroBlock, AInputBlock, AAddressBlock: TBlock);
+procedure TPBKDF_Argon2NotBuildInAdapter.InitAddressBlocks
+  (const AFiller: TFillBlock; const APosition: TPosition;
+  var AZeroBlock, AInputBlock, AAddressBlock: TBlock);
 begin
   AInputBlock.Fv[0] := IntToUInt64(APosition.FPass);
   AInputBlock.Fv[1] := IntToUInt64(APosition.FLane);
@@ -919,19 +914,20 @@ begin
   if ((APosition.FPass = 0) and (APosition.FSlice = 0)) then
   begin
     // Don't forget to generate the first block of addresses: */
-    NextAddresses(AZeroBlock, AInputBlock, AAddressBlock);
+    NextAddresses(AFiller, AZeroBlock, AInputBlock, AAddressBlock);
   end;
 end;
 
-function TPBKDF_Argon2NotBuildInAdapter.GetPseudoRandom(const APosition
-  : TPosition; var AAddressBlock, AInputBlock, AZeroBlock: TBlock;
-  APrevOffset: Int32; ADataIndependentAddressing: Boolean): UInt64;
+function TPBKDF_Argon2NotBuildInAdapter.GetPseudoRandom(const AFiller
+  : TFillBlock; const APosition: TPosition; var AAddressBlock, AInputBlock,
+  AZeroBlock: TBlock; APrevOffset: Int32;
+  ADataIndependentAddressing: Boolean): UInt64;
 begin
   if (ADataIndependentAddressing) then
   begin
     if (APosition.FIndex mod ARGON2_ADDRESSES_IN_BLOCK = 0) then
     begin
-      NextAddresses(AZeroBlock, AInputBlock, AAddressBlock);
+      NextAddresses(AFiller, AZeroBlock, AInputBlock, AAddressBlock);
     end;
     result := AAddressBlock.Fv[APosition.FIndex mod ARGON2_ADDRESSES_IN_BLOCK];
     Exit;
@@ -960,7 +956,7 @@ end;
 function TPBKDF_Argon2NotBuildInAdapter.GetRefColumn(const APosition: TPosition;
   APseudoRandom: UInt64; ASameLane: Boolean): Int32;
 var
-  LReferenceAreaSize, LStartPosition, Ltemp: Int32;
+  LReferenceAreaSize, LStartPosition, LTemp: Int32;
   LRelativePosition: UInt64;
 begin
 
@@ -978,15 +974,14 @@ begin
     begin
       if (APosition.FIndex = 0) then
       begin
-        Ltemp := -1;
+        LTemp := -1;
       end
       else
       begin
-        Ltemp := 0;
+        LTemp := 0;
       end;
-      LReferenceAreaSize := (APosition.FSlice * FSegmentLength) + Ltemp;
+      LReferenceAreaSize := (APosition.FSlice * FSegmentLength) + LTemp;
     end
-
   end
   else
   begin
@@ -1000,13 +995,13 @@ begin
     begin
       if (APosition.FIndex = 0) then
       begin
-        Ltemp := -1;
+        LTemp := -1;
       end
       else
       begin
-        Ltemp := 0;
+        LTemp := 0;
       end;
-      LReferenceAreaSize := FLaneLength - FSegmentLength + Ltemp;
+      LReferenceAreaSize := FLaneLength - FSegmentLength + LTemp;
     end;
   end;
 
@@ -1052,7 +1047,8 @@ begin
   result := APrevOffset;
 end;
 
-procedure TPBKDF_Argon2NotBuildInAdapter.FillSegment(var APosition: TPosition);
+procedure TPBKDF_Argon2NotBuildInAdapter.FillSegment(const AFiller: TFillBlock;
+  var APosition: TPosition);
 var
   LAddressBlock, LInputBlock, LZeroBlock, LPrevBlock, LRefBlock,
     LCurrentBlock: TBlock;
@@ -1069,11 +1065,12 @@ begin
 
   if (LDataIndependentAddressing) then
   begin
-    LAddressBlock := TBlock.CreateBlock();
-    LZeroBlock := TBlock.CreateBlock();
-    LInputBlock := TBlock.CreateBlock();
+    LAddressBlock := AFiller.AddressBlock.Clear();
+    LZeroBlock := AFiller.ZeroBlock.Clear();
+    LInputBlock := AFiller.InputBlock.Clear();
 
-    InitAddressBlocks(APosition, LZeroBlock, LInputBlock, LAddressBlock);
+    InitAddressBlocks(AFiller, APosition, LZeroBlock, LInputBlock,
+      LAddressBlock);
   end;
 
   APosition.FIndex := LStartingIndex;
@@ -1082,8 +1079,8 @@ begin
   begin
     LPrevOffset := RotatePrevOffset(LCurrentOffset, LPrevOffset);
 
-    LPseudoRandom := GetPseudoRandom(APosition, LAddressBlock, LInputBlock,
-      LZeroBlock, LPrevOffset, LDataIndependentAddressing);
+    LPseudoRandom := GetPseudoRandom(AFiller, APosition, LAddressBlock,
+      LInputBlock, LZeroBlock, LPrevOffset, LDataIndependentAddressing);
     LRefLane := GetRefLane(APosition, LPseudoRandom);
     LRefColumn := GetRefColumn(APosition, LPseudoRandom,
       LRefLane = APosition.FLane);
@@ -1094,7 +1091,7 @@ begin
     LCurrentBlock := FMemory[LCurrentOffset];
 
     LWithXor := IsWithXor(APosition);
-    FillBlock(LPrevBlock, LRefBlock, LCurrentBlock, LWithXor);
+    AFiller.FillBlock(LPrevBlock, LRefBlock, LCurrentBlock, LWithXor);
 
     System.Inc(APosition.FIndex);
     System.Inc(LCurrentOffset);
@@ -1102,33 +1099,37 @@ begin
   end;
 end;
 
-{$IFDEF DELPHIXE7_UP}
+{$IFDEF HAS_DELPHI_PPL}
 
 procedure TPBKDF_Argon2NotBuildInAdapter.DoParallelFillMemoryBlocks;
 
-  function CreateTask(APosition: TPosition): ITask;
+  function CreateTask(AFiller: TFillBlock; APosition: TPosition): ITask;
   begin
     result := TTask.Create(
       procedure()
       begin
-        FillSegment(APosition);
+        FillSegment(AFiller, APosition);
       end);
   end;
 
 var
   LIdx, LJdx, LKdx, LTaskIdx: Int32;
+  LFiller: TFillBlock;
   LPosition: TPosition;
   LArrayTasks: array of ITask;
 begin
   System.SetLength(LArrayTasks, FParameters.Lanes);
+
   for LIdx := 0 to System.Pred(FParameters.Iterations) do
   begin
     for LJdx := 0 to System.Pred(ARGON2_SYNC_POINTS) do
     begin
       for LKdx := 0 to System.Pred(FParameters.Lanes) do
       begin
-        LPosition := TPosition.CreatePosition(LIdx, LKdx, LJdx, 0);
-        LArrayTasks[LKdx] := CreateTask(LPosition);
+        LFiller := TFillBlock.CreateFillBlock();
+        LPosition := TPosition.CreatePosition();
+        LPosition.Update(LIdx, LKdx, LJdx, 0);
+        LArrayTasks[LKdx] := CreateTask(LFiller, LPosition);
       end;
       for LTaskIdx := System.Low(LArrayTasks) to System.High(LArrayTasks) do
       begin
@@ -1145,22 +1146,25 @@ end;
 procedure TPBKDF_Argon2NotBuildInAdapter.DoParallelFillMemoryBlocks;
 var
   LIdx, LJdx, LKdx: Int32;
+  LFiller: TFillBlock;
   LPosition: TPosition;
 begin
+  LFiller := TFillBlock.CreateFillBlock();
+  LPosition := TPosition.CreatePosition();
   for LIdx := 0 to System.Pred(FParameters.Iterations) do
   begin
     for LJdx := 0 to System.Pred(ARGON2_SYNC_POINTS) do
     begin
       for LKdx := 0 to System.Pred(FParameters.Lanes) do
       begin
-        LPosition := TPosition.CreatePosition(LIdx, LKdx, LJdx, 0);
-        FillSegment(LPosition);
+        LPosition.Update(LIdx, LKdx, LJdx, 0);
+        FillSegment(LFiller, LPosition);
       end;
     end;
   end;
 end;
 
-{$ENDIF DELPHIXE7_UP}
+{$ENDIF HAS_DELPHI_PPL}
 
 procedure TPBKDF_Argon2NotBuildInAdapter.Initialize(const APassword
   : THashLibByteArray; AOutputLength: Int32);
@@ -1206,7 +1210,6 @@ begin
   end;
 
   DoInit(AParameters);
-
 end;
 
 destructor TPBKDF_Argon2NotBuildInAdapter.Destroy;
@@ -1215,20 +1218,22 @@ begin
   inherited Destroy;
 end;
 
-function TPBKDF_Argon2NotBuildInAdapter.GetBytes(bc: Int32): THashLibByteArray;
+function TPBKDF_Argon2NotBuildInAdapter.GetBytes(AByteCount: Int32)
+  : THashLibByteArray;
 begin
-  if (bc <= MIN_OUTLEN) then
+  if (AByteCount <= MIN_OUTLEN) then
+  begin
     raise EArgumentHashLibException.CreateResFmt(@SInvalidOutputByteCount,
       [MIN_OUTLEN]);
+  end;
 
-  Initialize(FPassword, bc);
+  Initialize(FPassword, AByteCount);
   DoParallelFillMemoryBlocks();
-  Digest(bc);
-  System.SetLength(result, bc);
-  System.Move(FResult[0], result[0], bc * System.SizeOf(Byte));
+  Digest(AByteCount);
+  System.SetLength(result, AByteCount);
+  System.Move(FResult[0], result[0], AByteCount * System.SizeOf(Byte));
 
   Reset();
-
 end;
 
 { TPBKDF_Argon2NotBuildInAdapter.TBlock }
@@ -1236,7 +1241,7 @@ end;
 class function TPBKDF_Argon2NotBuildInAdapter.TBlock.CreateBlock: TBlock;
 begin
   result := Default (TBlock);
-  System.SetLength(result.Fv, ARGON2_QWORDS_IN_BLOCK);
+  System.SetLength(result.Fv, SIZE);
   result.FInitialized := True;
 end;
 
@@ -1266,7 +1271,7 @@ var
 begin
   CheckAreBlocksInitialized(THashLibGenericArray<TBlock>.Create(Self,
     AB1, AB2));
-  for LIdx := 0 to System.Pred(System.Length(Fv)) do
+  for LIdx := 0 to System.Pred(SIZE) do
   begin
     Fv[LIdx] := AB1.Fv[LIdx] xor AB2.Fv[LIdx];
   end;
@@ -1283,10 +1288,11 @@ begin
   end;
 end;
 
-procedure TPBKDF_Argon2NotBuildInAdapter.TBlock.Clear;
+function TPBKDF_Argon2NotBuildInAdapter.TBlock.Clear;
 begin
   CheckAreBlocksInitialized(THashLibGenericArray<TBlock>.Create(Self));
   TArrayUtils.ZeroFill(Fv);
+  result := Self;
 end;
 
 procedure TPBKDF_Argon2NotBuildInAdapter.TBlock.&Xor(const AB1, AB2,
@@ -1296,7 +1302,7 @@ var
 begin
   CheckAreBlocksInitialized(THashLibGenericArray<TBlock>.Create(Self, AB1,
     AB2, AB3));
-  for LIdx := 0 to System.Pred(System.Length(Fv)) do
+  for LIdx := 0 to System.Pred(SIZE) do
   begin
     Fv[LIdx] := AB1.Fv[LIdx] xor AB2.Fv[LIdx] xor AB3.Fv[LIdx];
   end;
@@ -1314,7 +1320,7 @@ begin
       [System.Length(AInput), ARGON2_BLOCK_SIZE]);
   end;
 
-  for LIdx := 0 to System.Pred(System.Length(Fv)) do
+  for LIdx := 0 to System.Pred(SIZE) do
   begin
     Fv[LIdx] := TConverters.ReadBytesAsUInt64LE(PByte(AInput), LIdx * 8);
   end;
@@ -1326,7 +1332,7 @@ var
 begin
   CheckAreBlocksInitialized(THashLibGenericArray<TBlock>.Create(Self));
   System.SetLength(result, ARGON2_BLOCK_SIZE);
-  for LIdx := 0 to System.Pred(System.Length(Fv)) do
+  for LIdx := 0 to System.Pred(SIZE) do
   begin
     TConverters.ReadUInt64AsBytesLE(Fv[LIdx], result, LIdx * 8);
   end;
@@ -1338,7 +1344,7 @@ var
 begin
   CheckAreBlocksInitialized(THashLibGenericArray<TBlock>.Create(Self));
   result := '';
-  for LIdx := 0 to System.Pred(System.Length(Fv)) do
+  for LIdx := 0 to System.Pred(SIZE) do
   begin
     result := result + TConverters.ConvertBytesToHexString
       (TConverters.ReadUInt64AsBytesLE(Fv[LIdx]), False);
@@ -1347,14 +1353,102 @@ end;
 
 { TPBKDF_Argon2NotBuildInAdapter.TPosition }
 
-class function TPBKDF_Argon2NotBuildInAdapter.TPosition.CreatePosition(APass,
-  ALane, ASlice, AIndex: Int32): TPosition;
+class function TPBKDF_Argon2NotBuildInAdapter.TPosition.CreatePosition()
+  : TPosition;
 begin
   result := Default (TPosition);
-  result.FPass := APass;
-  result.FLane := ALane;
-  result.FSlice := ASlice;
-  result.FIndex := AIndex;
+end;
+
+procedure TPBKDF_Argon2NotBuildInAdapter.TPosition.Update(APass, ALane, ASlice,
+  AIndex: Int32);
+begin
+  FPass := APass;
+  FLane := ALane;
+  FSlice := ASlice;
+  FIndex := AIndex;
+end;
+
+{ TPBKDF_Argon2NotBuildInAdapter.TFillBlock }
+
+function TPBKDF_Argon2NotBuildInAdapter.TFillBlock.GetAddressBlock: TBlock;
+begin
+  result := FAddressBlock;
+end;
+
+function TPBKDF_Argon2NotBuildInAdapter.TFillBlock.GetInputBlock: TBlock;
+begin
+  result := FInputBlock;
+end;
+
+function TPBKDF_Argon2NotBuildInAdapter.TFillBlock.GetR: TBlock;
+begin
+  result := FR;
+end;
+
+function TPBKDF_Argon2NotBuildInAdapter.TFillBlock.GetZ: TBlock;
+begin
+  result := FZ;
+end;
+
+function TPBKDF_Argon2NotBuildInAdapter.TFillBlock.GetZeroBlock: TBlock;
+begin
+  result := FZeroBlock;
+end;
+
+procedure TPBKDF_Argon2NotBuildInAdapter.TFillBlock.ApplyBlake();
+var
+  Li, Li16, Li2: Int32;
+begin
+  (* Apply Blake2 on columns of 64-bit words: (0,1,...,15) , then
+    (16,17,..31)... finally (112,113,...127) *)
+
+  for Li := 0 to System.Pred(8) do
+  begin
+    Li16 := 16 * Li;
+    RoundFunction(FZ, Li16, Li16 + 1, Li16 + 2, Li16 + 3, Li16 + 4, Li16 + 5,
+      Li16 + 6, Li16 + 7, Li16 + 8, Li16 + 9, Li16 + 10, Li16 + 11, Li16 + 12,
+      Li16 + 13, Li16 + 14, Li16 + 15);
+  end;
+
+  (* Apply Blake2 on rows of 64-bit words: (0,1,16,17,...112,113), then
+    (2,3,18,19,...,114,115).. finally (14,15,30,31,...,126,127) *)
+
+  for Li := 0 to System.Pred(8) do
+  begin
+    Li2 := 2 * Li;
+    RoundFunction(FZ, Li2, Li2 + 1, Li2 + 16, Li2 + 17, Li2 + 32, Li2 + 33,
+      Li2 + 48, Li2 + 49, Li2 + 64, Li2 + 65, Li2 + 80, Li2 + 81, Li2 + 96,
+      Li2 + 97, Li2 + 112, Li2 + 113);
+  end;
+end;
+
+class function TPBKDF_Argon2NotBuildInAdapter.TFillBlock.CreateFillBlock
+  : TFillBlock;
+begin
+  result := Default (TFillBlock);
+  result.FR := TBlock.CreateBlock();
+  result.FZ := TBlock.CreateBlock();
+  result.FAddressBlock := TBlock.CreateBlock();
+  result.FZeroBlock := TBlock.CreateBlock();
+  result.FInputBlock := TBlock.CreateBlock();
+end;
+
+procedure TPBKDF_Argon2NotBuildInAdapter.TFillBlock.FillBlock(var Ax, Ay,
+  ACurrentBlock: TBlock; AWithXor: Boolean);
+begin
+  R.&Xor(Ax, Ay);
+  FZ.CopyBlock(R);
+
+  ApplyBlake();
+
+  if (AWithXor) then
+  begin
+    ACurrentBlock.&Xor(R, Z, ACurrentBlock);
+  end
+  else
+  begin
+    ACurrentBlock.&Xor(R, Z);
+  end;
 end;
 
 end.

+ 217 - 210
src/libraries/hashlib4pascal/HlpPBKDF_ScryptNotBuildInAdapter.pas

@@ -5,11 +5,14 @@ unit HlpPBKDF_ScryptNotBuildInAdapter;
 interface
 
 uses
-{$IFDEF DELPHIXE7_UP}
+{$IFDEF HAS_DELPHI_PPL}
   System.Classes,
   System.SysUtils,
   System.Threading,
-{$ENDIF DELPHIXE7_UP}
+{$ENDIF HAS_DELPHI_PPL}
+{$IFDEF DELPHI}
+  HlpBitConverter,
+{$ENDIF DELPHI}
   HlpIHash,
   HlpKDF,
   HlpBits,
@@ -22,7 +25,7 @@ uses
 
 resourcestring
   SInvalidByteCount =
-    '"bc (ByteCount)" Argument must be a value greater than zero.';
+    '"(AByteCount)" Argument must be a value greater than zero.';
   SInvalidCost = 'Cost parameter must be > 1 and a power of 2.';
   SBlockSizeAndCostIncompatible = 'Cost parameter must be > 1 and < 65536.';
   SBlockSizeTooSmall = 'Block size must be >= 1.';
@@ -44,15 +47,15 @@ type
     FPasswordBytes, FSaltBytes: THashLibByteArray;
     FCost, FBlockSize, FParallelism: Int32;
 
-    class procedure ClearArray(const AInput: THashLibByteArray);
-      overload; static;
-    class procedure ClearArray(const AInput: THashLibUInt32Array);
-      overload; static;
+    class procedure ClearArray(const AInput: THashLibByteArray); overload;
+      static; inline;
+    class procedure ClearArray(const AInput: THashLibUInt32Array); overload;
+      static; inline;
 
     class procedure ClearAllArrays(const AInputs
       : THashLibMatrixUInt32Array); static;
 
-    class function IsPowerOf2(x: Int32): Boolean; static; inline;
+    class function IsPowerOf2(Ax: Int32): Boolean; static; inline;
 
     class function SingleIterationPBKDF2(const APasswordBytes,
       ASaltBytes: THashLibByteArray; AOutputLength: Int32)
@@ -61,37 +64,38 @@ type
     /// <summary>
     /// Rotate left
     /// </summary>
-    /// <param name="x">
+    /// <param name="AValue">
     /// value to rotate
     /// </param>
-    /// <param name="y">
-    /// amount to rotate x
+    /// <param name="ADistance">
+    /// distance to rotate AValue
     /// </param>
     /// <returns>
-    /// rotated x
+    /// rotated AValue
     /// </returns>
-    class function R(x: UInt32; y: Int32): UInt32; static; inline;
+    class function Rotl(AValue: UInt32; ADistance: Int32): UInt32;
+      static; inline;
 
     /// <summary>
     /// lifted from <c>ClpSalsa20Engine.pas</c> in CryptoLib4Pascal with
     /// minor modifications.
     /// </summary>
-    class procedure SalsaCore(rounds: Int32;
-      const input, x: THashLibUInt32Array); static;
+    class procedure SalsaCore(ARounds: Int32;
+      const AInput, Ax: THashLibUInt32Array); static;
 
-    class procedure &Xor(const a, b: THashLibUInt32Array; bOff: Int32;
-      const output: THashLibUInt32Array); static;
+    class procedure &Xor(const Aa, Ab: THashLibUInt32Array; AbOff: Int32;
+      const AOutput: THashLibUInt32Array); static;
 
-    class procedure SMix(const b: THashLibUInt32Array;
-      bOff, N, R: Int32); static;
+    class procedure SMix(const Ab: THashLibUInt32Array;
+      AbOff, AN, AR: Int32); static;
 
-    class procedure BlockMix(const b, X1, X2, y: THashLibUInt32Array;
-      R: Int32); static;
+    class procedure BlockMix(const Ab, AX1, AX2, Ay: THashLibUInt32Array;
+      AR: Int32); static;
 
-    class procedure DoParallelSMix(const b: THashLibUInt32Array;
+    class procedure DoSMix(const Ab: THashLibUInt32Array;
       AParallelism, ACost, ABlockSize: Int32); static;
 
-    class function MFcrypt(const APasswordBytes, ASaltBytes: THashLibByteArray;
+    class function MFCrypt(const APasswordBytes, ASaltBytes: THashLibByteArray;
       ACost, ABlockSize, AParallelism, AOutputLength: Int32)
       : THashLibByteArray; static;
 
@@ -110,10 +114,10 @@ type
     /// <summary>
     /// Returns the pseudo-random bytes for this object.
     /// </summary>
-    /// <param name="bc">The number of pseudo-random key bytes to generate.</param>
+    /// <param name="AByteCount">The number of pseudo-random key bytes to generate.</param>
     /// <returns>A byte array filled with pseudo-random key bytes.</returns>
-    /// /// <exception cref="EArgumentOutOfRangeHashLibException">bc must be greater than zero.</exception>
-    function GetBytes(bc: Int32): THashLibByteArray; override;
+    /// /// <exception cref="EArgumentOutOfRangeHashLibException">AByteCount must be greater than zero.</exception>
+    function GetBytes(AByteCount: Int32): THashLibByteArray; override;
 
   end;
 
@@ -129,38 +133,24 @@ end;
 
 class procedure TPBKDF_ScryptNotBuildInAdapter.ClearArray
   (const AInput: THashLibUInt32Array);
-{$IFNDEF FPC}
-var
-  Idx: Int32;
-{$ENDIF}
 begin
-  if AInput <> Nil then
-  begin
-{$IFDEF FPC}
-    System.FillDWord(AInput[0], System.Length(AInput), UInt32(0));
-{$ELSE}
-    for Idx := System.Low(AInput) to System.High(AInput) do
-    begin
-      AInput[Idx] := UInt32(0);
-    end;
-{$ENDIF}
-  end;
+  TArrayUtils.ZeroFill(AInput);
 end;
 
 class procedure TPBKDF_ScryptNotBuildInAdapter.ClearAllArrays
   (const AInputs: THashLibMatrixUInt32Array);
 var
-  Idx: Int32;
+  LIdx: Int32;
 begin
-  for Idx := System.Low(AInputs) to System.High(AInputs) do
+  for LIdx := System.Low(AInputs) to System.High(AInputs) do
   begin
-    ClearArray(AInputs[Idx]);
+    ClearArray(AInputs[LIdx]);
   end;
 end;
 
-class function TPBKDF_ScryptNotBuildInAdapter.IsPowerOf2(x: Int32): Boolean;
+class function TPBKDF_ScryptNotBuildInAdapter.IsPowerOf2(Ax: Int32): Boolean;
 begin
-  result := (x > 0) and ((x and (x - 1)) = 0);
+  result := (Ax > 0) and ((Ax and (Ax - 1)) = 0);
 end;
 
 class function TPBKDF_ScryptNotBuildInAdapter.SingleIterationPBKDF2
@@ -171,205 +161,212 @@ begin
     APasswordBytes, ASaltBytes, 1) as IPBKDF2_HMAC).GetBytes(AOutputLength);
 end;
 
-class procedure TPBKDF_ScryptNotBuildInAdapter.&Xor(const a,
-  b: THashLibUInt32Array; bOff: Int32; const output: THashLibUInt32Array);
+class procedure TPBKDF_ScryptNotBuildInAdapter.&Xor(const Aa,
+  Ab: THashLibUInt32Array; AbOff: Int32; const AOutput: THashLibUInt32Array);
 var
-  i: Int32;
+  LIdx: Int32;
 begin
-  i := System.Length(output) - 1;
-  while i >= 0 do
+  LIdx := System.Length(AOutput) - 1;
+  while LIdx >= 0 do
   begin
-    output[i] := a[i] xor b[bOff + i];
-    System.Dec(i);
+    AOutput[LIdx] := Aa[LIdx] xor Ab[AbOff + LIdx];
+    System.Dec(LIdx);
   end;
 end;
 
-class function TPBKDF_ScryptNotBuildInAdapter.R(x: UInt32; y: Int32): UInt32;
+class function TPBKDF_ScryptNotBuildInAdapter.Rotl(AValue: UInt32;
+  ADistance: Int32): UInt32;
 begin
-  result := TBits.RotateLeft32(x, y);
+  result := TBits.RotateLeft32(AValue, ADistance);
 end;
 
-class procedure TPBKDF_ScryptNotBuildInAdapter.SalsaCore(rounds: Int32;
-  const input, x: THashLibUInt32Array);
+class procedure TPBKDF_ScryptNotBuildInAdapter.SalsaCore(ARounds: Int32;
+  const AInput, Ax: THashLibUInt32Array);
 var
   x00, x01, x02, x03, x04, x05, x06, x07, x08, x09, x10, x11, x12, x13, x14,
     x15: UInt32;
-  Idx: Int32;
+  LIdx: Int32;
 begin
-  if (System.Length(input) <> 16) then
+  if (System.Length(AInput) <> 16) then
   begin
     raise EArgumentHashLibException.Create('');
   end;
-  if (System.Length(x) <> 16) then
+  if (System.Length(Ax) <> 16) then
   begin
     raise EArgumentHashLibException.Create('');
   end;
-  if ((rounds mod 2) <> 0) then
+  if ((ARounds mod 2) <> 0) then
   begin
     raise EArgumentHashLibException.CreateRes(@SRoundsMustBeEven);
   end;
 
-  x00 := input[0];
-  x01 := input[1];
-  x02 := input[2];
-  x03 := input[3];
-  x04 := input[4];
-  x05 := input[5];
-  x06 := input[6];
-  x07 := input[7];
-  x08 := input[8];
-  x09 := input[9];
-  x10 := input[10];
-  x11 := input[11];
-  x12 := input[12];
-  x13 := input[13];
-  x14 := input[14];
-  x15 := input[15];
-
-  Idx := rounds;
-  while Idx > 0 do
+  x00 := AInput[0];
+  x01 := AInput[1];
+  x02 := AInput[2];
+  x03 := AInput[3];
+  x04 := AInput[4];
+  x05 := AInput[5];
+  x06 := AInput[6];
+  x07 := AInput[7];
+  x08 := AInput[8];
+  x09 := AInput[9];
+  x10 := AInput[10];
+  x11 := AInput[11];
+  x12 := AInput[12];
+  x13 := AInput[13];
+  x14 := AInput[14];
+  x15 := AInput[15];
+
+  LIdx := ARounds;
+  while LIdx > 0 do
   begin
 
-    x04 := x04 xor (R((x00 + x12), 7));
-    x08 := x08 xor (R((x04 + x00), 9));
-    x12 := x12 xor (R((x08 + x04), 13));
-    x00 := x00 xor (R((x12 + x08), 18));
-    x09 := x09 xor (R((x05 + x01), 7));
-    x13 := x13 xor (R((x09 + x05), 9));
-    x01 := x01 xor (R((x13 + x09), 13));
-    x05 := x05 xor (R((x01 + x13), 18));
-    x14 := x14 xor (R((x10 + x06), 7));
-    x02 := x02 xor (R((x14 + x10), 9));
-    x06 := x06 xor (R((x02 + x14), 13));
-    x10 := x10 xor (R((x06 + x02), 18));
-    x03 := x03 xor (R((x15 + x11), 7));
-    x07 := x07 xor (R((x03 + x15), 9));
-    x11 := x11 xor (R((x07 + x03), 13));
-    x15 := x15 xor (R((x11 + x07), 18));
-
-    x01 := x01 xor (R((x00 + x03), 7));
-    x02 := x02 xor (R((x01 + x00), 9));
-    x03 := x03 xor (R((x02 + x01), 13));
-    x00 := x00 xor (R((x03 + x02), 18));
-    x06 := x06 xor (R((x05 + x04), 7));
-    x07 := x07 xor (R((x06 + x05), 9));
-    x04 := x04 xor (R((x07 + x06), 13));
-    x05 := x05 xor (R((x04 + x07), 18));
-    x11 := x11 xor (R((x10 + x09), 7));
-    x08 := x08 xor (R((x11 + x10), 9));
-    x09 := x09 xor (R((x08 + x11), 13));
-    x10 := x10 xor (R((x09 + x08), 18));
-    x12 := x12 xor (R((x15 + x14), 7));
-    x13 := x13 xor (R((x12 + x15), 9));
-    x14 := x14 xor (R((x13 + x12), 13));
-    x15 := x15 xor (R((x14 + x13), 18));
-
-    System.Dec(Idx, 2);
+    x04 := x04 xor (Rotl((x00 + x12), 7));
+    x08 := x08 xor (Rotl((x04 + x00), 9));
+    x12 := x12 xor (Rotl((x08 + x04), 13));
+    x00 := x00 xor (Rotl((x12 + x08), 18));
+    x09 := x09 xor (Rotl((x05 + x01), 7));
+    x13 := x13 xor (Rotl((x09 + x05), 9));
+    x01 := x01 xor (Rotl((x13 + x09), 13));
+    x05 := x05 xor (Rotl((x01 + x13), 18));
+    x14 := x14 xor (Rotl((x10 + x06), 7));
+    x02 := x02 xor (Rotl((x14 + x10), 9));
+    x06 := x06 xor (Rotl((x02 + x14), 13));
+    x10 := x10 xor (Rotl((x06 + x02), 18));
+    x03 := x03 xor (Rotl((x15 + x11), 7));
+    x07 := x07 xor (Rotl((x03 + x15), 9));
+    x11 := x11 xor (Rotl((x07 + x03), 13));
+    x15 := x15 xor (Rotl((x11 + x07), 18));
+
+    x01 := x01 xor (Rotl((x00 + x03), 7));
+    x02 := x02 xor (Rotl((x01 + x00), 9));
+    x03 := x03 xor (Rotl((x02 + x01), 13));
+    x00 := x00 xor (Rotl((x03 + x02), 18));
+    x06 := x06 xor (Rotl((x05 + x04), 7));
+    x07 := x07 xor (Rotl((x06 + x05), 9));
+    x04 := x04 xor (Rotl((x07 + x06), 13));
+    x05 := x05 xor (Rotl((x04 + x07), 18));
+    x11 := x11 xor (Rotl((x10 + x09), 7));
+    x08 := x08 xor (Rotl((x11 + x10), 9));
+    x09 := x09 xor (Rotl((x08 + x11), 13));
+    x10 := x10 xor (Rotl((x09 + x08), 18));
+    x12 := x12 xor (Rotl((x15 + x14), 7));
+    x13 := x13 xor (Rotl((x12 + x15), 9));
+    x14 := x14 xor (Rotl((x13 + x12), 13));
+    x15 := x15 xor (Rotl((x14 + x13), 18));
+
+    System.Dec(LIdx, 2);
   end;
 
-  x[0] := x00 + input[0];
-  x[1] := x01 + input[1];
-  x[2] := x02 + input[2];
-  x[3] := x03 + input[3];
-  x[4] := x04 + input[4];
-  x[5] := x05 + input[5];
-  x[6] := x06 + input[6];
-  x[7] := x07 + input[7];
-  x[8] := x08 + input[8];
-  x[9] := x09 + input[9];
-  x[10] := x10 + input[10];
-  x[11] := x11 + input[11];
-  x[12] := x12 + input[12];
-  x[13] := x13 + input[13];
-  x[14] := x14 + input[14];
-  x[15] := x15 + input[15];
+  Ax[0] := x00 + AInput[0];
+  Ax[1] := x01 + AInput[1];
+  Ax[2] := x02 + AInput[2];
+  Ax[3] := x03 + AInput[3];
+  Ax[4] := x04 + AInput[4];
+  Ax[5] := x05 + AInput[5];
+  Ax[6] := x06 + AInput[6];
+  Ax[7] := x07 + AInput[7];
+  Ax[8] := x08 + AInput[8];
+  Ax[9] := x09 + AInput[9];
+  Ax[10] := x10 + AInput[10];
+  Ax[11] := x11 + AInput[11];
+  Ax[12] := x12 + AInput[12];
+  Ax[13] := x13 + AInput[13];
+  Ax[14] := x14 + AInput[14];
+  Ax[15] := x15 + AInput[15];
 
 end;
 
-class procedure TPBKDF_ScryptNotBuildInAdapter.BlockMix(const b, X1, X2,
-  y: THashLibUInt32Array; R: Int32);
+class procedure TPBKDF_ScryptNotBuildInAdapter.BlockMix(const Ab, AX1, AX2,
+  Ay: THashLibUInt32Array; AR: Int32);
 var
-  bOff, YOff, halfLen, i: Int32;
+  LbOff, LYOff, LHalfLen, LIdx: Int32;
 begin
-  System.Move(b[System.Length(b) - 16], X1[0], 16 * System.SizeOf(UInt32));
+  System.Move(Ab[System.Length(Ab) - 16], AX1[0], 16 * System.SizeOf(UInt32));
 
-  bOff := 0;
-  YOff := 0;
-  halfLen := System.Length(b) div 2;
+  LbOff := 0;
+  LYOff := 0;
+  LHalfLen := System.Length(Ab) div 2;
 
-  i := 2 * R;
+  LIdx := 2 * AR;
 
-  while i > 0 do
+  while LIdx > 0 do
   begin
-    &Xor(X1, b, bOff, X2);
+    &Xor(AX1, Ab, LbOff, AX2);
 
-    SalsaCore(8, X2, X1);
-    System.Move(X1[0], y[YOff], 16 * System.SizeOf(UInt32));
+    SalsaCore(8, AX2, AX1);
+    System.Move(AX1[0], Ay[LYOff], 16 * System.SizeOf(UInt32));
 
-    YOff := halfLen + bOff - YOff;
-    bOff := bOff + 16;
-    System.Dec(i);
+    LYOff := LHalfLen + LbOff - LYOff;
+    LbOff := LbOff + 16;
+    System.Dec(LIdx);
   end;
-
-  System.Move(y[0], b[0], System.Length(y) * System.SizeOf(UInt32));
 end;
 
 class procedure TPBKDF_ScryptNotBuildInAdapter.SMix
-  (const b: THashLibUInt32Array; bOff, N, R: Int32);
+  (const Ab: THashLibUInt32Array; AbOff, AN, AR: Int32);
 var
-  BCount, i: Int32;
-  mask, j: UInt32;
-  blockX1, blockX2, blockY, x: THashLibUInt32Array;
-  V: THashLibMatrixUInt32Array;
+  LBCount, LIdx, LJdx, LOffset: Int32;
+  LMask: UInt32;
+  LBlockX1, LBlockX2, LBlockY, LX, LV: THashLibUInt32Array;
 begin
-  BCount := R * 32;
-  System.SetLength(blockX1, 16);
-  System.SetLength(blockX2, 16);
-  System.SetLength(blockY, BCount);
+  LBCount := AR * 32;
+  System.SetLength(LBlockX1, 16);
+  System.SetLength(LBlockX2, 16);
+  System.SetLength(LBlockY, LBCount);
 
-  System.SetLength(x, BCount);
+  System.SetLength(LX, LBCount);
 
-  System.SetLength(V, N);
+  System.SetLength(LV, AN * LBCount);
 
   try
-    System.Move(b[bOff], x[0], BCount * System.SizeOf(UInt32));
+    System.Move(Ab[AbOff], LX[0], LBCount * System.SizeOf(UInt32));
 
-    for i := 0 to System.Pred(N) do
+    LOffset := 0;
+    LIdx := 0;
+    while LIdx < AN do
     begin
-      V[i] := System.Copy(x);
-      BlockMix(x, blockX1, blockX2, blockY, R);
+      System.Move(LX[0], LV[LOffset], LBCount * System.SizeOf(UInt32));
+      LOffset := LOffset + LBCount;
+      BlockMix(LX, LBlockX1, LBlockX2, LBlockY, AR);
+      System.Move(LBlockY[0], LV[LOffset], LBCount * System.SizeOf(UInt32));
+      LOffset := LOffset + LBCount;
+      BlockMix(LBlockY, LBlockX1, LBlockX2, LX, AR);
+      System.Inc(LIdx, 2);
     end;
 
-    mask := UInt32(N) - 1;
+    LMask := UInt32(AN) - 1;
 
-    i := 0;
-    while i < N do
+    LIdx := 0;
+    while LIdx < AN do
     begin
-      j := x[BCount - 16] and mask;
-      &Xor(x, V[j], 0, x);
-      BlockMix(x, blockX1, blockX2, blockY, R);
-      System.Inc(i);
+      LJdx := LX[LBCount - 16] and LMask;
+      System.Move(LV[LJdx * LBCount], LBlockY[0],
+        LBCount * System.SizeOf(UInt32));
+      &Xor(LBlockY, LX, 0, LBlockY);
+      BlockMix(LBlockY, LBlockX1, LBlockX2, LX, AR);
+      System.Inc(LIdx);
     end;
 
-    System.Move(x[0], b[bOff], BCount * System.SizeOf(UInt32));
+    System.Move(LX[0], Ab[AbOff], LBCount * System.SizeOf(UInt32));
   finally
-    ClearAllArrays(V);
-    ClearAllArrays(THashLibMatrixUInt32Array.Create(x, blockX1,
-      blockX2, blockY));
+    ClearArray(LV);
+    ClearAllArrays(THashLibMatrixUInt32Array.Create(LX, LBlockX1, LBlockX2,
+      LBlockY));
   end;
 end;
 
-{$IFDEF DELPHIXE7_UP}
+{$IFDEF HAS_DELPHI_PPL}
 
-class procedure TPBKDF_ScryptNotBuildInAdapter.DoParallelSMix
-  (const b: THashLibUInt32Array; AParallelism, ACost, ABlockSize: Int32);
+class procedure TPBKDF_ScryptNotBuildInAdapter.DoSMix
+  (const Ab: THashLibUInt32Array; AParallelism, ACost, ABlockSize: Int32);
 
   function CreateTask(AOffset: Int32): ITask;
   begin
     result := TTask.Create(
       procedure()
       begin
-        SMix(b, AOffset, ACost, ABlockSize);
+        SMix(Ab, AOffset, ACost, ABlockSize);
       end);
   end;
 
@@ -391,48 +388,47 @@ end;
 
 {$ELSE}
 
-class procedure TPBKDF_ScryptNotBuildInAdapter.DoParallelSMix
-  (const b: THashLibUInt32Array; AParallelism, ACost, ABlockSize: Int32);
+class procedure TPBKDF_ScryptNotBuildInAdapter.DoSMix
+  (const Ab: THashLibUInt32Array; AParallelism, ACost, ABlockSize: Int32);
 var
-  i: Int32;
+  LIdx: Int32;
 begin
-
-  for i := 0 to System.Pred(AParallelism) do
+  for LIdx := 0 to System.Pred(AParallelism) do
   begin
-    SMix(b, i * 32 * ABlockSize, ACost, ABlockSize);
+    SMix(Ab, LIdx * 32 * ABlockSize, ACost, ABlockSize);
   end;
 end;
 
-{$ENDIF}
+{$ENDIF HAS_DELPHI_PPL}
 
-class function TPBKDF_ScryptNotBuildInAdapter.MFcrypt(const APasswordBytes,
+class function TPBKDF_ScryptNotBuildInAdapter.MFCrypt(const APasswordBytes,
   ASaltBytes: THashLibByteArray; ACost, ABlockSize, AParallelism,
   AOutputLength: Int32): THashLibByteArray;
 var
-  MFLenBytes, BLen: Int32;
-  bytes: THashLibByteArray;
-  b: THashLibUInt32Array;
+  LMFLenBytes, LBLen: Int32;
+  LBytes: THashLibByteArray;
+  Lb: THashLibUInt32Array;
 begin
-  MFLenBytes := ABlockSize * 128;
-  bytes := SingleIterationPBKDF2(APasswordBytes, ASaltBytes,
-    AParallelism * MFLenBytes);
+  LMFLenBytes := ABlockSize * 128;
+  LBytes := SingleIterationPBKDF2(APasswordBytes, ASaltBytes,
+    AParallelism * LMFLenBytes);
 
   try
-    BLen := System.Length(bytes) div 4;
-    System.SetLength(b, BLen);
+    LBLen := System.Length(LBytes) div 4;
+    System.SetLength(Lb, LBLen);
 
-    TConverters.le32_copy(PByte(bytes), 0, PCardinal(b), 0,
-      System.Length(bytes) * System.SizeOf(Byte));
+    TConverters.le32_copy(PByte(LBytes), 0, PCardinal(Lb), 0,
+      System.Length(LBytes) * System.SizeOf(Byte));
 
-    DoParallelSMix(b, AParallelism, ACost, ABlockSize);
+    DoSMix(Lb, AParallelism, ACost, ABlockSize);
 
-    TConverters.le32_copy(PCardinal(b), 0, PByte(bytes), 0,
-      System.Length(b) * System.SizeOf(UInt32));
+    TConverters.le32_copy(PCardinal(Lb), 0, PByte(LBytes), 0,
+      System.Length(Lb) * System.SizeOf(UInt32));
 
-    result := SingleIterationPBKDF2(APasswordBytes, bytes, AOutputLength);
+    result := SingleIterationPBKDF2(APasswordBytes, LBytes, AOutputLength);
   finally
-    ClearArray(b);
-    ClearArray(bytes);
+    ClearArray(Lb);
+    ClearArray(LBytes);
   end;
 
 end;
@@ -440,24 +436,32 @@ end;
 class procedure TPBKDF_ScryptNotBuildInAdapter.ValidatePBKDF_ScryptInputs(ACost,
   ABlockSize, AParallelism: Int32);
 var
-  maxParallel: Int32;
+  LMaxParallel: Int32;
 begin
 
   if ((ACost <= 1) or (not IsPowerOf2(ACost))) then
+  begin
     raise EArgumentHashLibException.CreateRes(@SInvalidCost);
+  end;
 
   // Only value of ABlockSize that cost (as an int) could be exceeded for is 1
   if ((ABlockSize = 1) and (ACost >= 65536)) then
+  begin
     raise EArgumentHashLibException.CreateRes(@SBlockSizeAndCostIncompatible);
+  end;
 
   if (ABlockSize < 1) then
+  begin
     raise EArgumentHashLibException.CreateRes(@SBlockSizeTooSmall);
+  end;
 
-  maxParallel := System.High(Int32) div (128 * ABlockSize * 8);
+  LMaxParallel := System.High(Int32) div (128 * ABlockSize * 8);
 
-  if ((AParallelism < 1) or (AParallelism > maxParallel)) then
+  if ((AParallelism < 1) or (AParallelism > LMaxParallel)) then
+  begin
     raise EArgumentHashLibException.CreateResFmt(@SInvalidParallelism,
-      [maxParallel, ABlockSize]);
+      [LMaxParallel, ABlockSize]);
+  end;
 end;
 
 procedure TPBKDF_ScryptNotBuildInAdapter.Clear();
@@ -484,13 +488,16 @@ begin
   inherited Destroy;
 end;
 
-function TPBKDF_ScryptNotBuildInAdapter.GetBytes(bc: Int32): THashLibByteArray;
+function TPBKDF_ScryptNotBuildInAdapter.GetBytes(AByteCount: Int32)
+  : THashLibByteArray;
 begin
-  if (bc <= 0) then
+  if (AByteCount <= 0) then
+  begin
     raise EArgumentHashLibException.CreateRes(@SInvalidByteCount);
+  end;
 
-  result := MFcrypt(FPasswordBytes, FSaltBytes, FCost, FBlockSize,
-    FParallelism, bc);
+  result := MFCrypt(FPasswordBytes, FSaltBytes, FCost, FBlockSize, FParallelism,
+    AByteCount);
 end;
 
 end.

+ 27 - 26
src/libraries/hashlib4pascal/HlpPJW.pas

@@ -15,8 +15,8 @@ uses
 type
   TPJW = class sealed(THash, IHash32, ITransformBlock)
   strict private
-
-    Fm_hash: UInt32;
+  var
+    FHash: UInt32;
 
   const
     UInt32MaxValue = UInt32(4294967295);
@@ -28,8 +28,8 @@ type
   public
     constructor Create();
     procedure Initialize(); override;
-    procedure TransformBytes(const a_data: THashLibByteArray;
-      a_index, a_length: Int32); override;
+    procedure TransformBytes(const AData: THashLibByteArray;
+      AIndex, ALength: Int32); override;
     function TransformFinal(): IHashResult; override;
     function Clone(): IHash; override;
   end;
@@ -40,11 +40,11 @@ implementation
 
 function TPJW.Clone(): IHash;
 var
-  HashInstance: TPJW;
+  LHashInstance: TPJW;
 begin
-  HashInstance := TPJW.Create();
-  HashInstance.Fm_hash := Fm_hash;
-  result := HashInstance as IHash;
+  LHashInstance := TPJW.Create();
+  LHashInstance.FHash := FHash;
+  result := LHashInstance as IHash;
   result.BufferSize := BufferSize;
 end;
 
@@ -55,36 +55,37 @@ end;
 
 procedure TPJW.Initialize;
 begin
-  Fm_hash := 0;
+  FHash := 0;
 end;
 
-procedure TPJW.TransformBytes(const a_data: THashLibByteArray;
-  a_index, a_length: Int32);
+procedure TPJW.TransformBytes(const AData: THashLibByteArray;
+  AIndex, ALength: Int32);
 var
-  i: Int32;
-  test: UInt32;
+  LIdx: Int32;
+  LTest: UInt32;
 begin
 {$IFDEF DEBUG}
-  System.Assert(a_index >= 0);
-  System.Assert(a_length >= 0);
-  System.Assert(a_index + a_length <= System.Length(a_data));
+  System.Assert(AIndex >= 0);
+  System.Assert(ALength >= 0);
+  System.Assert(AIndex + ALength <= System.Length(AData));
 {$ENDIF DEBUG}
-  i := a_index;
-  while a_length > 0 do
+  LIdx := AIndex;
+  while ALength > 0 do
   begin
-    Fm_hash := (Fm_hash shl OneEighth) + a_data[i];
-    test := Fm_hash and HighBits;
-    if (test <> 0) then
-      Fm_hash := ((Fm_hash xor (test shr ThreeQuarters)) and (not HighBits));
-    System.Inc(i);
-    System.Dec(a_length);
+    FHash := (FHash shl OneEighth) + AData[LIdx];
+    LTest := FHash and HighBits;
+    if (LTest <> 0) then
+    begin
+      FHash := ((FHash xor (LTest shr ThreeQuarters)) and (not HighBits));
+    end;
+    System.Inc(LIdx);
+    System.Dec(ALength);
   end;
-
 end;
 
 function TPJW.TransformFinal: IHashResult;
 begin
-  result := THashResult.Create(Fm_hash);
+  result := THashResult.Create(FHash);
   Initialize();
 end;
 

+ 198 - 212
src/libraries/hashlib4pascal/HlpPanama.pas

@@ -22,21 +22,19 @@ type
   TPanama = class sealed(TBlockHash, ICryptoNotBuildIn, ITransformBlock)
 
   strict private
+  var
+    FState, FTheta, FGamma, FPi: THashLibUInt32Array;
+    FStages: THashLibMatrixUInt32Array;
+    FTap: Int32;
 
-    Fm_state, Ftheta, Fgamma, Fpi: THashLibUInt32Array;
-
-    Fm_stages: THashLibMatrixUInt32Array;
-
-    Fm_tap: Int32;
-
-    procedure GPT(a_theta: PCardinal);
+    procedure GPT(APtrTheta: PCardinal);
 
   const
 
   strict protected
     procedure Finish(); override;
-    procedure TransformBlock(a_data: PByte; a_data_length: Int32;
-      a_index: Int32); override;
+    procedure TransformBlock(AData: PByte; ADataLength: Int32;
+      AIndex: Int32); override;
     function GetResult(): THashLibByteArray; override;
 
   public
@@ -52,262 +50,250 @@ implementation
 
 function TPanama.Clone(): IHash;
 var
-  HashInstance: TPanama;
-  Idx: Int32;
+  LHashInstance: TPanama;
+  LIdx: Int32;
 begin
-  HashInstance := TPanama.Create();
-  HashInstance.Fm_state := System.Copy(Fm_state);
-  HashInstance.Ftheta := System.Copy(Ftheta);
-  HashInstance.Fgamma := System.Copy(Fgamma);
-  HashInstance.Fpi := System.Copy(Fpi);
+  LHashInstance := TPanama.Create();
+  LHashInstance.FState := System.Copy(FState);
+  LHashInstance.FTheta := System.Copy(FTheta);
+  LHashInstance.FGamma := System.Copy(FGamma);
+  LHashInstance.FPi := System.Copy(FPi);
   // since System.Copy() does not support jagged arrays (multidimensional dynamic arrays, we improvise)
-  for Idx := System.Low(Fm_stages) to System.High(Fm_stages) do
+  for LIdx := System.Low(FStages) to System.High(FStages) do
   begin
-    HashInstance.Fm_stages[Idx] := System.Copy(Fm_stages[Idx]);
+    LHashInstance.FStages[LIdx] := System.Copy(FStages[LIdx]);
   end;
-  HashInstance.Fm_tap := Fm_tap;
-  HashInstance.Fm_buffer := Fm_buffer.Clone();
-  HashInstance.Fm_processed_bytes := Fm_processed_bytes;
-  result := HashInstance as IHash;
+  LHashInstance.FTap := FTap;
+  LHashInstance.FBuffer := FBuffer.Clone();
+  LHashInstance.FProcessedBytesCount := FProcessedBytesCount;
+  result := LHashInstance as IHash;
   result.BufferSize := BufferSize;
 end;
 
 constructor TPanama.Create;
 var
-  i: Int32;
+  LIdx: Int32;
 begin
   Inherited Create(32, 32);
-  System.SetLength(Fm_state, 17);
+  System.SetLength(FState, 17);
 
-  System.SetLength(Fm_stages, 32);
-  i := 0;
-  while i <= System.High(Fm_stages) do
+  System.SetLength(FStages, 32);
+  LIdx := 0;
+  while LIdx <= System.High(FStages) do
   begin
-    System.SetLength(Fm_stages[i], 8);
-    System.Inc(i);
+    System.SetLength(FStages[LIdx], 8);
+    System.Inc(LIdx);
   end;
 
-  System.SetLength(Ftheta, 17);
-
-  System.SetLength(Fgamma, 17);
+  System.SetLength(FTheta, 17);
 
-  System.SetLength(Fpi, 17);
+  System.SetLength(FGamma, 17);
 
+  System.SetLength(FPi, 17);
 end;
 
 procedure TPanama.Finish;
 var
-  padding_size, i, tap4, tap16, tap25: Int32;
-  pad: THashLibByteArray;
-  theta: THashLibUInt32Array;
-  ptr_theta: PCardinal;
+  LPaddingSize, LIdx, LTap4, LTap16, LTap25: Int32;
+  LPad: THashLibByteArray;
+  LTheta: THashLibUInt32Array;
+  LPtrTheta: PCardinal;
 begin
+  LPaddingSize := 32 - ((Int32(FProcessedBytesCount)) and 31);
 
-  padding_size := 32 - ((Int32(Fm_processed_bytes)) and 31);
+  System.SetLength(LPad, LPaddingSize);
 
-  System.SetLength(pad, padding_size);
+  LPad[0] := $01;
+  TransformBytes(LPad, 0, LPaddingSize);
 
-  pad[0] := $01;
-  TransformBytes(pad, 0, padding_size);
+  System.SetLength(LTheta, 17);
 
-  System.SetLength(theta, 17);
+  LPtrTheta := PCardinal(LTheta);
 
-  ptr_theta := PCardinal(theta);
-
-  i := 0;
-  while i < 32 do
+  LIdx := 0;
+  while LIdx < 32 do
   begin
-    tap4 := (Fm_tap + 4) and $1F;
-    tap16 := (Fm_tap + 16) and $1F;
-
-    Fm_tap := (Fm_tap - 1) and $1F;
-    tap25 := (Fm_tap + 25) and $1F;
-
-    GPT(ptr_theta);
-
-    Fm_stages[tap25, 0] := Fm_stages[tap25, 0] xor Fm_stages[Fm_tap, 2];
-    Fm_stages[tap25, 1] := Fm_stages[tap25, 1] xor Fm_stages[Fm_tap, 3];
-    Fm_stages[tap25, 2] := Fm_stages[tap25, 2] xor Fm_stages[Fm_tap, 4];
-    Fm_stages[tap25, 3] := Fm_stages[tap25, 3] xor Fm_stages[Fm_tap, 5];
-    Fm_stages[tap25, 4] := Fm_stages[tap25, 4] xor Fm_stages[Fm_tap, 6];
-    Fm_stages[tap25, 5] := Fm_stages[tap25, 5] xor Fm_stages[Fm_tap, 7];
-    Fm_stages[tap25, 6] := Fm_stages[tap25, 6] xor Fm_stages[Fm_tap, 0];
-    Fm_stages[tap25, 7] := Fm_stages[tap25, 7] xor Fm_stages[Fm_tap, 1];
-    Fm_stages[Fm_tap, 0] := Fm_stages[Fm_tap, 0] xor Fm_state[1];
-    Fm_stages[Fm_tap, 1] := Fm_stages[Fm_tap, 1] xor Fm_state[2];
-    Fm_stages[Fm_tap, 2] := Fm_stages[Fm_tap, 2] xor Fm_state[3];
-    Fm_stages[Fm_tap, 3] := Fm_stages[Fm_tap, 3] xor Fm_state[4];
-    Fm_stages[Fm_tap, 4] := Fm_stages[Fm_tap, 4] xor Fm_state[5];
-    Fm_stages[Fm_tap, 5] := Fm_stages[Fm_tap, 5] xor Fm_state[6];
-    Fm_stages[Fm_tap, 6] := Fm_stages[Fm_tap, 6] xor Fm_state[7];
-    Fm_stages[Fm_tap, 7] := Fm_stages[Fm_tap, 7] xor Fm_state[8];
-
-    Fm_state[0] := theta[0] xor $01;
-    Fm_state[1] := theta[1] xor Fm_stages[tap4, 0];
-    Fm_state[2] := theta[2] xor Fm_stages[tap4, 1];
-    Fm_state[3] := theta[3] xor Fm_stages[tap4, 2];
-    Fm_state[4] := theta[4] xor Fm_stages[tap4, 3];
-    Fm_state[5] := theta[5] xor Fm_stages[tap4, 4];
-    Fm_state[6] := theta[6] xor Fm_stages[tap4, 5];
-    Fm_state[7] := theta[7] xor Fm_stages[tap4, 6];
-    Fm_state[8] := theta[8] xor Fm_stages[tap4, 7];
-    Fm_state[9] := theta[9] xor Fm_stages[tap16, 0];
-    Fm_state[10] := theta[10] xor Fm_stages[tap16, 1];
-    Fm_state[11] := theta[11] xor Fm_stages[tap16, 2];
-    Fm_state[12] := theta[12] xor Fm_stages[tap16, 3];
-    Fm_state[13] := theta[13] xor Fm_stages[tap16, 4];
-    Fm_state[14] := theta[14] xor Fm_stages[tap16, 5];
-    Fm_state[15] := theta[15] xor Fm_stages[tap16, 6];
-    Fm_state[16] := theta[16] xor Fm_stages[tap16, 7];
-
-    System.Inc(i);
+    LTap4 := (FTap + 4) and $1F;
+    LTap16 := (FTap + 16) and $1F;
+
+    FTap := (FTap - 1) and $1F;
+    LTap25 := (FTap + 25) and $1F;
+
+    GPT(LPtrTheta);
+
+    FStages[LTap25, 0] := FStages[LTap25, 0] xor FStages[FTap, 2];
+    FStages[LTap25, 1] := FStages[LTap25, 1] xor FStages[FTap, 3];
+    FStages[LTap25, 2] := FStages[LTap25, 2] xor FStages[FTap, 4];
+    FStages[LTap25, 3] := FStages[LTap25, 3] xor FStages[FTap, 5];
+    FStages[LTap25, 4] := FStages[LTap25, 4] xor FStages[FTap, 6];
+    FStages[LTap25, 5] := FStages[LTap25, 5] xor FStages[FTap, 7];
+    FStages[LTap25, 6] := FStages[LTap25, 6] xor FStages[FTap, 0];
+    FStages[LTap25, 7] := FStages[LTap25, 7] xor FStages[FTap, 1];
+    FStages[FTap, 0] := FStages[FTap, 0] xor FState[1];
+    FStages[FTap, 1] := FStages[FTap, 1] xor FState[2];
+    FStages[FTap, 2] := FStages[FTap, 2] xor FState[3];
+    FStages[FTap, 3] := FStages[FTap, 3] xor FState[4];
+    FStages[FTap, 4] := FStages[FTap, 4] xor FState[5];
+    FStages[FTap, 5] := FStages[FTap, 5] xor FState[6];
+    FStages[FTap, 6] := FStages[FTap, 6] xor FState[7];
+    FStages[FTap, 7] := FStages[FTap, 7] xor FState[8];
+
+    FState[0] := LTheta[0] xor $01;
+    FState[1] := LTheta[1] xor FStages[LTap4, 0];
+    FState[2] := LTheta[2] xor FStages[LTap4, 1];
+    FState[3] := LTheta[3] xor FStages[LTap4, 2];
+    FState[4] := LTheta[4] xor FStages[LTap4, 3];
+    FState[5] := LTheta[5] xor FStages[LTap4, 4];
+    FState[6] := LTheta[6] xor FStages[LTap4, 5];
+    FState[7] := LTheta[7] xor FStages[LTap4, 6];
+    FState[8] := LTheta[8] xor FStages[LTap4, 7];
+    FState[9] := LTheta[9] xor FStages[LTap16, 0];
+    FState[10] := LTheta[10] xor FStages[LTap16, 1];
+    FState[11] := LTheta[11] xor FStages[LTap16, 2];
+    FState[12] := LTheta[12] xor FStages[LTap16, 3];
+    FState[13] := LTheta[13] xor FStages[LTap16, 4];
+    FState[14] := LTheta[14] xor FStages[LTap16, 5];
+    FState[15] := LTheta[15] xor FStages[LTap16, 6];
+    FState[16] := LTheta[16] xor FStages[LTap16, 7];
+
+    System.Inc(LIdx);
   end;
-
 end;
 
 function TPanama.GetResult: THashLibByteArray;
 begin
-
   System.SetLength(result, 8 * System.SizeOf(UInt32));
-
-  TConverters.le32_copy(PCardinal(Fm_state), 9 * System.SizeOf(UInt32),
+  TConverters.le32_copy(PCardinal(FState), 9 * System.SizeOf(UInt32),
     PByte(result), 0, System.Length(result));
-
 end;
 
-procedure TPanama.GPT(a_theta: PCardinal);
+procedure TPanama.GPT(APtrTheta: PCardinal);
 begin
-
-  Fgamma[0] := Fm_state[0] xor (Fm_state[1] or not Fm_state[2]);
-  Fgamma[1] := Fm_state[1] xor (Fm_state[2] or not Fm_state[3]);
-  Fgamma[2] := Fm_state[2] xor (Fm_state[3] or not Fm_state[4]);
-  Fgamma[3] := Fm_state[3] xor (Fm_state[4] or not Fm_state[5]);
-  Fgamma[4] := Fm_state[4] xor (Fm_state[5] or not Fm_state[6]);
-  Fgamma[5] := Fm_state[5] xor (Fm_state[6] or not Fm_state[7]);
-  Fgamma[6] := Fm_state[6] xor (Fm_state[7] or not Fm_state[8]);
-  Fgamma[7] := Fm_state[7] xor (Fm_state[8] or not Fm_state[9]);
-  Fgamma[8] := Fm_state[8] xor (Fm_state[9] or not Fm_state[10]);
-  Fgamma[9] := Fm_state[9] xor (Fm_state[10] or not Fm_state[11]);
-  Fgamma[10] := Fm_state[10] xor (Fm_state[11] or not Fm_state[12]);
-  Fgamma[11] := Fm_state[11] xor (Fm_state[12] or not Fm_state[13]);
-  Fgamma[12] := Fm_state[12] xor (Fm_state[13] or not Fm_state[14]);
-  Fgamma[13] := Fm_state[13] xor (Fm_state[14] or not Fm_state[15]);
-  Fgamma[14] := Fm_state[14] xor (Fm_state[15] or not Fm_state[16]);
-  Fgamma[15] := Fm_state[15] xor (Fm_state[16] or not Fm_state[0]);
-  Fgamma[16] := Fm_state[16] xor (Fm_state[0] or not Fm_state[1]);
-
-  Fpi[0] := Fgamma[0];
-  Fpi[1] := TBits.RotateLeft32(Fgamma[7], 1);
-  Fpi[2] := TBits.RotateLeft32(Fgamma[14], 3);
-  Fpi[3] := TBits.RotateLeft32(Fgamma[4], 6);
-  Fpi[4] := TBits.RotateLeft32(Fgamma[11], 10);
-  Fpi[5] := TBits.RotateLeft32(Fgamma[1], 15);
-  Fpi[6] := TBits.RotateLeft32(Fgamma[8], 21);
-  Fpi[7] := TBits.RotateLeft32(Fgamma[15], 28);
-  Fpi[8] := TBits.RotateLeft32(Fgamma[5], 4);
-  Fpi[9] := TBits.RotateLeft32(Fgamma[12], 13);
-  Fpi[10] := TBits.RotateLeft32(Fgamma[2], 23);
-  Fpi[11] := TBits.RotateLeft32(Fgamma[9], 2);
-  Fpi[12] := TBits.RotateLeft32(Fgamma[16], 14);
-  Fpi[13] := TBits.RotateLeft32(Fgamma[6], 27);
-  Fpi[14] := TBits.RotateLeft32(Fgamma[13], 9);
-  Fpi[15] := TBits.RotateLeft32(Fgamma[3], 24);
-  Fpi[16] := TBits.RotateLeft32(Fgamma[10], 8);
-
-  a_theta[0] := Fpi[0] xor Fpi[1] xor Fpi[4];
-  a_theta[1] := Fpi[1] xor Fpi[2] xor Fpi[5];
-  a_theta[2] := Fpi[2] xor Fpi[3] xor Fpi[6];
-  a_theta[3] := Fpi[3] xor Fpi[4] xor Fpi[7];
-  a_theta[4] := Fpi[4] xor Fpi[5] xor Fpi[8];
-  a_theta[5] := Fpi[5] xor Fpi[6] xor Fpi[9];
-  a_theta[6] := Fpi[6] xor Fpi[7] xor Fpi[10];
-  a_theta[7] := Fpi[7] xor Fpi[8] xor Fpi[11];
-  a_theta[8] := Fpi[8] xor Fpi[9] xor Fpi[12];
-  a_theta[9] := Fpi[9] xor Fpi[10] xor Fpi[13];
-  a_theta[10] := Fpi[10] xor Fpi[11] xor Fpi[14];
-  a_theta[11] := Fpi[11] xor Fpi[12] xor Fpi[15];
-  a_theta[12] := Fpi[12] xor Fpi[13] xor Fpi[16];
-  a_theta[13] := Fpi[13] xor Fpi[14] xor Fpi[0];
-  a_theta[14] := Fpi[14] xor Fpi[15] xor Fpi[1];
-  a_theta[15] := Fpi[15] xor Fpi[16] xor Fpi[2];
-  a_theta[16] := Fpi[16] xor Fpi[0] xor Fpi[3];
-
+  FGamma[0] := FState[0] xor (FState[1] or not FState[2]);
+  FGamma[1] := FState[1] xor (FState[2] or not FState[3]);
+  FGamma[2] := FState[2] xor (FState[3] or not FState[4]);
+  FGamma[3] := FState[3] xor (FState[4] or not FState[5]);
+  FGamma[4] := FState[4] xor (FState[5] or not FState[6]);
+  FGamma[5] := FState[5] xor (FState[6] or not FState[7]);
+  FGamma[6] := FState[6] xor (FState[7] or not FState[8]);
+  FGamma[7] := FState[7] xor (FState[8] or not FState[9]);
+  FGamma[8] := FState[8] xor (FState[9] or not FState[10]);
+  FGamma[9] := FState[9] xor (FState[10] or not FState[11]);
+  FGamma[10] := FState[10] xor (FState[11] or not FState[12]);
+  FGamma[11] := FState[11] xor (FState[12] or not FState[13]);
+  FGamma[12] := FState[12] xor (FState[13] or not FState[14]);
+  FGamma[13] := FState[13] xor (FState[14] or not FState[15]);
+  FGamma[14] := FState[14] xor (FState[15] or not FState[16]);
+  FGamma[15] := FState[15] xor (FState[16] or not FState[0]);
+  FGamma[16] := FState[16] xor (FState[0] or not FState[1]);
+
+  FPi[0] := FGamma[0];
+  FPi[1] := TBits.RotateLeft32(FGamma[7], 1);
+  FPi[2] := TBits.RotateLeft32(FGamma[14], 3);
+  FPi[3] := TBits.RotateLeft32(FGamma[4], 6);
+  FPi[4] := TBits.RotateLeft32(FGamma[11], 10);
+  FPi[5] := TBits.RotateLeft32(FGamma[1], 15);
+  FPi[6] := TBits.RotateLeft32(FGamma[8], 21);
+  FPi[7] := TBits.RotateLeft32(FGamma[15], 28);
+  FPi[8] := TBits.RotateLeft32(FGamma[5], 4);
+  FPi[9] := TBits.RotateLeft32(FGamma[12], 13);
+  FPi[10] := TBits.RotateLeft32(FGamma[2], 23);
+  FPi[11] := TBits.RotateLeft32(FGamma[9], 2);
+  FPi[12] := TBits.RotateLeft32(FGamma[16], 14);
+  FPi[13] := TBits.RotateLeft32(FGamma[6], 27);
+  FPi[14] := TBits.RotateLeft32(FGamma[13], 9);
+  FPi[15] := TBits.RotateLeft32(FGamma[3], 24);
+  FPi[16] := TBits.RotateLeft32(FGamma[10], 8);
+
+  APtrTheta[0] := FPi[0] xor FPi[1] xor FPi[4];
+  APtrTheta[1] := FPi[1] xor FPi[2] xor FPi[5];
+  APtrTheta[2] := FPi[2] xor FPi[3] xor FPi[6];
+  APtrTheta[3] := FPi[3] xor FPi[4] xor FPi[7];
+  APtrTheta[4] := FPi[4] xor FPi[5] xor FPi[8];
+  APtrTheta[5] := FPi[5] xor FPi[6] xor FPi[9];
+  APtrTheta[6] := FPi[6] xor FPi[7] xor FPi[10];
+  APtrTheta[7] := FPi[7] xor FPi[8] xor FPi[11];
+  APtrTheta[8] := FPi[8] xor FPi[9] xor FPi[12];
+  APtrTheta[9] := FPi[9] xor FPi[10] xor FPi[13];
+  APtrTheta[10] := FPi[10] xor FPi[11] xor FPi[14];
+  APtrTheta[11] := FPi[11] xor FPi[12] xor FPi[15];
+  APtrTheta[12] := FPi[12] xor FPi[13] xor FPi[16];
+  APtrTheta[13] := FPi[13] xor FPi[14] xor FPi[0];
+  APtrTheta[14] := FPi[14] xor FPi[15] xor FPi[1];
+  APtrTheta[15] := FPi[15] xor FPi[16] xor FPi[2];
+  APtrTheta[16] := FPi[16] xor FPi[0] xor FPi[3];
 end;
 
 procedure TPanama.Initialize;
 var
-  i: Int32;
+  LIdx: Int32;
 begin
+  TArrayUtils.ZeroFill(FState);
+  TArrayUtils.ZeroFill(FTheta);
+  TArrayUtils.ZeroFill(FGamma);
+  TArrayUtils.ZeroFill(FPi);
 
-  TArrayUtils.ZeroFill(Fm_state);
-  TArrayUtils.ZeroFill(Ftheta);
-  TArrayUtils.ZeroFill(Fgamma);
-  TArrayUtils.ZeroFill(Fpi);
-
-  Fm_tap := 0;
+  FTap := 0;
 
-  for i := System.Low(Fm_stages) to System.High(Fm_stages) do
+  for LIdx := System.Low(FStages) to System.High(FStages) do
   begin
-    TArrayUtils.ZeroFill(Fm_stages[i]);
+    TArrayUtils.ZeroFill(FStages[LIdx]);
   end;
 
   Inherited Initialize();
-
 end;
 
-procedure TPanama.TransformBlock(a_data: PByte; a_data_length: Int32;
-  a_index: Int32);
+procedure TPanama.TransformBlock(AData: PByte; ADataLength: Int32;
+  AIndex: Int32);
 var
-  work_buffer: array [0 .. 7] of UInt32;
-  tap16, tap25: Int32;
+  LWorkBuffer: array [0 .. 7] of UInt32;
+  LTap16, LTap25: Int32;
 begin
-
-  TConverters.le32_copy(a_data, a_index, @(work_buffer[0]), 0, a_data_length);
-
-  tap16 := (Fm_tap + 16) and $1F;
-
-  Fm_tap := (Fm_tap - 1) and $1F;
-  tap25 := (Fm_tap + 25) and $1F;
-
-  GPT(PCardinal(Ftheta));
-
-  Fm_stages[tap25, 0] := Fm_stages[tap25, 0] xor Fm_stages[Fm_tap, 2];
-  Fm_stages[tap25, 1] := Fm_stages[tap25, 1] xor Fm_stages[Fm_tap, 3];
-  Fm_stages[tap25, 2] := Fm_stages[tap25, 2] xor Fm_stages[Fm_tap, 4];
-  Fm_stages[tap25, 3] := Fm_stages[tap25, 3] xor Fm_stages[Fm_tap, 5];
-  Fm_stages[tap25, 4] := Fm_stages[tap25, 4] xor Fm_stages[Fm_tap, 6];
-  Fm_stages[tap25, 5] := Fm_stages[tap25, 5] xor Fm_stages[Fm_tap, 7];
-  Fm_stages[tap25, 6] := Fm_stages[tap25, 6] xor Fm_stages[Fm_tap, 0];
-  Fm_stages[tap25, 7] := Fm_stages[tap25, 7] xor Fm_stages[Fm_tap, 1];
-  Fm_stages[Fm_tap, 0] := Fm_stages[Fm_tap, 0] xor work_buffer[0];
-  Fm_stages[Fm_tap, 1] := Fm_stages[Fm_tap, 1] xor work_buffer[1];
-  Fm_stages[Fm_tap, 2] := Fm_stages[Fm_tap, 2] xor work_buffer[2];
-  Fm_stages[Fm_tap, 3] := Fm_stages[Fm_tap, 3] xor work_buffer[3];
-  Fm_stages[Fm_tap, 4] := Fm_stages[Fm_tap, 4] xor work_buffer[4];
-  Fm_stages[Fm_tap, 5] := Fm_stages[Fm_tap, 5] xor work_buffer[5];
-  Fm_stages[Fm_tap, 6] := Fm_stages[Fm_tap, 6] xor work_buffer[6];
-  Fm_stages[Fm_tap, 7] := Fm_stages[Fm_tap, 7] xor work_buffer[7];
-
-  Fm_state[0] := Ftheta[0] xor $01;
-  Fm_state[1] := Ftheta[1] xor work_buffer[0];
-  Fm_state[2] := Ftheta[2] xor work_buffer[1];
-  Fm_state[3] := Ftheta[3] xor work_buffer[2];
-  Fm_state[4] := Ftheta[4] xor work_buffer[3];
-  Fm_state[5] := Ftheta[5] xor work_buffer[4];
-  Fm_state[6] := Ftheta[6] xor work_buffer[5];
-  Fm_state[7] := Ftheta[7] xor work_buffer[6];
-  Fm_state[8] := Ftheta[8] xor work_buffer[7];
-  Fm_state[9] := Ftheta[9] xor Fm_stages[tap16, 0];
-  Fm_state[10] := Ftheta[10] xor Fm_stages[tap16, 1];
-  Fm_state[11] := Ftheta[11] xor Fm_stages[tap16, 2];
-  Fm_state[12] := Ftheta[12] xor Fm_stages[tap16, 3];
-  Fm_state[13] := Ftheta[13] xor Fm_stages[tap16, 4];
-  Fm_state[14] := Ftheta[14] xor Fm_stages[tap16, 5];
-  Fm_state[15] := Ftheta[15] xor Fm_stages[tap16, 6];
-  Fm_state[16] := Ftheta[16] xor Fm_stages[tap16, 7];
-
-  System.FillChar(work_buffer, System.SizeOf(work_buffer), UInt32(0));
-
+  TConverters.le32_copy(AData, AIndex, @(LWorkBuffer[0]), 0, ADataLength);
+
+  LTap16 := (FTap + 16) and $1F;
+
+  FTap := (FTap - 1) and $1F;
+  LTap25 := (FTap + 25) and $1F;
+
+  GPT(PCardinal(FTheta));
+
+  FStages[LTap25, 0] := FStages[LTap25, 0] xor FStages[FTap, 2];
+  FStages[LTap25, 1] := FStages[LTap25, 1] xor FStages[FTap, 3];
+  FStages[LTap25, 2] := FStages[LTap25, 2] xor FStages[FTap, 4];
+  FStages[LTap25, 3] := FStages[LTap25, 3] xor FStages[FTap, 5];
+  FStages[LTap25, 4] := FStages[LTap25, 4] xor FStages[FTap, 6];
+  FStages[LTap25, 5] := FStages[LTap25, 5] xor FStages[FTap, 7];
+  FStages[LTap25, 6] := FStages[LTap25, 6] xor FStages[FTap, 0];
+  FStages[LTap25, 7] := FStages[LTap25, 7] xor FStages[FTap, 1];
+  FStages[FTap, 0] := FStages[FTap, 0] xor LWorkBuffer[0];
+  FStages[FTap, 1] := FStages[FTap, 1] xor LWorkBuffer[1];
+  FStages[FTap, 2] := FStages[FTap, 2] xor LWorkBuffer[2];
+  FStages[FTap, 3] := FStages[FTap, 3] xor LWorkBuffer[3];
+  FStages[FTap, 4] := FStages[FTap, 4] xor LWorkBuffer[4];
+  FStages[FTap, 5] := FStages[FTap, 5] xor LWorkBuffer[5];
+  FStages[FTap, 6] := FStages[FTap, 6] xor LWorkBuffer[6];
+  FStages[FTap, 7] := FStages[FTap, 7] xor LWorkBuffer[7];
+
+  FState[0] := FTheta[0] xor $01;
+  FState[1] := FTheta[1] xor LWorkBuffer[0];
+  FState[2] := FTheta[2] xor LWorkBuffer[1];
+  FState[3] := FTheta[3] xor LWorkBuffer[2];
+  FState[4] := FTheta[4] xor LWorkBuffer[3];
+  FState[5] := FTheta[5] xor LWorkBuffer[4];
+  FState[6] := FTheta[6] xor LWorkBuffer[5];
+  FState[7] := FTheta[7] xor LWorkBuffer[6];
+  FState[8] := FTheta[8] xor LWorkBuffer[7];
+  FState[9] := FTheta[9] xor FStages[LTap16, 0];
+  FState[10] := FTheta[10] xor FStages[LTap16, 1];
+  FState[11] := FTheta[11] xor FStages[LTap16, 2];
+  FState[12] := FTheta[12] xor FStages[LTap16, 3];
+  FState[13] := FTheta[13] xor FStages[LTap16, 4];
+  FState[14] := FTheta[14] xor FStages[LTap16, 5];
+  FState[15] := FTheta[15] xor FStages[LTap16, 6];
+  FState[16] := FTheta[16] xor FStages[LTap16, 7];
+
+  System.FillChar(LWorkBuffer, System.SizeOf(LWorkBuffer), UInt32(0));
 end;
 
 end.

+ 125 - 127
src/libraries/hashlib4pascal/HlpRIPEMD.pas

@@ -28,8 +28,8 @@ type
     class function P3(a, b, c: UInt32): UInt32; static; inline;
 
   strict protected
-    procedure TransformBlock(a_data: PByte; a_data_length: Int32;
-      a_index: Int32); override;
+    procedure TransformBlock(AData: PByte; ADataLength: Int32;
+      AIndex: Int32); override;
 
   public
     constructor Create();
@@ -43,13 +43,13 @@ implementation
 
 function TRIPEMD.Clone(): IHash;
 var
-  HashInstance: TRIPEMD;
+  LHashInstance: TRIPEMD;
 begin
-  HashInstance := TRIPEMD.Create();
-  HashInstance.Fm_state := System.Copy(Fm_state);
-  HashInstance.Fm_buffer := Fm_buffer.Clone();
-  HashInstance.Fm_processed_bytes := Fm_processed_bytes;
-  result := HashInstance as IHash;
+  LHashInstance := TRIPEMD.Create();
+  LHashInstance.FState := System.Copy(FState);
+  LHashInstance.FBuffer := FBuffer.Clone();
+  LHashInstance.FProcessedBytesCount := FProcessedBytesCount;
+  result := LHashInstance as IHash;
   result.BufferSize := BufferSize;
 end;
 
@@ -73,134 +73,132 @@ begin
   result := a xor b xor c;
 end;
 
-procedure TRIPEMD.TransformBlock(a_data: PByte; a_data_length: Int32;
-  a_index: Int32);
+procedure TRIPEMD.TransformBlock(AData: PByte; ADataLength: Int32;
+  AIndex: Int32);
 var
   a, b, c, d, aa, bb, cc, dd: UInt32;
-  data: array [0 .. 15] of UInt32;
+  LData: array [0 .. 15] of UInt32;
 begin
+  TConverters.le32_copy(AData, AIndex, @(LData[0]), 0, ADataLength);
 
-  TConverters.le32_copy(a_data, a_index, @(data[0]), 0, a_data_length);
-
-  a := Fm_state[0];
-  b := Fm_state[1];
-  c := Fm_state[2];
-  d := Fm_state[3];
+  a := FState[0];
+  b := FState[1];
+  c := FState[2];
+  d := FState[3];
   aa := a;
   bb := b;
   cc := c;
   dd := d;
 
-  a := TBits.RotateLeft32(P1(b, c, d) + a + data[0], 11);
-  d := TBits.RotateLeft32(P1(a, b, c) + d + data[1], 14);
-  c := TBits.RotateLeft32(P1(d, a, b) + c + data[2], 15);
-  b := TBits.RotateLeft32(P1(c, d, a) + b + data[3], 12);
-  a := TBits.RotateLeft32(P1(b, c, d) + a + data[4], 5);
-  d := TBits.RotateLeft32(P1(a, b, c) + d + data[5], 8);
-  c := TBits.RotateLeft32(P1(d, a, b) + c + data[6], 7);
-  b := TBits.RotateLeft32(P1(c, d, a) + b + data[7], 9);
-  a := TBits.RotateLeft32(P1(b, c, d) + a + data[8], 11);
-  d := TBits.RotateLeft32(P1(a, b, c) + d + data[9], 13);
-  c := TBits.RotateLeft32(P1(d, a, b) + c + data[10], 14);
-  b := TBits.RotateLeft32(P1(c, d, a) + b + data[11], 15);
-  a := TBits.RotateLeft32(P1(b, c, d) + a + data[12], 6);
-  d := TBits.RotateLeft32(P1(a, b, c) + d + data[13], 7);
-  c := TBits.RotateLeft32(P1(d, a, b) + c + data[14], 9);
-  b := TBits.RotateLeft32(P1(c, d, a) + b + data[15], 8);
-
-  a := TBits.RotateLeft32(P2(b, c, d) + a + data[7] + C2, 7);
-  d := TBits.RotateLeft32(P2(a, b, c) + d + data[4] + C2, 6);
-  c := TBits.RotateLeft32(P2(d, a, b) + c + data[13] + C2, 8);
-  b := TBits.RotateLeft32(P2(c, d, a) + b + data[1] + C2, 13);
-  a := TBits.RotateLeft32(P2(b, c, d) + a + data[10] + C2, 11);
-  d := TBits.RotateLeft32(P2(a, b, c) + d + data[6] + C2, 9);
-  c := TBits.RotateLeft32(P2(d, a, b) + c + data[15] + C2, 7);
-  b := TBits.RotateLeft32(P2(c, d, a) + b + data[3] + C2, 15);
-  a := TBits.RotateLeft32(P2(b, c, d) + a + data[12] + C2, 7);
-  d := TBits.RotateLeft32(P2(a, b, c) + d + data[0] + C2, 12);
-  c := TBits.RotateLeft32(P2(d, a, b) + c + data[9] + C2, 15);
-  b := TBits.RotateLeft32(P2(c, d, a) + b + data[5] + C2, 9);
-  a := TBits.RotateLeft32(P2(b, c, d) + a + data[14] + C2, 7);
-  d := TBits.RotateLeft32(P2(a, b, c) + d + data[2] + C2, 11);
-  c := TBits.RotateLeft32(P2(d, a, b) + c + data[11] + C2, 13);
-  b := TBits.RotateLeft32(P2(c, d, a) + b + data[8] + C2, 12);
-
-  a := TBits.RotateLeft32(P3(b, c, d) + a + data[3] + C4, 11);
-  d := TBits.RotateLeft32(P3(a, b, c) + d + data[10] + C4, 13);
-  c := TBits.RotateLeft32(P3(d, a, b) + c + data[2] + C4, 14);
-  b := TBits.RotateLeft32(P3(c, d, a) + b + data[4] + C4, 7);
-  a := TBits.RotateLeft32(P3(b, c, d) + a + data[9] + C4, 14);
-  d := TBits.RotateLeft32(P3(a, b, c) + d + data[15] + C4, 9);
-  c := TBits.RotateLeft32(P3(d, a, b) + c + data[8] + C4, 13);
-  b := TBits.RotateLeft32(P3(c, d, a) + b + data[1] + C4, 15);
-  a := TBits.RotateLeft32(P3(b, c, d) + a + data[14] + C4, 6);
-  d := TBits.RotateLeft32(P3(a, b, c) + d + data[7] + C4, 8);
-  c := TBits.RotateLeft32(P3(d, a, b) + c + data[0] + C4, 13);
-  b := TBits.RotateLeft32(P3(c, d, a) + b + data[6] + C4, 6);
-  a := TBits.RotateLeft32(P3(b, c, d) + a + data[11] + C4, 12);
-  d := TBits.RotateLeft32(P3(a, b, c) + d + data[13] + C4, 5);
-  c := TBits.RotateLeft32(P3(d, a, b) + c + data[5] + C4, 7);
-  b := TBits.RotateLeft32(P3(c, d, a) + b + data[12] + C4, 5);
-
-  aa := TBits.RotateLeft32(P1(bb, cc, dd) + aa + data[0] + C1, 11);
-  dd := TBits.RotateLeft32(P1(aa, bb, cc) + dd + data[1] + C1, 14);
-  cc := TBits.RotateLeft32(P1(dd, aa, bb) + cc + data[2] + C1, 15);
-  bb := TBits.RotateLeft32(P1(cc, dd, aa) + bb + data[3] + C1, 12);
-  aa := TBits.RotateLeft32(P1(bb, cc, dd) + aa + data[4] + C1, 5);
-  dd := TBits.RotateLeft32(P1(aa, bb, cc) + dd + data[5] + C1, 8);
-  cc := TBits.RotateLeft32(P1(dd, aa, bb) + cc + data[6] + C1, 7);
-  bb := TBits.RotateLeft32(P1(cc, dd, aa) + bb + data[7] + C1, 9);
-  aa := TBits.RotateLeft32(P1(bb, cc, dd) + aa + data[8] + C1, 11);
-  dd := TBits.RotateLeft32(P1(aa, bb, cc) + dd + data[9] + C1, 13);
-  cc := TBits.RotateLeft32(P1(dd, aa, bb) + cc + data[10] + C1, 14);
-  bb := TBits.RotateLeft32(P1(cc, dd, aa) + bb + data[11] + C1, 15);
-  aa := TBits.RotateLeft32(P1(bb, cc, dd) + aa + data[12] + C1, 6);
-  dd := TBits.RotateLeft32(P1(aa, bb, cc) + dd + data[13] + C1, 7);
-  cc := TBits.RotateLeft32(P1(dd, aa, bb) + cc + data[14] + C1, 9);
-  bb := TBits.RotateLeft32(P1(cc, dd, aa) + bb + data[15] + C1, 8);
-
-  aa := TBits.RotateLeft32(P2(bb, cc, dd) + aa + data[7], 7);
-  dd := TBits.RotateLeft32(P2(aa, bb, cc) + dd + data[4], 6);
-  cc := TBits.RotateLeft32(P2(dd, aa, bb) + cc + data[13], 8);
-  bb := TBits.RotateLeft32(P2(cc, dd, aa) + bb + data[1], 13);
-  aa := TBits.RotateLeft32(P2(bb, cc, dd) + aa + data[10], 11);
-  dd := TBits.RotateLeft32(P2(aa, bb, cc) + dd + data[6], 9);
-  cc := TBits.RotateLeft32(P2(dd, aa, bb) + cc + data[15], 7);
-  bb := TBits.RotateLeft32(P2(cc, dd, aa) + bb + data[3], 15);
-  aa := TBits.RotateLeft32(P2(bb, cc, dd) + aa + data[12], 7);
-  dd := TBits.RotateLeft32(P2(aa, bb, cc) + dd + data[0], 12);
-  cc := TBits.RotateLeft32(P2(dd, aa, bb) + cc + data[9], 15);
-  bb := TBits.RotateLeft32(P2(cc, dd, aa) + bb + data[5], 9);
-  aa := TBits.RotateLeft32(P2(bb, cc, dd) + aa + data[14], 7);
-  dd := TBits.RotateLeft32(P2(aa, bb, cc) + dd + data[2], 11);
-  cc := TBits.RotateLeft32(P2(dd, aa, bb) + cc + data[11], 13);
-  bb := TBits.RotateLeft32(P2(cc, dd, aa) + bb + data[8], 12);
-
-  aa := TBits.RotateLeft32(P3(bb, cc, dd) + aa + data[3] + C3, 11);
-  dd := TBits.RotateLeft32(P3(aa, bb, cc) + dd + data[10] + C3, 13);
-  cc := TBits.RotateLeft32(P3(dd, aa, bb) + cc + data[2] + C3, 14);
-  bb := TBits.RotateLeft32(P3(cc, dd, aa) + bb + data[4] + C3, 7);
-  aa := TBits.RotateLeft32(P3(bb, cc, dd) + aa + data[9] + C3, 14);
-  dd := TBits.RotateLeft32(P3(aa, bb, cc) + dd + data[15] + C3, 9);
-  cc := TBits.RotateLeft32(P3(dd, aa, bb) + cc + data[8] + C3, 13);
-  bb := TBits.RotateLeft32(P3(cc, dd, aa) + bb + data[1] + C3, 15);
-  aa := TBits.RotateLeft32(P3(bb, cc, dd) + aa + data[14] + C3, 6);
-  dd := TBits.RotateLeft32(P3(aa, bb, cc) + dd + data[7] + C3, 8);
-  cc := TBits.RotateLeft32(P3(dd, aa, bb) + cc + data[0] + C3, 13);
-  bb := TBits.RotateLeft32(P3(cc, dd, aa) + bb + data[6] + C3, 6);
-  aa := TBits.RotateLeft32(P3(bb, cc, dd) + aa + data[11] + C3, 12);
-  dd := TBits.RotateLeft32(P3(aa, bb, cc) + dd + data[13] + C3, 5);
-  cc := TBits.RotateLeft32(P3(dd, aa, bb) + cc + data[5] + C3, 7);
-  bb := TBits.RotateLeft32(P3(cc, dd, aa) + bb + data[12] + C3, 5);
-
-  cc := cc + Fm_state[0] + b;
-  Fm_state[0] := Fm_state[1] + c + dd;
-  Fm_state[1] := Fm_state[2] + d + aa;
-  Fm_state[2] := Fm_state[3] + a + bb;
-  Fm_state[3] := cc;
-
-  System.FillChar(data, System.SizeOf(data), UInt32(0));
-
+  a := TBits.RotateLeft32(P1(b, c, d) + a + LData[0], 11);
+  d := TBits.RotateLeft32(P1(a, b, c) + d + LData[1], 14);
+  c := TBits.RotateLeft32(P1(d, a, b) + c + LData[2], 15);
+  b := TBits.RotateLeft32(P1(c, d, a) + b + LData[3], 12);
+  a := TBits.RotateLeft32(P1(b, c, d) + a + LData[4], 5);
+  d := TBits.RotateLeft32(P1(a, b, c) + d + LData[5], 8);
+  c := TBits.RotateLeft32(P1(d, a, b) + c + LData[6], 7);
+  b := TBits.RotateLeft32(P1(c, d, a) + b + LData[7], 9);
+  a := TBits.RotateLeft32(P1(b, c, d) + a + LData[8], 11);
+  d := TBits.RotateLeft32(P1(a, b, c) + d + LData[9], 13);
+  c := TBits.RotateLeft32(P1(d, a, b) + c + LData[10], 14);
+  b := TBits.RotateLeft32(P1(c, d, a) + b + LData[11], 15);
+  a := TBits.RotateLeft32(P1(b, c, d) + a + LData[12], 6);
+  d := TBits.RotateLeft32(P1(a, b, c) + d + LData[13], 7);
+  c := TBits.RotateLeft32(P1(d, a, b) + c + LData[14], 9);
+  b := TBits.RotateLeft32(P1(c, d, a) + b + LData[15], 8);
+
+  a := TBits.RotateLeft32(P2(b, c, d) + a + LData[7] + C2, 7);
+  d := TBits.RotateLeft32(P2(a, b, c) + d + LData[4] + C2, 6);
+  c := TBits.RotateLeft32(P2(d, a, b) + c + LData[13] + C2, 8);
+  b := TBits.RotateLeft32(P2(c, d, a) + b + LData[1] + C2, 13);
+  a := TBits.RotateLeft32(P2(b, c, d) + a + LData[10] + C2, 11);
+  d := TBits.RotateLeft32(P2(a, b, c) + d + LData[6] + C2, 9);
+  c := TBits.RotateLeft32(P2(d, a, b) + c + LData[15] + C2, 7);
+  b := TBits.RotateLeft32(P2(c, d, a) + b + LData[3] + C2, 15);
+  a := TBits.RotateLeft32(P2(b, c, d) + a + LData[12] + C2, 7);
+  d := TBits.RotateLeft32(P2(a, b, c) + d + LData[0] + C2, 12);
+  c := TBits.RotateLeft32(P2(d, a, b) + c + LData[9] + C2, 15);
+  b := TBits.RotateLeft32(P2(c, d, a) + b + LData[5] + C2, 9);
+  a := TBits.RotateLeft32(P2(b, c, d) + a + LData[14] + C2, 7);
+  d := TBits.RotateLeft32(P2(a, b, c) + d + LData[2] + C2, 11);
+  c := TBits.RotateLeft32(P2(d, a, b) + c + LData[11] + C2, 13);
+  b := TBits.RotateLeft32(P2(c, d, a) + b + LData[8] + C2, 12);
+
+  a := TBits.RotateLeft32(P3(b, c, d) + a + LData[3] + C4, 11);
+  d := TBits.RotateLeft32(P3(a, b, c) + d + LData[10] + C4, 13);
+  c := TBits.RotateLeft32(P3(d, a, b) + c + LData[2] + C4, 14);
+  b := TBits.RotateLeft32(P3(c, d, a) + b + LData[4] + C4, 7);
+  a := TBits.RotateLeft32(P3(b, c, d) + a + LData[9] + C4, 14);
+  d := TBits.RotateLeft32(P3(a, b, c) + d + LData[15] + C4, 9);
+  c := TBits.RotateLeft32(P3(d, a, b) + c + LData[8] + C4, 13);
+  b := TBits.RotateLeft32(P3(c, d, a) + b + LData[1] + C4, 15);
+  a := TBits.RotateLeft32(P3(b, c, d) + a + LData[14] + C4, 6);
+  d := TBits.RotateLeft32(P3(a, b, c) + d + LData[7] + C4, 8);
+  c := TBits.RotateLeft32(P3(d, a, b) + c + LData[0] + C4, 13);
+  b := TBits.RotateLeft32(P3(c, d, a) + b + LData[6] + C4, 6);
+  a := TBits.RotateLeft32(P3(b, c, d) + a + LData[11] + C4, 12);
+  d := TBits.RotateLeft32(P3(a, b, c) + d + LData[13] + C4, 5);
+  c := TBits.RotateLeft32(P3(d, a, b) + c + LData[5] + C4, 7);
+  b := TBits.RotateLeft32(P3(c, d, a) + b + LData[12] + C4, 5);
+
+  aa := TBits.RotateLeft32(P1(bb, cc, dd) + aa + LData[0] + C1, 11);
+  dd := TBits.RotateLeft32(P1(aa, bb, cc) + dd + LData[1] + C1, 14);
+  cc := TBits.RotateLeft32(P1(dd, aa, bb) + cc + LData[2] + C1, 15);
+  bb := TBits.RotateLeft32(P1(cc, dd, aa) + bb + LData[3] + C1, 12);
+  aa := TBits.RotateLeft32(P1(bb, cc, dd) + aa + LData[4] + C1, 5);
+  dd := TBits.RotateLeft32(P1(aa, bb, cc) + dd + LData[5] + C1, 8);
+  cc := TBits.RotateLeft32(P1(dd, aa, bb) + cc + LData[6] + C1, 7);
+  bb := TBits.RotateLeft32(P1(cc, dd, aa) + bb + LData[7] + C1, 9);
+  aa := TBits.RotateLeft32(P1(bb, cc, dd) + aa + LData[8] + C1, 11);
+  dd := TBits.RotateLeft32(P1(aa, bb, cc) + dd + LData[9] + C1, 13);
+  cc := TBits.RotateLeft32(P1(dd, aa, bb) + cc + LData[10] + C1, 14);
+  bb := TBits.RotateLeft32(P1(cc, dd, aa) + bb + LData[11] + C1, 15);
+  aa := TBits.RotateLeft32(P1(bb, cc, dd) + aa + LData[12] + C1, 6);
+  dd := TBits.RotateLeft32(P1(aa, bb, cc) + dd + LData[13] + C1, 7);
+  cc := TBits.RotateLeft32(P1(dd, aa, bb) + cc + LData[14] + C1, 9);
+  bb := TBits.RotateLeft32(P1(cc, dd, aa) + bb + LData[15] + C1, 8);
+
+  aa := TBits.RotateLeft32(P2(bb, cc, dd) + aa + LData[7], 7);
+  dd := TBits.RotateLeft32(P2(aa, bb, cc) + dd + LData[4], 6);
+  cc := TBits.RotateLeft32(P2(dd, aa, bb) + cc + LData[13], 8);
+  bb := TBits.RotateLeft32(P2(cc, dd, aa) + bb + LData[1], 13);
+  aa := TBits.RotateLeft32(P2(bb, cc, dd) + aa + LData[10], 11);
+  dd := TBits.RotateLeft32(P2(aa, bb, cc) + dd + LData[6], 9);
+  cc := TBits.RotateLeft32(P2(dd, aa, bb) + cc + LData[15], 7);
+  bb := TBits.RotateLeft32(P2(cc, dd, aa) + bb + LData[3], 15);
+  aa := TBits.RotateLeft32(P2(bb, cc, dd) + aa + LData[12], 7);
+  dd := TBits.RotateLeft32(P2(aa, bb, cc) + dd + LData[0], 12);
+  cc := TBits.RotateLeft32(P2(dd, aa, bb) + cc + LData[9], 15);
+  bb := TBits.RotateLeft32(P2(cc, dd, aa) + bb + LData[5], 9);
+  aa := TBits.RotateLeft32(P2(bb, cc, dd) + aa + LData[14], 7);
+  dd := TBits.RotateLeft32(P2(aa, bb, cc) + dd + LData[2], 11);
+  cc := TBits.RotateLeft32(P2(dd, aa, bb) + cc + LData[11], 13);
+  bb := TBits.RotateLeft32(P2(cc, dd, aa) + bb + LData[8], 12);
+
+  aa := TBits.RotateLeft32(P3(bb, cc, dd) + aa + LData[3] + C3, 11);
+  dd := TBits.RotateLeft32(P3(aa, bb, cc) + dd + LData[10] + C3, 13);
+  cc := TBits.RotateLeft32(P3(dd, aa, bb) + cc + LData[2] + C3, 14);
+  bb := TBits.RotateLeft32(P3(cc, dd, aa) + bb + LData[4] + C3, 7);
+  aa := TBits.RotateLeft32(P3(bb, cc, dd) + aa + LData[9] + C3, 14);
+  dd := TBits.RotateLeft32(P3(aa, bb, cc) + dd + LData[15] + C3, 9);
+  cc := TBits.RotateLeft32(P3(dd, aa, bb) + cc + LData[8] + C3, 13);
+  bb := TBits.RotateLeft32(P3(cc, dd, aa) + bb + LData[1] + C3, 15);
+  aa := TBits.RotateLeft32(P3(bb, cc, dd) + aa + LData[14] + C3, 6);
+  dd := TBits.RotateLeft32(P3(aa, bb, cc) + dd + LData[7] + C3, 8);
+  cc := TBits.RotateLeft32(P3(dd, aa, bb) + cc + LData[0] + C3, 13);
+  bb := TBits.RotateLeft32(P3(cc, dd, aa) + bb + LData[6] + C3, 6);
+  aa := TBits.RotateLeft32(P3(bb, cc, dd) + aa + LData[11] + C3, 12);
+  dd := TBits.RotateLeft32(P3(aa, bb, cc) + dd + LData[13] + C3, 5);
+  cc := TBits.RotateLeft32(P3(dd, aa, bb) + cc + LData[5] + C3, 7);
+  bb := TBits.RotateLeft32(P3(cc, dd, aa) + bb + LData[12] + C3, 5);
+
+  cc := cc + FState[0] + b;
+  FState[0] := FState[1] + c + dd;
+  FState[1] := FState[2] + d + aa;
+  FState[2] := FState[3] + a + bb;
+  FState[3] := cc;
+
+  System.FillChar(LData, System.SizeOf(LData), UInt32(0));
 end;
 
 end.

+ 150 - 152
src/libraries/hashlib4pascal/HlpRIPEMD128.pas

@@ -23,8 +23,8 @@ type
   TRIPEMD128 = class sealed(TMDBase, ITransformBlock)
 
   strict protected
-    procedure TransformBlock(a_data: PByte; a_data_length: Int32;
-      a_index: Int32); override;
+    procedure TransformBlock(AData: PByte; ADataLength: Int32;
+      AIndex: Int32); override;
 
   public
     constructor Create();
@@ -38,13 +38,13 @@ implementation
 
 function TRIPEMD128.Clone(): IHash;
 var
-  HashInstance: TRIPEMD128;
+  LHashInstance: TRIPEMD128;
 begin
-  HashInstance := TRIPEMD128.Create();
-  HashInstance.Fm_state := System.Copy(Fm_state);
-  HashInstance.Fm_buffer := Fm_buffer.Clone();
-  HashInstance.Fm_processed_bytes := Fm_processed_bytes;
-  result := HashInstance as IHash;
+  LHashInstance := TRIPEMD128.Create();
+  LHashInstance.FState := System.Copy(FState);
+  LHashInstance.FBuffer := FBuffer.Clone();
+  LHashInstance.FProcessedBytesCount := FProcessedBytesCount;
+  result := LHashInstance as IHash;
   result.BufferSize := BufferSize;
 end;
 
@@ -53,296 +53,294 @@ begin
   Inherited Create(4, 16);
 end;
 
-procedure TRIPEMD128.TransformBlock(a_data: PByte; a_data_length: Int32;
-  a_index: Int32);
+procedure TRIPEMD128.TransformBlock(AData: PByte; ADataLength: Int32;
+  AIndex: Int32);
 var
   a, b, c, d, aa, bb, cc, dd: UInt32;
-  data: array [0 .. 15] of UInt32;
+  LData: array [0 .. 15] of UInt32;
 begin
+  TConverters.le32_copy(AData, AIndex, @(LData[0]), 0, ADataLength);
 
-  TConverters.le32_copy(a_data, a_index, @(data[0]), 0, a_data_length);
-
-  a := Fm_state[0];
-  b := Fm_state[1];
-  c := Fm_state[2];
-  d := Fm_state[3];
+  a := FState[0];
+  b := FState[1];
+  c := FState[2];
+  d := FState[3];
   aa := a;
   bb := b;
   cc := c;
   dd := d;
 
-  a := a + (data[0] + (b xor c xor d));
+  a := a + (LData[0] + (b xor c xor d));
   a := TBits.RotateLeft32(a, 11);
-  d := d + (data[1] + (a xor b xor c));
+  d := d + (LData[1] + (a xor b xor c));
   d := TBits.RotateLeft32(d, 14);
-  c := c + (data[2] + (d xor a xor b));
+  c := c + (LData[2] + (d xor a xor b));
   c := TBits.RotateLeft32(c, 15);
-  b := b + (data[3] + (c xor d xor a));
+  b := b + (LData[3] + (c xor d xor a));
   b := TBits.RotateLeft32(b, 12);
-  a := a + (data[4] + (b xor c xor d));
+  a := a + (LData[4] + (b xor c xor d));
   a := TBits.RotateLeft32(a, 5);
-  d := d + (data[5] + (a xor b xor c));
+  d := d + (LData[5] + (a xor b xor c));
   d := TBits.RotateLeft32(d, 8);
-  c := c + (data[6] + (d xor a xor b));
+  c := c + (LData[6] + (d xor a xor b));
   c := TBits.RotateLeft32(c, 7);
-  b := b + (data[7] + (c xor d xor a));
+  b := b + (LData[7] + (c xor d xor a));
   b := TBits.RotateLeft32(b, 9);
-  a := a + (data[8] + (b xor c xor d));
+  a := a + (LData[8] + (b xor c xor d));
   a := TBits.RotateLeft32(a, 11);
-  d := d + (data[9] + (a xor b xor c));
+  d := d + (LData[9] + (a xor b xor c));
   d := TBits.RotateLeft32(d, 13);
-  c := c + (data[10] + (d xor a xor b));
+  c := c + (LData[10] + (d xor a xor b));
   c := TBits.RotateLeft32(c, 14);
-  b := b + (data[11] + (c xor d xor a));
+  b := b + (LData[11] + (c xor d xor a));
   b := TBits.RotateLeft32(b, 15);
-  a := a + (data[12] + (b xor c xor d));
+  a := a + (LData[12] + (b xor c xor d));
   a := TBits.RotateLeft32(a, 6);
-  d := d + (data[13] + (a xor b xor c));
+  d := d + (LData[13] + (a xor b xor c));
   d := TBits.RotateLeft32(d, 7);
-  c := c + (data[14] + (d xor a xor b));
+  c := c + (LData[14] + (d xor a xor b));
   c := TBits.RotateLeft32(c, 9);
-  b := b + (data[15] + (c xor d xor a));
+  b := b + (LData[15] + (c xor d xor a));
   b := TBits.RotateLeft32(b, 8);
 
-  a := a + (data[7] + C2 + ((b and c) or (not b and d)));
+  a := a + (LData[7] + C2 + ((b and c) or (not b and d)));
   a := TBits.RotateLeft32(a, 7);
-  d := d + (data[4] + C2 + ((a and b) or (not a and c)));
+  d := d + (LData[4] + C2 + ((a and b) or (not a and c)));
   d := TBits.RotateLeft32(d, 6);
-  c := c + (data[13] + C2 + ((d and a) or (not d and b)));
+  c := c + (LData[13] + C2 + ((d and a) or (not d and b)));
   c := TBits.RotateLeft32(c, 8);
-  b := b + (data[1] + C2 + ((c and d) or (not c and a)));
+  b := b + (LData[1] + C2 + ((c and d) or (not c and a)));
   b := TBits.RotateLeft32(b, 13);
-  a := a + (data[10] + C2 + ((b and c) or (not b and d)));
+  a := a + (LData[10] + C2 + ((b and c) or (not b and d)));
   a := TBits.RotateLeft32(a, 11);
-  d := d + (data[6] + C2 + ((a and b) or (not a and c)));
+  d := d + (LData[6] + C2 + ((a and b) or (not a and c)));
   d := TBits.RotateLeft32(d, 9);
-  c := c + (data[15] + C2 + ((d and a) or (not d and b)));
+  c := c + (LData[15] + C2 + ((d and a) or (not d and b)));
   c := TBits.RotateLeft32(c, 7);
-  b := b + (data[3] + C2 + ((c and d) or (not c and a)));
+  b := b + (LData[3] + C2 + ((c and d) or (not c and a)));
   b := TBits.RotateLeft32(b, 15);
-  a := a + (data[12] + C2 + ((b and c) or (not b and d)));
+  a := a + (LData[12] + C2 + ((b and c) or (not b and d)));
   a := TBits.RotateLeft32(a, 7);
-  d := d + (data[0] + C2 + ((a and b) or (not a and c)));
+  d := d + (LData[0] + C2 + ((a and b) or (not a and c)));
   d := TBits.RotateLeft32(d, 12);
-  c := c + (data[9] + C2 + ((d and a) or (not d and b)));
+  c := c + (LData[9] + C2 + ((d and a) or (not d and b)));
   c := TBits.RotateLeft32(c, 15);
-  b := b + (data[5] + C2 + ((c and d) or (not c and a)));
+  b := b + (LData[5] + C2 + ((c and d) or (not c and a)));
   b := TBits.RotateLeft32(b, 9);
-  a := a + (data[2] + C2 + ((b and c) or (not b and d)));
+  a := a + (LData[2] + C2 + ((b and c) or (not b and d)));
   a := TBits.RotateLeft32(a, 11);
-  d := d + (data[14] + C2 + ((a and b) or (not a and c)));
+  d := d + (LData[14] + C2 + ((a and b) or (not a and c)));
   d := TBits.RotateLeft32(d, 7);
-  c := c + (data[11] + C2 + ((d and a) or (not d and b)));
+  c := c + (LData[11] + C2 + ((d and a) or (not d and b)));
   c := TBits.RotateLeft32(c, 13);
-  b := b + (data[8] + C2 + ((c and d) or (not c and a)));
+  b := b + (LData[8] + C2 + ((c and d) or (not c and a)));
   b := TBits.RotateLeft32(b, 12);
 
-  a := a + (data[3] + C4 + ((b or not c) xor d));
+  a := a + (LData[3] + C4 + ((b or not c) xor d));
   a := TBits.RotateLeft32(a, 11);
-  d := d + (data[10] + C4 + ((a or not b) xor c));
+  d := d + (LData[10] + C4 + ((a or not b) xor c));
   d := TBits.RotateLeft32(d, 13);
-  c := c + (data[14] + C4 + ((d or not a) xor b));
+  c := c + (LData[14] + C4 + ((d or not a) xor b));
   c := TBits.RotateLeft32(c, 6);
-  b := b + (data[4] + C4 + ((c or not d) xor a));
+  b := b + (LData[4] + C4 + ((c or not d) xor a));
   b := TBits.RotateLeft32(b, 7);
-  a := a + (data[9] + C4 + ((b or not c) xor d));
+  a := a + (LData[9] + C4 + ((b or not c) xor d));
   a := TBits.RotateLeft32(a, 14);
-  d := d + (data[15] + C4 + ((a or not b) xor c));
+  d := d + (LData[15] + C4 + ((a or not b) xor c));
   d := TBits.RotateLeft32(d, 9);
-  c := c + (data[8] + C4 + ((d or not a) xor b));
+  c := c + (LData[8] + C4 + ((d or not a) xor b));
   c := TBits.RotateLeft32(c, 13);
-  b := b + (data[1] + C4 + ((c or not d) xor a));
+  b := b + (LData[1] + C4 + ((c or not d) xor a));
   b := TBits.RotateLeft32(b, 15);
-  a := a + (data[2] + C4 + ((b or not c) xor d));
+  a := a + (LData[2] + C4 + ((b or not c) xor d));
   a := TBits.RotateLeft32(a, 14);
-  d := d + (data[7] + C4 + ((a or not b) xor c));
+  d := d + (LData[7] + C4 + ((a or not b) xor c));
   d := TBits.RotateLeft32(d, 8);
-  c := c + (data[0] + C4 + ((d or not a) xor b));
+  c := c + (LData[0] + C4 + ((d or not a) xor b));
   c := TBits.RotateLeft32(c, 13);
-  b := b + (data[6] + C4 + ((c or not d) xor a));
+  b := b + (LData[6] + C4 + ((c or not d) xor a));
   b := TBits.RotateLeft32(b, 6);
-  a := a + (data[13] + C4 + ((b or not c) xor d));
+  a := a + (LData[13] + C4 + ((b or not c) xor d));
   a := TBits.RotateLeft32(a, 5);
-  d := d + (data[11] + C4 + ((a or not b) xor c));
+  d := d + (LData[11] + C4 + ((a or not b) xor c));
   d := TBits.RotateLeft32(d, 12);
-  c := c + (data[5] + C4 + ((d or not a) xor b));
+  c := c + (LData[5] + C4 + ((d or not a) xor b));
   c := TBits.RotateLeft32(c, 7);
-  b := b + (data[12] + C4 + ((c or not d) xor a));
+  b := b + (LData[12] + C4 + ((c or not d) xor a));
   b := TBits.RotateLeft32(b, 5);
 
-  a := a + (data[1] + C6 + ((b and d) or (c and not d)));
+  a := a + (LData[1] + C6 + ((b and d) or (c and not d)));
   a := TBits.RotateLeft32(a, 11);
-  d := d + (data[9] + C6 + ((a and c) or (b and not c)));
+  d := d + (LData[9] + C6 + ((a and c) or (b and not c)));
   d := TBits.RotateLeft32(d, 12);
-  c := c + (data[11] + C6 + ((d and b) or (a and not b)));
+  c := c + (LData[11] + C6 + ((d and b) or (a and not b)));
   c := TBits.RotateLeft32(c, 14);
-  b := b + (data[10] + C6 + ((c and a) or (d and not a)));
+  b := b + (LData[10] + C6 + ((c and a) or (d and not a)));
   b := TBits.RotateLeft32(b, 15);
-  a := a + (data[0] + C6 + ((b and d) or (c and not d)));
+  a := a + (LData[0] + C6 + ((b and d) or (c and not d)));
   a := TBits.RotateLeft32(a, 14);
-  d := d + (data[8] + C6 + ((a and c) or (b and not c)));
+  d := d + (LData[8] + C6 + ((a and c) or (b and not c)));
   d := TBits.RotateLeft32(d, 15);
-  c := c + (data[12] + C6 + ((d and b) or (a and not b)));
+  c := c + (LData[12] + C6 + ((d and b) or (a and not b)));
   c := TBits.RotateLeft32(c, 9);
-  b := b + (data[4] + C6 + ((c and a) or (d and not a)));
+  b := b + (LData[4] + C6 + ((c and a) or (d and not a)));
   b := TBits.RotateLeft32(b, 8);
-  a := a + (data[13] + C6 + ((b and d) or (c and not d)));
+  a := a + (LData[13] + C6 + ((b and d) or (c and not d)));
   a := TBits.RotateLeft32(a, 9);
-  d := d + (data[3] + C6 + ((a and c) or (b and not c)));
+  d := d + (LData[3] + C6 + ((a and c) or (b and not c)));
   d := TBits.RotateLeft32(d, 14);
-  c := c + (data[7] + C6 + ((d and b) or (a and not b)));
+  c := c + (LData[7] + C6 + ((d and b) or (a and not b)));
   c := TBits.RotateLeft32(c, 5);
-  b := b + (data[15] + C6 + ((c and a) or (d and not a)));
+  b := b + (LData[15] + C6 + ((c and a) or (d and not a)));
   b := TBits.RotateLeft32(b, 6);
-  a := a + (data[14] + C6 + ((b and d) or (c and not d)));
+  a := a + (LData[14] + C6 + ((b and d) or (c and not d)));
   a := TBits.RotateLeft32(a, 8);
-  d := d + (data[5] + C6 + ((a and c) or (b and not c)));
+  d := d + (LData[5] + C6 + ((a and c) or (b and not c)));
   d := TBits.RotateLeft32(d, 6);
-  c := c + (data[6] + C6 + ((d and b) or (a and not b)));
+  c := c + (LData[6] + C6 + ((d and b) or (a and not b)));
   c := TBits.RotateLeft32(c, 5);
-  b := b + (data[2] + C6 + ((c and a) or (d and not a)));
+  b := b + (LData[2] + C6 + ((c and a) or (d and not a)));
   b := TBits.RotateLeft32(b, 12);
 
-  aa := aa + (data[5] + C1 + ((bb and dd) or (cc and not dd)));
+  aa := aa + (LData[5] + C1 + ((bb and dd) or (cc and not dd)));
   aa := TBits.RotateLeft32(aa, 8);
-  dd := dd + (data[14] + C1 + ((aa and cc) or (bb and not cc)));
+  dd := dd + (LData[14] + C1 + ((aa and cc) or (bb and not cc)));
   dd := TBits.RotateLeft32(dd, 9);
-  cc := cc + (data[7] + C1 + ((dd and bb) or (aa and not bb)));
+  cc := cc + (LData[7] + C1 + ((dd and bb) or (aa and not bb)));
   cc := TBits.RotateLeft32(cc, 9);
-  bb := bb + (data[0] + C1 + ((cc and aa) or (dd and not aa)));
+  bb := bb + (LData[0] + C1 + ((cc and aa) or (dd and not aa)));
   bb := TBits.RotateLeft32(bb, 11);
-  aa := aa + (data[9] + C1 + ((bb and dd) or (cc and not dd)));
+  aa := aa + (LData[9] + C1 + ((bb and dd) or (cc and not dd)));
   aa := TBits.RotateLeft32(aa, 13);
-  dd := dd + (data[2] + C1 + ((aa and cc) or (bb and not cc)));
+  dd := dd + (LData[2] + C1 + ((aa and cc) or (bb and not cc)));
   dd := TBits.RotateLeft32(dd, 15);
-  cc := cc + (data[11] + C1 + ((dd and bb) or (aa and not bb)));
+  cc := cc + (LData[11] + C1 + ((dd and bb) or (aa and not bb)));
   cc := TBits.RotateLeft32(cc, 15);
-  bb := bb + (data[4] + C1 + ((cc and aa) or (dd and not aa)));
+  bb := bb + (LData[4] + C1 + ((cc and aa) or (dd and not aa)));
   bb := TBits.RotateLeft32(bb, 5);
-  aa := aa + (data[13] + C1 + ((bb and dd) or (cc and not dd)));
+  aa := aa + (LData[13] + C1 + ((bb and dd) or (cc and not dd)));
   aa := TBits.RotateLeft32(aa, 7);
-  dd := dd + (data[6] + C1 + ((aa and cc) or (bb and not cc)));
+  dd := dd + (LData[6] + C1 + ((aa and cc) or (bb and not cc)));
   dd := TBits.RotateLeft32(dd, 7);
-  cc := cc + (data[15] + C1 + ((dd and bb) or (aa and not bb)));
+  cc := cc + (LData[15] + C1 + ((dd and bb) or (aa and not bb)));
   cc := TBits.RotateLeft32(cc, 8);
-  bb := bb + (data[8] + C1 + ((cc and aa) or (dd and not aa)));
+  bb := bb + (LData[8] + C1 + ((cc and aa) or (dd and not aa)));
   bb := TBits.RotateLeft32(bb, 11);
-  aa := aa + (data[1] + C1 + ((bb and dd) or (cc and not dd)));
+  aa := aa + (LData[1] + C1 + ((bb and dd) or (cc and not dd)));
   aa := TBits.RotateLeft32(aa, 14);
-  dd := dd + (data[10] + C1 + ((aa and cc) or (bb and not cc)));
+  dd := dd + (LData[10] + C1 + ((aa and cc) or (bb and not cc)));
   dd := TBits.RotateLeft32(dd, 14);
-  cc := cc + (data[3] + C1 + ((dd and bb) or (aa and not bb)));
+  cc := cc + (LData[3] + C1 + ((dd and bb) or (aa and not bb)));
   cc := TBits.RotateLeft32(cc, 12);
-  bb := bb + (data[12] + C1 + ((cc and aa) or (dd and not aa)));
+  bb := bb + (LData[12] + C1 + ((cc and aa) or (dd and not aa)));
   bb := TBits.RotateLeft32(bb, 6);
 
-  aa := aa + (data[6] + C3 + ((bb or not cc) xor dd));
+  aa := aa + (LData[6] + C3 + ((bb or not cc) xor dd));
   aa := TBits.RotateLeft32(aa, 9);
-  dd := dd + (data[11] + C3 + ((aa or not bb) xor cc));
+  dd := dd + (LData[11] + C3 + ((aa or not bb) xor cc));
   dd := TBits.RotateLeft32(dd, 13);
-  cc := cc + (data[3] + C3 + ((dd or not aa) xor bb));
+  cc := cc + (LData[3] + C3 + ((dd or not aa) xor bb));
   cc := TBits.RotateLeft32(cc, 15);
-  bb := bb + (data[7] + C3 + ((cc or not dd) xor aa));
+  bb := bb + (LData[7] + C3 + ((cc or not dd) xor aa));
   bb := TBits.RotateLeft32(bb, 7);
-  aa := aa + (data[0] + C3 + ((bb or not cc) xor dd));
+  aa := aa + (LData[0] + C3 + ((bb or not cc) xor dd));
   aa := TBits.RotateLeft32(aa, 12);
-  dd := dd + (data[13] + C3 + ((aa or not bb) xor cc));
+  dd := dd + (LData[13] + C3 + ((aa or not bb) xor cc));
   dd := TBits.RotateLeft32(dd, 8);
-  cc := cc + (data[5] + C3 + ((dd or not aa) xor bb));
+  cc := cc + (LData[5] + C3 + ((dd or not aa) xor bb));
   cc := TBits.RotateLeft32(cc, 9);
-  bb := bb + (data[10] + C3 + ((cc or not dd) xor aa));
+  bb := bb + (LData[10] + C3 + ((cc or not dd) xor aa));
   bb := TBits.RotateLeft32(bb, 11);
-  aa := aa + (data[14] + C3 + ((bb or not cc) xor dd));
+  aa := aa + (LData[14] + C3 + ((bb or not cc) xor dd));
   aa := TBits.RotateLeft32(aa, 7);
-  dd := dd + (data[15] + C3 + ((aa or not bb) xor cc));
+  dd := dd + (LData[15] + C3 + ((aa or not bb) xor cc));
   dd := TBits.RotateLeft32(dd, 7);
-  cc := cc + (data[8] + C3 + ((dd or not aa) xor bb));
+  cc := cc + (LData[8] + C3 + ((dd or not aa) xor bb));
   cc := TBits.RotateLeft32(cc, 12);
-  bb := bb + (data[12] + C3 + ((cc or not dd) xor aa));
+  bb := bb + (LData[12] + C3 + ((cc or not dd) xor aa));
   bb := TBits.RotateLeft32(bb, 7);
-  aa := aa + (data[4] + C3 + ((bb or not cc) xor dd));
+  aa := aa + (LData[4] + C3 + ((bb or not cc) xor dd));
   aa := TBits.RotateLeft32(aa, 6);
-  dd := dd + (data[9] + C3 + ((aa or not bb) xor cc));
+  dd := dd + (LData[9] + C3 + ((aa or not bb) xor cc));
   dd := TBits.RotateLeft32(dd, 15);
-  cc := cc + (data[1] + C3 + ((dd or not aa) xor bb));
+  cc := cc + (LData[1] + C3 + ((dd or not aa) xor bb));
   cc := TBits.RotateLeft32(cc, 13);
-  bb := bb + (data[2] + C3 + ((cc or not dd) xor aa));
+  bb := bb + (LData[2] + C3 + ((cc or not dd) xor aa));
   bb := TBits.RotateLeft32(bb, 11);
 
-  aa := aa + (data[15] + C5 + ((bb and cc) or (not bb and dd)));
+  aa := aa + (LData[15] + C5 + ((bb and cc) or (not bb and dd)));
   aa := TBits.RotateLeft32(aa, 9);
-  dd := dd + (data[5] + C5 + ((aa and bb) or (not aa and cc)));
+  dd := dd + (LData[5] + C5 + ((aa and bb) or (not aa and cc)));
   dd := TBits.RotateLeft32(dd, 7);
-  cc := cc + (data[1] + C5 + ((dd and aa) or (not dd and bb)));
+  cc := cc + (LData[1] + C5 + ((dd and aa) or (not dd and bb)));
   cc := TBits.RotateLeft32(cc, 15);
-  bb := bb + (data[3] + C5 + ((cc and dd) or (not cc and aa)));
+  bb := bb + (LData[3] + C5 + ((cc and dd) or (not cc and aa)));
   bb := TBits.RotateLeft32(bb, 11);
-  aa := aa + (data[7] + C5 + ((bb and cc) or (not bb and dd)));
+  aa := aa + (LData[7] + C5 + ((bb and cc) or (not bb and dd)));
   aa := TBits.RotateLeft32(aa, 8);
-  dd := dd + (data[14] + C5 + ((aa and bb) or (not aa and cc)));
+  dd := dd + (LData[14] + C5 + ((aa and bb) or (not aa and cc)));
   dd := TBits.RotateLeft32(dd, 6);
-  cc := cc + (data[6] + C5 + ((dd and aa) or (not dd and bb)));
+  cc := cc + (LData[6] + C5 + ((dd and aa) or (not dd and bb)));
   cc := TBits.RotateLeft32(cc, 6);
-  bb := bb + (data[9] + C5 + ((cc and dd) or (not cc and aa)));
+  bb := bb + (LData[9] + C5 + ((cc and dd) or (not cc and aa)));
   bb := TBits.RotateLeft32(bb, 14);
-  aa := aa + (data[11] + C5 + ((bb and cc) or (not bb and dd)));
+  aa := aa + (LData[11] + C5 + ((bb and cc) or (not bb and dd)));
   aa := TBits.RotateLeft32(aa, 12);
-  dd := dd + (data[8] + C5 + ((aa and bb) or (not aa and cc)));
+  dd := dd + (LData[8] + C5 + ((aa and bb) or (not aa and cc)));
   dd := TBits.RotateLeft32(dd, 13);
-  cc := cc + (data[12] + C5 + ((dd and aa) or (not dd and bb)));
+  cc := cc + (LData[12] + C5 + ((dd and aa) or (not dd and bb)));
   cc := TBits.RotateLeft32(cc, 5);
-  bb := bb + (data[2] + C5 + ((cc and dd) or (not cc and aa)));
+  bb := bb + (LData[2] + C5 + ((cc and dd) or (not cc and aa)));
   bb := TBits.RotateLeft32(bb, 14);
-  aa := aa + (data[10] + C5 + ((bb and cc) or (not bb and dd)));
+  aa := aa + (LData[10] + C5 + ((bb and cc) or (not bb and dd)));
   aa := TBits.RotateLeft32(aa, 13);
-  dd := dd + (data[0] + C5 + ((aa and bb) or (not aa and cc)));
+  dd := dd + (LData[0] + C5 + ((aa and bb) or (not aa and cc)));
   dd := TBits.RotateLeft32(dd, 13);
-  cc := cc + (data[4] + C5 + ((dd and aa) or (not dd and bb)));
+  cc := cc + (LData[4] + C5 + ((dd and aa) or (not dd and bb)));
   cc := TBits.RotateLeft32(cc, 7);
-  bb := bb + (data[13] + C5 + ((cc and dd) or (not cc and aa)));
+  bb := bb + (LData[13] + C5 + ((cc and dd) or (not cc and aa)));
   bb := TBits.RotateLeft32(bb, 5);
 
-  aa := aa + (data[8] + (bb xor cc xor dd));
+  aa := aa + (LData[8] + (bb xor cc xor dd));
   aa := TBits.RotateLeft32(aa, 15);
-  dd := dd + (data[6] + (aa xor bb xor cc));
+  dd := dd + (LData[6] + (aa xor bb xor cc));
   dd := TBits.RotateLeft32(dd, 5);
-  cc := cc + (data[4] + (dd xor aa xor bb));
+  cc := cc + (LData[4] + (dd xor aa xor bb));
   cc := TBits.RotateLeft32(cc, 8);
-  bb := bb + (data[1] + (cc xor dd xor aa));
+  bb := bb + (LData[1] + (cc xor dd xor aa));
   bb := TBits.RotateLeft32(bb, 11);
-  aa := aa + (data[3] + (bb xor cc xor dd));
+  aa := aa + (LData[3] + (bb xor cc xor dd));
   aa := TBits.RotateLeft32(aa, 14);
-  dd := dd + (data[11] + (aa xor bb xor cc));
+  dd := dd + (LData[11] + (aa xor bb xor cc));
   dd := TBits.RotateLeft32(dd, 14);
-  cc := cc + (data[15] + (dd xor aa xor bb));
+  cc := cc + (LData[15] + (dd xor aa xor bb));
   cc := TBits.RotateLeft32(cc, 6);
-  bb := bb + (data[0] + (cc xor dd xor aa));
+  bb := bb + (LData[0] + (cc xor dd xor aa));
   bb := TBits.RotateLeft32(bb, 14);
-  aa := aa + (data[5] + (bb xor cc xor dd));
+  aa := aa + (LData[5] + (bb xor cc xor dd));
   aa := TBits.RotateLeft32(aa, 6);
-  dd := dd + (data[12] + (aa xor bb xor cc));
+  dd := dd + (LData[12] + (aa xor bb xor cc));
   dd := TBits.RotateLeft32(dd, 9);
-  cc := cc + (data[2] + (dd xor aa xor bb));
+  cc := cc + (LData[2] + (dd xor aa xor bb));
   cc := TBits.RotateLeft32(cc, 12);
-  bb := bb + (data[13] + (cc xor dd xor aa));
+  bb := bb + (LData[13] + (cc xor dd xor aa));
   bb := TBits.RotateLeft32(bb, 9);
-  aa := aa + (data[9] + (bb xor cc xor dd));
+  aa := aa + (LData[9] + (bb xor cc xor dd));
   aa := TBits.RotateLeft32(aa, 12);
-  dd := dd + (data[7] + (aa xor bb xor cc));
+  dd := dd + (LData[7] + (aa xor bb xor cc));
   dd := TBits.RotateLeft32(dd, 5);
-  cc := cc + (data[10] + (dd xor aa xor bb));
+  cc := cc + (LData[10] + (dd xor aa xor bb));
   cc := TBits.RotateLeft32(cc, 15);
-  bb := bb + (data[14] + (cc xor dd xor aa));
+  bb := bb + (LData[14] + (cc xor dd xor aa));
   bb := TBits.RotateLeft32(bb, 8);
 
-  dd := dd + c + Fm_state[1];
-  Fm_state[1] := Fm_state[2] + d + aa;
-  Fm_state[2] := Fm_state[3] + a + bb;
-  Fm_state[3] := Fm_state[0] + b + cc;
-  Fm_state[0] := dd;
-
-  System.FillChar(data, System.SizeOf(data), UInt32(0));
+  dd := dd + c + FState[1];
+  FState[1] := FState[2] + d + aa;
+  FState[2] := FState[3] + a + bb;
+  FState[3] := FState[0] + b + cc;
+  FState[0] := dd;
 
+  System.FillChar(LData, System.SizeOf(LData), UInt32(0));
 end;
 
 end.

+ 185 - 189
src/libraries/hashlib4pascal/HlpRIPEMD160.pas

@@ -23,8 +23,8 @@ type
   TRIPEMD160 = class sealed(TMDBase, ITransformBlock)
 
   strict protected
-    procedure TransformBlock(a_data: PByte; a_data_length: Int32;
-      a_index: Int32); override;
+    procedure TransformBlock(AData: PByte; ADataLength: Int32;
+      AIndex: Int32); override;
 
   public
     constructor Create();
@@ -39,13 +39,13 @@ implementation
 
 function TRIPEMD160.Clone(): IHash;
 var
-  HashInstance: TRIPEMD160;
+  LHashInstance: TRIPEMD160;
 begin
-  HashInstance := TRIPEMD160.Create();
-  HashInstance.Fm_state := System.Copy(Fm_state);
-  HashInstance.Fm_buffer := Fm_buffer.Clone();
-  HashInstance.Fm_processed_bytes := Fm_processed_bytes;
-  result := HashInstance as IHash;
+  LHashInstance := TRIPEMD160.Create();
+  LHashInstance.FState := System.Copy(FState);
+  LHashInstance.FBuffer := FBuffer.Clone();
+  LHashInstance.FProcessedBytesCount := FProcessedBytesCount;
+  result := LHashInstance as IHash;
   result.BufferSize := BufferSize;
 end;
 
@@ -56,531 +56,527 @@ end;
 
 procedure TRIPEMD160.Initialize;
 begin
-  Fm_state[4] := $C3D2E1F0;
-
+  FState[4] := $C3D2E1F0;
   Inherited Initialize();
-
 end;
 
-procedure TRIPEMD160.TransformBlock(a_data: PByte; a_data_length: Int32;
-  a_index: Int32);
+procedure TRIPEMD160.TransformBlock(AData: PByte; ADataLength: Int32;
+  AIndex: Int32);
 var
   a, b, c, d, e, aa, bb, cc, dd, ee: UInt32;
-  data: array [0 .. 15] of UInt32;
+  LData: array [0 .. 15] of UInt32;
 begin
+  TConverters.le32_copy(AData, AIndex, @(LData[0]), 0, ADataLength);
 
-  TConverters.le32_copy(a_data, a_index, @(data[0]), 0, a_data_length);
-
-  a := Fm_state[0];
-  b := Fm_state[1];
-  c := Fm_state[2];
-  d := Fm_state[3];
-  e := Fm_state[4];
+  a := FState[0];
+  b := FState[1];
+  c := FState[2];
+  d := FState[3];
+  e := FState[4];
   aa := a;
   bb := b;
   cc := c;
   dd := d;
   ee := e;
 
-  a := a + (data[0] + (b xor c xor d));
+  a := a + (LData[0] + (b xor c xor d));
   a := TBits.RotateLeft32(a, 11) + e;
   c := TBits.RotateLeft32(c, 10);
-  e := e + (data[1] + (a xor b xor c));
+  e := e + (LData[1] + (a xor b xor c));
   e := TBits.RotateLeft32(e, 14) + d;
   b := TBits.RotateLeft32(b, 10);
-  d := d + (data[2] + (e xor a xor b));
+  d := d + (LData[2] + (e xor a xor b));
   d := TBits.RotateLeft32(d, 15) + c;
   a := TBits.RotateLeft32(a, 10);
-  c := c + (data[3] + (d xor e xor a));
+  c := c + (LData[3] + (d xor e xor a));
   c := TBits.RotateLeft32(c, 12) + b;
   e := TBits.RotateLeft32(e, 10);
-  b := b + (data[4] + (c xor d xor e));
+  b := b + (LData[4] + (c xor d xor e));
   b := TBits.RotateLeft32(b, 5) + a;
   d := TBits.RotateLeft32(d, 10);
-  a := a + (data[5] + (b xor c xor d));
+  a := a + (LData[5] + (b xor c xor d));
   a := TBits.RotateLeft32(a, 8) + e;
   c := TBits.RotateLeft32(c, 10);
-  e := e + (data[6] + (a xor b xor c));
+  e := e + (LData[6] + (a xor b xor c));
   e := TBits.RotateLeft32(e, 7) + d;
   b := TBits.RotateLeft32(b, 10);
-  d := d + (data[7] + (e xor a xor b));
+  d := d + (LData[7] + (e xor a xor b));
   d := TBits.RotateLeft32(d, 9) + c;
   a := TBits.RotateLeft32(a, 10);
-  c := c + (data[8] + (d xor e xor a));
+  c := c + (LData[8] + (d xor e xor a));
   c := TBits.RotateLeft32(c, 11) + b;
   e := TBits.RotateLeft32(e, 10);
-  b := b + (data[9] + (c xor d xor e));
+  b := b + (LData[9] + (c xor d xor e));
   b := TBits.RotateLeft32(b, 13) + a;
   d := TBits.RotateLeft32(d, 10);
-  a := a + (data[10] + (b xor c xor d));
+  a := a + (LData[10] + (b xor c xor d));
   a := TBits.RotateLeft32(a, 14) + e;
   c := TBits.RotateLeft32(c, 10);
-  e := e + (data[11] + (a xor b xor c));
+  e := e + (LData[11] + (a xor b xor c));
   e := TBits.RotateLeft32(e, 15) + d;
   b := TBits.RotateLeft32(b, 10);
-  d := d + (data[12] + (e xor a xor b));
+  d := d + (LData[12] + (e xor a xor b));
   d := TBits.RotateLeft32(d, 6) + c;
   a := TBits.RotateLeft32(a, 10);
-  c := c + (data[13] + (d xor e xor a));
+  c := c + (LData[13] + (d xor e xor a));
   c := TBits.RotateLeft32(c, 7) + b;
   e := TBits.RotateLeft32(e, 10);
-  b := b + (data[14] + (c xor d xor e));
+  b := b + (LData[14] + (c xor d xor e));
   b := TBits.RotateLeft32(b, 9) + a;
   d := TBits.RotateLeft32(d, 10);
-  a := a + (data[15] + (b xor c xor d));
+  a := a + (LData[15] + (b xor c xor d));
   a := TBits.RotateLeft32(a, 8) + e;
   c := TBits.RotateLeft32(c, 10);
 
-  aa := aa + (data[5] + C1 + (bb xor (cc or not dd)));
+  aa := aa + (LData[5] + C1 + (bb xor (cc or not dd)));
   aa := TBits.RotateLeft32(aa, 8) + ee;
   cc := TBits.RotateLeft32(cc, 10);
-  ee := ee + (data[14] + C1 + (aa xor (bb or not cc)));
+  ee := ee + (LData[14] + C1 + (aa xor (bb or not cc)));
   ee := TBits.RotateLeft32(ee, 9) + dd;
   bb := TBits.RotateLeft32(bb, 10);
-  dd := dd + (data[7] + C1 + (ee xor (aa or not bb)));
+  dd := dd + (LData[7] + C1 + (ee xor (aa or not bb)));
   dd := TBits.RotateLeft32(dd, 9) + cc;
   aa := TBits.RotateLeft32(aa, 10);
-  cc := cc + (data[0] + C1 + (dd xor (ee or not aa)));
+  cc := cc + (LData[0] + C1 + (dd xor (ee or not aa)));
   cc := TBits.RotateLeft32(cc, 11) + bb;
   ee := TBits.RotateLeft32(ee, 10);
-  bb := bb + (data[9] + C1 + (cc xor (dd or not ee)));
+  bb := bb + (LData[9] + C1 + (cc xor (dd or not ee)));
   bb := TBits.RotateLeft32(bb, 13) + aa;
   dd := TBits.RotateLeft32(dd, 10);
-  aa := aa + (data[2] + C1 + (bb xor (cc or not dd)));
+  aa := aa + (LData[2] + C1 + (bb xor (cc or not dd)));
   aa := TBits.RotateLeft32(aa, 15) + ee;
   cc := TBits.RotateLeft32(cc, 10);
-  ee := ee + (data[11] + C1 + (aa xor (bb or not cc)));
+  ee := ee + (LData[11] + C1 + (aa xor (bb or not cc)));
   ee := TBits.RotateLeft32(ee, 15) + dd;
   bb := TBits.RotateLeft32(bb, 10);
-  dd := dd + (data[4] + C1 + (ee xor (aa or not bb)));
+  dd := dd + (LData[4] + C1 + (ee xor (aa or not bb)));
   dd := TBits.RotateLeft32(dd, 5) + cc;
   aa := TBits.RotateLeft32(aa, 10);
-  cc := cc + (data[13] + C1 + (dd xor (ee or not aa)));
+  cc := cc + (LData[13] + C1 + (dd xor (ee or not aa)));
   cc := TBits.RotateLeft32(cc, 7) + bb;
   ee := TBits.RotateLeft32(ee, 10);
-  bb := bb + (data[6] + C1 + (cc xor (dd or not ee)));
+  bb := bb + (LData[6] + C1 + (cc xor (dd or not ee)));
   bb := TBits.RotateLeft32(bb, 7) + aa;
   dd := TBits.RotateLeft32(dd, 10);
-  aa := aa + (data[15] + C1 + (bb xor (cc or not dd)));
+  aa := aa + (LData[15] + C1 + (bb xor (cc or not dd)));
   aa := TBits.RotateLeft32(aa, 8) + ee;
   cc := TBits.RotateLeft32(cc, 10);
-  ee := ee + (data[8] + C1 + (aa xor (bb or not cc)));
+  ee := ee + (LData[8] + C1 + (aa xor (bb or not cc)));
   ee := TBits.RotateLeft32(ee, 11) + dd;
   bb := TBits.RotateLeft32(bb, 10);
-  dd := dd + (data[1] + C1 + (ee xor (aa or not bb)));
+  dd := dd + (LData[1] + C1 + (ee xor (aa or not bb)));
   dd := TBits.RotateLeft32(dd, 14) + cc;
   aa := TBits.RotateLeft32(aa, 10);
-  cc := cc + (data[10] + C1 + (dd xor (ee or not aa)));
+  cc := cc + (LData[10] + C1 + (dd xor (ee or not aa)));
   cc := TBits.RotateLeft32(cc, 14) + bb;
   ee := TBits.RotateLeft32(ee, 10);
-  bb := bb + (data[3] + C1 + (cc xor (dd or not ee)));
+  bb := bb + (LData[3] + C1 + (cc xor (dd or not ee)));
   bb := TBits.RotateLeft32(bb, 12) + aa;
   dd := TBits.RotateLeft32(dd, 10);
-  aa := aa + (data[12] + C1 + (bb xor (cc or not dd)));
+  aa := aa + (LData[12] + C1 + (bb xor (cc or not dd)));
   aa := TBits.RotateLeft32(aa, 6) + ee;
   cc := TBits.RotateLeft32(cc, 10);
 
-  e := e + (data[7] + C2 + ((a and b) or (not a and c)));
+  e := e + (LData[7] + C2 + ((a and b) or (not a and c)));
   e := TBits.RotateLeft32(e, 7) + d;
   b := TBits.RotateLeft32(b, 10);
-  d := d + (data[4] + C2 + ((e and a) or (not e and b)));
+  d := d + (LData[4] + C2 + ((e and a) or (not e and b)));
   d := TBits.RotateLeft32(d, 6) + c;
   a := TBits.RotateLeft32(a, 10);
-  c := c + (data[13] + C2 + ((d and e) or (not d and a)));
+  c := c + (LData[13] + C2 + ((d and e) or (not d and a)));
   c := TBits.RotateLeft32(c, 8) + b;
   e := TBits.RotateLeft32(e, 10);
-  b := b + (data[1] + C2 + ((c and d) or (not c and e)));
+  b := b + (LData[1] + C2 + ((c and d) or (not c and e)));
   b := TBits.RotateLeft32(b, 13) + a;
   d := TBits.RotateLeft32(d, 10);
-  a := a + (data[10] + C2 + ((b and c) or (not b and d)));
+  a := a + (LData[10] + C2 + ((b and c) or (not b and d)));
   a := TBits.RotateLeft32(a, 11) + e;
   c := TBits.RotateLeft32(c, 10);
-  e := e + (data[6] + C2 + ((a and b) or (not a and c)));
+  e := e + (LData[6] + C2 + ((a and b) or (not a and c)));
   e := TBits.RotateLeft32(e, 9) + d;
   b := TBits.RotateLeft32(b, 10);
-  d := d + (data[15] + C2 + ((e and a) or (not e and b)));
+  d := d + (LData[15] + C2 + ((e and a) or (not e and b)));
   d := TBits.RotateLeft32(d, 7) + c;
   a := TBits.RotateLeft32(a, 10);
-  c := c + (data[3] + C2 + ((d and e) or (not d and a)));
+  c := c + (LData[3] + C2 + ((d and e) or (not d and a)));
   c := TBits.RotateLeft32(c, 15) + b;
   e := TBits.RotateLeft32(e, 10);
-  b := b + (data[12] + C2 + ((c and d) or (not c and e)));
+  b := b + (LData[12] + C2 + ((c and d) or (not c and e)));
   b := TBits.RotateLeft32(b, 7) + a;
   d := TBits.RotateLeft32(d, 10);
-  a := a + (data[0] + C2 + ((b and c) or (not b and d)));
+  a := a + (LData[0] + C2 + ((b and c) or (not b and d)));
   a := TBits.RotateLeft32(a, 12) + e;
   c := TBits.RotateLeft32(c, 10);
-  e := e + (data[9] + C2 + ((a and b) or (not a and c)));
+  e := e + (LData[9] + C2 + ((a and b) or (not a and c)));
   e := TBits.RotateLeft32(e, 15) + d;
   b := TBits.RotateLeft32(b, 10);
-  d := d + (data[5] + C2 + ((e and a) or (not e and b)));
+  d := d + (LData[5] + C2 + ((e and a) or (not e and b)));
   d := TBits.RotateLeft32(d, 9) + c;
   a := TBits.RotateLeft32(a, 10);
-  c := c + (data[2] + C2 + ((d and e) or (not d and a)));
+  c := c + (LData[2] + C2 + ((d and e) or (not d and a)));
   c := TBits.RotateLeft32(c, 11) + b;
   e := TBits.RotateLeft32(e, 10);
-  b := b + (data[14] + C2 + ((c and d) or (not c and e)));
+  b := b + (LData[14] + C2 + ((c and d) or (not c and e)));
   b := TBits.RotateLeft32(b, 7) + a;
   d := TBits.RotateLeft32(d, 10);
-  a := a + (data[11] + C2 + ((b and c) or (not b and d)));
+  a := a + (LData[11] + C2 + ((b and c) or (not b and d)));
   a := TBits.RotateLeft32(a, 13) + e;
   c := TBits.RotateLeft32(c, 10);
-  e := e + (data[8] + C2 + ((a and b) or (not a and c)));
+  e := e + (LData[8] + C2 + ((a and b) or (not a and c)));
   e := TBits.RotateLeft32(e, 12) + d;
   b := TBits.RotateLeft32(b, 10);
 
-  ee := ee + (data[6] + C3 + ((aa and cc) or (bb and not cc)));
+  ee := ee + (LData[6] + C3 + ((aa and cc) or (bb and not cc)));
   ee := TBits.RotateLeft32(ee, 9) + dd;
   bb := TBits.RotateLeft32(bb, 10);
-  dd := dd + (data[11] + C3 + ((ee and bb) or (aa and not bb)));
+  dd := dd + (LData[11] + C3 + ((ee and bb) or (aa and not bb)));
   dd := TBits.RotateLeft32(dd, 13) + cc;
   aa := TBits.RotateLeft32(aa, 10);
-  cc := cc + (data[3] + C3 + ((dd and aa) or (ee and not aa)));
+  cc := cc + (LData[3] + C3 + ((dd and aa) or (ee and not aa)));
   cc := TBits.RotateLeft32(cc, 15) + bb;
   ee := TBits.RotateLeft32(ee, 10);
-  bb := bb + (data[7] + C3 + ((cc and ee) or (dd and not ee)));
+  bb := bb + (LData[7] + C3 + ((cc and ee) or (dd and not ee)));
   bb := TBits.RotateLeft32(bb, 7) + aa;
   dd := TBits.RotateLeft32(dd, 10);
-  aa := aa + (data[0] + C3 + ((bb and dd) or (cc and not dd)));
+  aa := aa + (LData[0] + C3 + ((bb and dd) or (cc and not dd)));
   aa := TBits.RotateLeft32(aa, 12) + ee;
   cc := TBits.RotateLeft32(cc, 10);
-  ee := ee + (data[13] + C3 + ((aa and cc) or (bb and not cc)));
+  ee := ee + (LData[13] + C3 + ((aa and cc) or (bb and not cc)));
   ee := TBits.RotateLeft32(ee, 8) + dd;
   bb := TBits.RotateLeft32(bb, 10);
-  dd := dd + (data[5] + C3 + ((ee and bb) or (aa and not bb)));
+  dd := dd + (LData[5] + C3 + ((ee and bb) or (aa and not bb)));
   dd := TBits.RotateLeft32(dd, 9) + cc;
   aa := TBits.RotateLeft32(aa, 10);
-  cc := cc + (data[10] + C3 + ((dd and aa) or (ee and not aa)));
+  cc := cc + (LData[10] + C3 + ((dd and aa) or (ee and not aa)));
   cc := TBits.RotateLeft32(cc, 11) + bb;
   ee := TBits.RotateLeft32(ee, 10);
-  bb := bb + (data[14] + C3 + ((cc and ee) or (dd and not ee)));
+  bb := bb + (LData[14] + C3 + ((cc and ee) or (dd and not ee)));
   bb := TBits.RotateLeft32(bb, 7) + aa;
   dd := TBits.RotateLeft32(dd, 10);
-  aa := aa + (data[15] + C3 + ((bb and dd) or (cc and not dd)));
+  aa := aa + (LData[15] + C3 + ((bb and dd) or (cc and not dd)));
   aa := TBits.RotateLeft32(aa, 7) + ee;
   cc := TBits.RotateLeft32(cc, 10);
-  ee := ee + (data[8] + C3 + ((aa and cc) or (bb and not cc)));
+  ee := ee + (LData[8] + C3 + ((aa and cc) or (bb and not cc)));
   ee := TBits.RotateLeft32(ee, 12) + dd;
   bb := TBits.RotateLeft32(bb, 10);
-  dd := dd + (data[12] + C3 + ((ee and bb) or (aa and not bb)));
+  dd := dd + (LData[12] + C3 + ((ee and bb) or (aa and not bb)));
   dd := TBits.RotateLeft32(dd, 7) + cc;
   aa := TBits.RotateLeft32(aa, 10);
-  cc := cc + (data[4] + C3 + ((dd and aa) or (ee and not aa)));
+  cc := cc + (LData[4] + C3 + ((dd and aa) or (ee and not aa)));
   cc := TBits.RotateLeft32(cc, 6) + bb;
   ee := TBits.RotateLeft32(ee, 10);
-  bb := bb + (data[9] + C3 + ((cc and ee) or (dd and not ee)));
+  bb := bb + (LData[9] + C3 + ((cc and ee) or (dd and not ee)));
   bb := TBits.RotateLeft32(bb, 15) + aa;
   dd := TBits.RotateLeft32(dd, 10);
-  aa := aa + (data[1] + C3 + ((bb and dd) or (cc and not dd)));
+  aa := aa + (LData[1] + C3 + ((bb and dd) or (cc and not dd)));
   aa := TBits.RotateLeft32(aa, 13) + ee;
   cc := TBits.RotateLeft32(cc, 10);
-  ee := ee + (data[2] + C3 + ((aa and cc) or (bb and not cc)));
+  ee := ee + (LData[2] + C3 + ((aa and cc) or (bb and not cc)));
   ee := TBits.RotateLeft32(ee, 11) + dd;
   bb := TBits.RotateLeft32(bb, 10);
 
-  d := d + (data[3] + C4 + ((e or not a) xor b));
+  d := d + (LData[3] + C4 + ((e or not a) xor b));
   d := TBits.RotateLeft32(d, 11) + c;
   a := TBits.RotateLeft32(a, 10);
-  c := c + (data[10] + C4 + ((d or not e) xor a));
+  c := c + (LData[10] + C4 + ((d or not e) xor a));
   c := TBits.RotateLeft32(c, 13) + b;
   e := TBits.RotateLeft32(e, 10);
-  b := b + (data[14] + C4 + ((c or not d) xor e));
+  b := b + (LData[14] + C4 + ((c or not d) xor e));
   b := TBits.RotateLeft32(b, 6) + a;
   d := TBits.RotateLeft32(d, 10);
-  a := a + (data[4] + C4 + ((b or not c) xor d));
+  a := a + (LData[4] + C4 + ((b or not c) xor d));
   a := TBits.RotateLeft32(a, 7) + e;
   c := TBits.RotateLeft32(c, 10);
-  e := e + (data[9] + C4 + ((a or not b) xor c));
+  e := e + (LData[9] + C4 + ((a or not b) xor c));
   e := TBits.RotateLeft32(e, 14) + d;
   b := TBits.RotateLeft32(b, 10);
-  d := d + (data[15] + C4 + ((e or not a) xor b));
+  d := d + (LData[15] + C4 + ((e or not a) xor b));
   d := TBits.RotateLeft32(d, 9) + c;
   a := TBits.RotateLeft32(a, 10);
-  c := c + (data[8] + C4 + ((d or not e) xor a));
+  c := c + (LData[8] + C4 + ((d or not e) xor a));
   c := TBits.RotateLeft32(c, 13) + b;
   e := TBits.RotateLeft32(e, 10);
-  b := b + (data[1] + C4 + ((c or not d) xor e));
+  b := b + (LData[1] + C4 + ((c or not d) xor e));
   b := TBits.RotateLeft32(b, 15) + a;
   d := TBits.RotateLeft32(d, 10);
-  a := a + (data[2] + C4 + ((b or not c) xor d));
+  a := a + (LData[2] + C4 + ((b or not c) xor d));
   a := TBits.RotateLeft32(a, 14) + e;
   c := TBits.RotateLeft32(c, 10);
-  e := e + (data[7] + C4 + ((a or not b) xor c));
+  e := e + (LData[7] + C4 + ((a or not b) xor c));
   e := TBits.RotateLeft32(e, 8) + d;
   b := TBits.RotateLeft32(b, 10);
-  d := d + (data[0] + C4 + ((e or not a) xor b));
+  d := d + (LData[0] + C4 + ((e or not a) xor b));
   d := TBits.RotateLeft32(d, 13) + c;
   a := TBits.RotateLeft32(a, 10);
-  c := c + (data[6] + C4 + ((d or not e) xor a));
+  c := c + (LData[6] + C4 + ((d or not e) xor a));
   c := TBits.RotateLeft32(c, 6) + b;
   e := TBits.RotateLeft32(e, 10);
-  b := b + (data[13] + C4 + ((c or not d) xor e));
+  b := b + (LData[13] + C4 + ((c or not d) xor e));
   b := TBits.RotateLeft32(b, 5) + a;
   d := TBits.RotateLeft32(d, 10);
-  a := a + (data[11] + C4 + ((b or not c) xor d));
+  a := a + (LData[11] + C4 + ((b or not c) xor d));
   a := TBits.RotateLeft32(a, 12) + e;
   c := TBits.RotateLeft32(c, 10);
-  e := e + (data[5] + C4 + ((a or not b) xor c));
+  e := e + (LData[5] + C4 + ((a or not b) xor c));
   e := TBits.RotateLeft32(e, 7) + d;
   b := TBits.RotateLeft32(b, 10);
-  d := d + (data[12] + C4 + ((e or not a) xor b));
+  d := d + (LData[12] + C4 + ((e or not a) xor b));
   d := TBits.RotateLeft32(d, 5) + c;
   a := TBits.RotateLeft32(a, 10);
 
-  dd := dd + (data[15] + C5 + ((ee or not aa) xor bb));
+  dd := dd + (LData[15] + C5 + ((ee or not aa) xor bb));
   dd := TBits.RotateLeft32(dd, 9) + cc;
   aa := TBits.RotateLeft32(aa, 10);
-  cc := cc + (data[5] + C5 + ((dd or not ee) xor aa));
+  cc := cc + (LData[5] + C5 + ((dd or not ee) xor aa));
   cc := TBits.RotateLeft32(cc, 7) + bb;
   ee := TBits.RotateLeft32(ee, 10);
-  bb := bb + (data[1] + C5 + ((cc or not dd) xor ee));
+  bb := bb + (LData[1] + C5 + ((cc or not dd) xor ee));
   bb := TBits.RotateLeft32(bb, 15) + aa;
   dd := TBits.RotateLeft32(dd, 10);
-  aa := aa + (data[3] + C5 + ((bb or not cc) xor dd));
+  aa := aa + (LData[3] + C5 + ((bb or not cc) xor dd));
   aa := TBits.RotateLeft32(aa, 11) + ee;
   cc := TBits.RotateLeft32(cc, 10);
-  ee := ee + (data[7] + C5 + ((aa or not bb) xor cc));
+  ee := ee + (LData[7] + C5 + ((aa or not bb) xor cc));
   ee := TBits.RotateLeft32(ee, 8) + dd;
   bb := TBits.RotateLeft32(bb, 10);
-  dd := dd + (data[14] + C5 + ((ee or not aa) xor bb));
+  dd := dd + (LData[14] + C5 + ((ee or not aa) xor bb));
   dd := TBits.RotateLeft32(dd, 6) + cc;
   aa := TBits.RotateLeft32(aa, 10);
-  cc := cc + (data[6] + C5 + ((dd or not ee) xor aa));
+  cc := cc + (LData[6] + C5 + ((dd or not ee) xor aa));
   cc := TBits.RotateLeft32(cc, 6) + bb;
   ee := TBits.RotateLeft32(ee, 10);
-  bb := bb + (data[9] + C5 + ((cc or not dd) xor ee));
+  bb := bb + (LData[9] + C5 + ((cc or not dd) xor ee));
   bb := TBits.RotateLeft32(bb, 14) + aa;
   dd := TBits.RotateLeft32(dd, 10);
-  aa := aa + (data[11] + C5 + ((bb or not cc) xor dd));
+  aa := aa + (LData[11] + C5 + ((bb or not cc) xor dd));
   aa := TBits.RotateLeft32(aa, 12) + ee;
   cc := TBits.RotateLeft32(cc, 10);
-  ee := ee + (data[8] + C5 + ((aa or not bb) xor cc));
+  ee := ee + (LData[8] + C5 + ((aa or not bb) xor cc));
   ee := TBits.RotateLeft32(ee, 13) + dd;
   bb := TBits.RotateLeft32(bb, 10);
-  dd := dd + (data[12] + C5 + ((ee or not aa) xor bb));
+  dd := dd + (LData[12] + C5 + ((ee or not aa) xor bb));
   dd := TBits.RotateLeft32(dd, 5) + cc;
   aa := TBits.RotateLeft32(aa, 10);
-  cc := cc + (data[2] + C5 + ((dd or not ee) xor aa));
+  cc := cc + (LData[2] + C5 + ((dd or not ee) xor aa));
   cc := TBits.RotateLeft32(cc, 14) + bb;
   ee := TBits.RotateLeft32(ee, 10);
-  bb := bb + (data[10] + C5 + ((cc or not dd) xor ee));
+  bb := bb + (LData[10] + C5 + ((cc or not dd) xor ee));
   bb := TBits.RotateLeft32(bb, 13) + aa;
   dd := TBits.RotateLeft32(dd, 10);
-  aa := aa + (data[0] + C5 + ((bb or not cc) xor dd));
+  aa := aa + (LData[0] + C5 + ((bb or not cc) xor dd));
   aa := TBits.RotateLeft32(aa, 13) + ee;
   cc := TBits.RotateLeft32(cc, 10);
-  ee := ee + (data[4] + C5 + ((aa or not bb) xor cc));
+  ee := ee + (LData[4] + C5 + ((aa or not bb) xor cc));
   ee := TBits.RotateLeft32(ee, 7) + dd;
   bb := TBits.RotateLeft32(bb, 10);
-  dd := dd + (data[13] + C5 + ((ee or not aa) xor bb));
+  dd := dd + (LData[13] + C5 + ((ee or not aa) xor bb));
   dd := TBits.RotateLeft32(dd, 5) + cc;
   aa := TBits.RotateLeft32(aa, 10);
 
-  c := c + (data[1] + C6 + ((d and a) or (e and not a)));
+  c := c + (LData[1] + C6 + ((d and a) or (e and not a)));
   c := TBits.RotateLeft32(c, 11) + b;
   e := TBits.RotateLeft32(e, 10);
-  b := b + (data[9] + C6 + ((c and e) or (d and not e)));
+  b := b + (LData[9] + C6 + ((c and e) or (d and not e)));
   b := TBits.RotateLeft32(b, 12) + a;
   d := TBits.RotateLeft32(d, 10);
-  a := a + (data[11] + C6 + ((b and d) or (c and not d)));
+  a := a + (LData[11] + C6 + ((b and d) or (c and not d)));
   a := TBits.RotateLeft32(a, 14) + e;
   c := TBits.RotateLeft32(c, 10);
-  e := e + (data[10] + C6 + ((a and c) or (b and not c)));
+  e := e + (LData[10] + C6 + ((a and c) or (b and not c)));
   e := TBits.RotateLeft32(e, 15) + d;
   b := TBits.RotateLeft32(b, 10);
-  d := d + (data[0] + C6 + ((e and b) or (a and not b)));
+  d := d + (LData[0] + C6 + ((e and b) or (a and not b)));
   d := TBits.RotateLeft32(d, 14) + c;
   a := TBits.RotateLeft32(a, 10);
-  c := c + (data[8] + C6 + ((d and a) or (e and not a)));
+  c := c + (LData[8] + C6 + ((d and a) or (e and not a)));
   c := TBits.RotateLeft32(c, 15) + b;
   e := TBits.RotateLeft32(e, 10);
-  b := b + (data[12] + C6 + ((c and e) or (d and not e)));
+  b := b + (LData[12] + C6 + ((c and e) or (d and not e)));
   b := TBits.RotateLeft32(b, 9) + a;
   d := TBits.RotateLeft32(d, 10);
-  a := a + (data[4] + C6 + ((b and d) or (c and not d)));
+  a := a + (LData[4] + C6 + ((b and d) or (c and not d)));
   a := TBits.RotateLeft32(a, 8) + e;
   c := TBits.RotateLeft32(c, 10);
-  e := e + (data[13] + C6 + ((a and c) or (b and not c)));
+  e := e + (LData[13] + C6 + ((a and c) or (b and not c)));
   e := TBits.RotateLeft32(e, 9) + d;
   b := TBits.RotateLeft32(b, 10);
-  d := d + (data[3] + C6 + ((e and b) or (a and not b)));
+  d := d + (LData[3] + C6 + ((e and b) or (a and not b)));
   d := TBits.RotateLeft32(d, 14) + c;
   a := TBits.RotateLeft32(a, 10);
-  c := c + (data[7] + C6 + ((d and a) or (e and not a)));
+  c := c + (LData[7] + C6 + ((d and a) or (e and not a)));
   c := TBits.RotateLeft32(c, 5) + b;
   e := TBits.RotateLeft32(e, 10);
-  b := b + (data[15] + C6 + ((c and e) or (d and not e)));
+  b := b + (LData[15] + C6 + ((c and e) or (d and not e)));
   b := TBits.RotateLeft32(b, 6) + a;
   d := TBits.RotateLeft32(d, 10);
-  a := a + (data[14] + C6 + ((b and d) or (c and not d)));
+  a := a + (LData[14] + C6 + ((b and d) or (c and not d)));
   a := TBits.RotateLeft32(a, 8) + e;
   c := TBits.RotateLeft32(c, 10);
-  e := e + (data[5] + C6 + ((a and c) or (b and not c)));
+  e := e + (LData[5] + C6 + ((a and c) or (b and not c)));
   e := TBits.RotateLeft32(e, 6) + d;
   b := TBits.RotateLeft32(b, 10);
-  d := d + (data[6] + C6 + ((e and b) or (a and not b)));
+  d := d + (LData[6] + C6 + ((e and b) or (a and not b)));
   d := TBits.RotateLeft32(d, 5) + c;
   a := TBits.RotateLeft32(a, 10);
-  c := c + (data[2] + C6 + ((d and a) or (e and not a)));
+  c := c + (LData[2] + C6 + ((d and a) or (e and not a)));
   c := TBits.RotateLeft32(c, 12) + b;
   e := TBits.RotateLeft32(e, 10);
 
-  cc := cc + (data[8] + C7 + ((dd and ee) or (not dd and aa)));
+  cc := cc + (LData[8] + C7 + ((dd and ee) or (not dd and aa)));
   cc := TBits.RotateLeft32(cc, 15) + bb;
   ee := TBits.RotateLeft32(ee, 10);
-  bb := bb + (data[6] + C7 + ((cc and dd) or (not cc and ee)));
+  bb := bb + (LData[6] + C7 + ((cc and dd) or (not cc and ee)));
   bb := TBits.RotateLeft32(bb, 5) + aa;
   dd := TBits.RotateLeft32(dd, 10);
-  aa := aa + (data[4] + C7 + ((bb and cc) or (not bb and dd)));
+  aa := aa + (LData[4] + C7 + ((bb and cc) or (not bb and dd)));
   aa := TBits.RotateLeft32(aa, 8) + ee;
   cc := TBits.RotateLeft32(cc, 10);
-  ee := ee + (data[1] + C7 + ((aa and bb) or (not aa and cc)));
+  ee := ee + (LData[1] + C7 + ((aa and bb) or (not aa and cc)));
   ee := TBits.RotateLeft32(ee, 11) + dd;
   bb := TBits.RotateLeft32(bb, 10);
-  dd := dd + (data[3] + C7 + ((ee and aa) or (not ee and bb)));
+  dd := dd + (LData[3] + C7 + ((ee and aa) or (not ee and bb)));
   dd := TBits.RotateLeft32(dd, 14) + cc;
   aa := TBits.RotateLeft32(aa, 10);
-  cc := cc + (data[11] + C7 + ((dd and ee) or (not dd and aa)));
+  cc := cc + (LData[11] + C7 + ((dd and ee) or (not dd and aa)));
   cc := TBits.RotateLeft32(cc, 14) + bb;
   ee := TBits.RotateLeft32(ee, 10);
-  bb := bb + (data[15] + C7 + ((cc and dd) or (not cc and ee)));
+  bb := bb + (LData[15] + C7 + ((cc and dd) or (not cc and ee)));
   bb := TBits.RotateLeft32(bb, 6) + aa;
   dd := TBits.RotateLeft32(dd, 10);
-  aa := aa + (data[0] + C7 + ((bb and cc) or (not bb and dd)));
+  aa := aa + (LData[0] + C7 + ((bb and cc) or (not bb and dd)));
   aa := TBits.RotateLeft32(aa, 14) + ee;
   cc := TBits.RotateLeft32(cc, 10);
-  ee := ee + (data[5] + C7 + ((aa and bb) or (not aa and cc)));
+  ee := ee + (LData[5] + C7 + ((aa and bb) or (not aa and cc)));
   ee := TBits.RotateLeft32(ee, 6) + dd;
   bb := TBits.RotateLeft32(bb, 10);
-  dd := dd + (data[12] + C7 + ((ee and aa) or (not ee and bb)));
+  dd := dd + (LData[12] + C7 + ((ee and aa) or (not ee and bb)));
   dd := TBits.RotateLeft32(dd, 9) + cc;
   aa := TBits.RotateLeft32(aa, 10);
-  cc := cc + (data[2] + C7 + ((dd and ee) or (not dd and aa)));
+  cc := cc + (LData[2] + C7 + ((dd and ee) or (not dd and aa)));
   cc := TBits.RotateLeft32(cc, 12) + bb;
   ee := TBits.RotateLeft32(ee, 10);
-  bb := bb + (data[13] + C7 + ((cc and dd) or (not cc and ee)));
+  bb := bb + (LData[13] + C7 + ((cc and dd) or (not cc and ee)));
   bb := TBits.RotateLeft32(bb, 9) + aa;
   dd := TBits.RotateLeft32(dd, 10);
-  aa := aa + (data[9] + C7 + ((bb and cc) or (not bb and dd)));
+  aa := aa + (LData[9] + C7 + ((bb and cc) or (not bb and dd)));
   aa := TBits.RotateLeft32(aa, 12) + ee;
   cc := TBits.RotateLeft32(cc, 10);
-  ee := ee + (data[7] + C7 + ((aa and bb) or (not aa and cc)));
+  ee := ee + (LData[7] + C7 + ((aa and bb) or (not aa and cc)));
   ee := TBits.RotateLeft32(ee, 5) + dd;
   bb := TBits.RotateLeft32(bb, 10);
-  dd := dd + (data[10] + C7 + ((ee and aa) or (not ee and bb)));
+  dd := dd + (LData[10] + C7 + ((ee and aa) or (not ee and bb)));
   dd := TBits.RotateLeft32(dd, 15) + cc;
   aa := TBits.RotateLeft32(aa, 10);
-  cc := cc + (data[14] + C7 + ((dd and ee) or (not dd and aa)));
+  cc := cc + (LData[14] + C7 + ((dd and ee) or (not dd and aa)));
   cc := TBits.RotateLeft32(cc, 8) + bb;
   ee := TBits.RotateLeft32(ee, 10);
 
-  b := b + (data[4] + C8 + (c xor (d or not e)));
+  b := b + (LData[4] + C8 + (c xor (d or not e)));
   b := TBits.RotateLeft32(b, 9) + a;
   d := TBits.RotateLeft32(d, 10);
-  a := a + (data[0] + C8 + (b xor (c or not d)));
+  a := a + (LData[0] + C8 + (b xor (c or not d)));
   a := TBits.RotateLeft32(a, 15) + e;
   c := TBits.RotateLeft32(c, 10);
-  e := e + (data[5] + C8 + (a xor (b or not c)));
+  e := e + (LData[5] + C8 + (a xor (b or not c)));
   e := TBits.RotateLeft32(e, 5) + d;
   b := TBits.RotateLeft32(b, 10);
-  d := d + (data[9] + C8 + (e xor (a or not b)));
+  d := d + (LData[9] + C8 + (e xor (a or not b)));
   d := TBits.RotateLeft32(d, 11) + c;
   a := TBits.RotateLeft32(a, 10);
-  c := c + (data[7] + C8 + (d xor (e or not a)));
+  c := c + (LData[7] + C8 + (d xor (e or not a)));
   c := TBits.RotateLeft32(c, 6) + b;
   e := TBits.RotateLeft32(e, 10);
-  b := b + (data[12] + C8 + (c xor (d or not e)));
+  b := b + (LData[12] + C8 + (c xor (d or not e)));
   b := TBits.RotateLeft32(b, 8) + a;
   d := TBits.RotateLeft32(d, 10);
-  a := a + (data[2] + C8 + (b xor (c or not d)));
+  a := a + (LData[2] + C8 + (b xor (c or not d)));
   a := TBits.RotateLeft32(a, 13) + e;
   c := TBits.RotateLeft32(c, 10);
-  e := e + (data[10] + C8 + (a xor (b or not c)));
+  e := e + (LData[10] + C8 + (a xor (b or not c)));
   e := TBits.RotateLeft32(e, 12) + d;
   b := TBits.RotateLeft32(b, 10);
-  d := d + (data[14] + C8 + (e xor (a or not b)));
+  d := d + (LData[14] + C8 + (e xor (a or not b)));
   d := TBits.RotateLeft32(d, 5) + c;
   a := TBits.RotateLeft32(a, 10);
-  c := c + (data[1] + C8 + (d xor (e or not a)));
+  c := c + (LData[1] + C8 + (d xor (e or not a)));
   c := TBits.RotateLeft32(c, 12) + b;
   e := TBits.RotateLeft32(e, 10);
-  b := b + (data[3] + C8 + (c xor (d or not e)));
+  b := b + (LData[3] + C8 + (c xor (d or not e)));
   b := TBits.RotateLeft32(b, 13) + a;
   d := TBits.RotateLeft32(d, 10);
-  a := a + (data[8] + C8 + (b xor (c or not d)));
+  a := a + (LData[8] + C8 + (b xor (c or not d)));
   a := TBits.RotateLeft32(a, 14) + e;
   c := TBits.RotateLeft32(c, 10);
-  e := e + (data[11] + C8 + (a xor (b or not c)));
+  e := e + (LData[11] + C8 + (a xor (b or not c)));
   e := TBits.RotateLeft32(e, 11) + d;
   b := TBits.RotateLeft32(b, 10);
-  d := d + (data[6] + C8 + (e xor (a or not b)));
+  d := d + (LData[6] + C8 + (e xor (a or not b)));
   d := TBits.RotateLeft32(d, 8) + c;
   a := TBits.RotateLeft32(a, 10);
-  c := c + (data[15] + C8 + (d xor (e or not a)));
+  c := c + (LData[15] + C8 + (d xor (e or not a)));
   c := TBits.RotateLeft32(c, 5) + b;
   e := TBits.RotateLeft32(e, 10);
-  b := b + (data[13] + C8 + (c xor (d or not e)));
+  b := b + (LData[13] + C8 + (c xor (d or not e)));
   b := TBits.RotateLeft32(b, 6) + a;
   d := TBits.RotateLeft32(d, 10);
 
-  bb := bb + (data[12] + (cc xor dd xor ee));
+  bb := bb + (LData[12] + (cc xor dd xor ee));
   bb := TBits.RotateLeft32(bb, 8) + aa;
   dd := TBits.RotateLeft32(dd, 10);
-  aa := aa + (data[15] + (bb xor cc xor dd));
+  aa := aa + (LData[15] + (bb xor cc xor dd));
   aa := TBits.RotateLeft32(aa, 5) + ee;
   cc := TBits.RotateLeft32(cc, 10);
-  ee := ee + (data[10] + (aa xor bb xor cc));
+  ee := ee + (LData[10] + (aa xor bb xor cc));
   ee := TBits.RotateLeft32(ee, 12) + dd;
   bb := TBits.RotateLeft32(bb, 10);
-  dd := dd + (data[4] + (ee xor aa xor bb));
+  dd := dd + (LData[4] + (ee xor aa xor bb));
   dd := TBits.RotateLeft32(dd, 9) + cc;
   aa := TBits.RotateLeft32(aa, 10);
-  cc := cc + (data[1] + (dd xor ee xor aa));
+  cc := cc + (LData[1] + (dd xor ee xor aa));
   cc := TBits.RotateLeft32(cc, 12) + bb;
   ee := TBits.RotateLeft32(ee, 10);
-  bb := bb + (data[5] + (cc xor dd xor ee));
+  bb := bb + (LData[5] + (cc xor dd xor ee));
   bb := TBits.RotateLeft32(bb, 5) + aa;
   dd := TBits.RotateLeft32(dd, 10);
-  aa := aa + (data[8] + (bb xor cc xor dd));
+  aa := aa + (LData[8] + (bb xor cc xor dd));
   aa := TBits.RotateLeft32(aa, 14) + ee;
   cc := TBits.RotateLeft32(cc, 10);
-  ee := ee + (data[7] + (aa xor bb xor cc));
+  ee := ee + (LData[7] + (aa xor bb xor cc));
   ee := TBits.RotateLeft32(ee, 6) + dd;
   bb := TBits.RotateLeft32(bb, 10);
-  dd := dd + (data[6] + (ee xor aa xor bb));
+  dd := dd + (LData[6] + (ee xor aa xor bb));
   dd := TBits.RotateLeft32(dd, 8) + cc;
   aa := TBits.RotateLeft32(aa, 10);
-  cc := cc + (data[2] + (dd xor ee xor aa));
+  cc := cc + (LData[2] + (dd xor ee xor aa));
   cc := TBits.RotateLeft32(cc, 13) + bb;
   ee := TBits.RotateLeft32(ee, 10);
-  bb := bb + (data[13] + (cc xor dd xor ee));
+  bb := bb + (LData[13] + (cc xor dd xor ee));
   bb := TBits.RotateLeft32(bb, 6) + aa;
   dd := TBits.RotateLeft32(dd, 10);
-  aa := aa + (data[14] + (bb xor cc xor dd));
+  aa := aa + (LData[14] + (bb xor cc xor dd));
   aa := TBits.RotateLeft32(aa, 5) + ee;
   cc := TBits.RotateLeft32(cc, 10);
-  ee := ee + (data[0] + (aa xor bb xor cc));
+  ee := ee + (LData[0] + (aa xor bb xor cc));
   ee := TBits.RotateLeft32(ee, 15) + dd;
   bb := TBits.RotateLeft32(bb, 10);
-  dd := dd + (data[3] + (ee xor aa xor bb));
+  dd := dd + (LData[3] + (ee xor aa xor bb));
   dd := TBits.RotateLeft32(dd, 13) + cc;
   aa := TBits.RotateLeft32(aa, 10);
-  cc := cc + (data[9] + (dd xor ee xor aa));
+  cc := cc + (LData[9] + (dd xor ee xor aa));
   cc := TBits.RotateLeft32(cc, 11) + bb;
   ee := TBits.RotateLeft32(ee, 10);
-  bb := bb + (data[11] + (cc xor dd xor ee));
+  bb := bb + (LData[11] + (cc xor dd xor ee));
   bb := TBits.RotateLeft32(bb, 11) + aa;
   dd := TBits.RotateLeft32(dd, 10);
 
-  dd := dd + c + Fm_state[1];
-  Fm_state[1] := Fm_state[2] + d + ee;
-  Fm_state[2] := Fm_state[3] + e + aa;
-  Fm_state[3] := Fm_state[4] + a + bb;
-  Fm_state[4] := Fm_state[0] + b + cc;
-  Fm_state[0] := dd;
-
-  System.FillChar(data, System.SizeOf(data), UInt32(0));
+  dd := dd + c + FState[1];
+  FState[1] := FState[2] + d + ee;
+  FState[2] := FState[3] + e + aa;
+  FState[3] := FState[4] + a + bb;
+  FState[4] := FState[0] + b + cc;
+  FState[0] := dd;
 
+  System.FillChar(LData, System.SizeOf(LData), UInt32(0));
 end;
 
 end.

+ 161 - 165
src/libraries/hashlib4pascal/HlpRIPEMD256.pas

@@ -23,8 +23,8 @@ type
   TRIPEMD256 = class sealed(TMDBase, ITransformBlock)
 
   strict protected
-    procedure TransformBlock(a_data: PByte; a_data_length: Int32;
-      a_index: Int32); override;
+    procedure TransformBlock(AData: PByte; ADataLength: Int32;
+      AIndex: Int32); override;
 
   public
     constructor Create();
@@ -39,13 +39,13 @@ implementation
 
 function TRIPEMD256.Clone(): IHash;
 var
-  HashInstance: TRIPEMD256;
+  LHashInstance: TRIPEMD256;
 begin
-  HashInstance := TRIPEMD256.Create();
-  HashInstance.Fm_state := System.Copy(Fm_state);
-  HashInstance.Fm_buffer := Fm_buffer.Clone();
-  HashInstance.Fm_processed_bytes := Fm_processed_bytes;
-  result := HashInstance as IHash;
+  LHashInstance := TRIPEMD256.Create();
+  LHashInstance.FState := System.Copy(FState);
+  LHashInstance.FBuffer := FBuffer.Clone();
+  LHashInstance.FProcessedBytesCount := FProcessedBytesCount;
+  result := LHashInstance as IHash;
   result.BufferSize := BufferSize;
 end;
 
@@ -56,308 +56,304 @@ end;
 
 procedure TRIPEMD256.Initialize;
 begin
-  Fm_state[4] := $76543210;
-  Fm_state[5] := $FEDCBA98;
-  Fm_state[6] := $89ABCDEF;
-  Fm_state[7] := $01234567;
-
+  FState[4] := $76543210;
+  FState[5] := $FEDCBA98;
+  FState[6] := $89ABCDEF;
+  FState[7] := $01234567;
   Inherited Initialize();
-
 end;
 
-procedure TRIPEMD256.TransformBlock(a_data: PByte; a_data_length: Int32;
-  a_index: Int32);
+procedure TRIPEMD256.TransformBlock(AData: PByte; ADataLength: Int32;
+  AIndex: Int32);
 var
   a, b, c, d, aa, bb, cc, dd: UInt32;
-  data: array [0 .. 15] of UInt32;
+  LData: array [0 .. 15] of UInt32;
 begin
+  TConverters.le32_copy(AData, AIndex, @(LData[0]), 0, ADataLength);
 
-  TConverters.le32_copy(a_data, a_index, @(data[0]), 0, a_data_length);
+  a := FState[0];
+  b := FState[1];
+  c := FState[2];
+  d := FState[3];
+  aa := FState[4];
+  bb := FState[5];
+  cc := FState[6];
+  dd := FState[7];
 
-  a := Fm_state[0];
-  b := Fm_state[1];
-  c := Fm_state[2];
-  d := Fm_state[3];
-  aa := Fm_state[4];
-  bb := Fm_state[5];
-  cc := Fm_state[6];
-  dd := Fm_state[7];
-
-  a := a + (data[0] + (b xor c xor d));
+  a := a + (LData[0] + (b xor c xor d));
   a := TBits.RotateLeft32(a, 11);
-  d := d + (data[1] + (a xor b xor c));
+  d := d + (LData[1] + (a xor b xor c));
   d := TBits.RotateLeft32(d, 14);
-  c := c + (data[2] + (d xor a xor b));
+  c := c + (LData[2] + (d xor a xor b));
   c := TBits.RotateLeft32(c, 15);
-  b := b + (data[3] + (c xor d xor a));
+  b := b + (LData[3] + (c xor d xor a));
   b := TBits.RotateLeft32(b, 12);
-  a := a + (data[4] + (b xor c xor d));
+  a := a + (LData[4] + (b xor c xor d));
   a := TBits.RotateLeft32(a, 5);
-  d := d + (data[5] + (a xor b xor c));
+  d := d + (LData[5] + (a xor b xor c));
   d := TBits.RotateLeft32(d, 8);
-  c := c + (data[6] + (d xor a xor b));
+  c := c + (LData[6] + (d xor a xor b));
   c := TBits.RotateLeft32(c, 7);
-  b := b + (data[7] + (c xor d xor a));
+  b := b + (LData[7] + (c xor d xor a));
   b := TBits.RotateLeft32(b, 9);
-  a := a + (data[8] + (b xor c xor d));
+  a := a + (LData[8] + (b xor c xor d));
   a := TBits.RotateLeft32(a, 11);
-  d := d + (data[9] + (a xor b xor c));
+  d := d + (LData[9] + (a xor b xor c));
   d := TBits.RotateLeft32(d, 13);
-  c := c + (data[10] + (d xor a xor b));
+  c := c + (LData[10] + (d xor a xor b));
   c := TBits.RotateLeft32(c, 14);
-  b := b + (data[11] + (c xor d xor a));
+  b := b + (LData[11] + (c xor d xor a));
   b := TBits.RotateLeft32(b, 15);
-  a := a + (data[12] + (b xor c xor d));
+  a := a + (LData[12] + (b xor c xor d));
   a := TBits.RotateLeft32(a, 6);
-  d := d + (data[13] + (a xor b xor c));
+  d := d + (LData[13] + (a xor b xor c));
   d := TBits.RotateLeft32(d, 7);
-  c := c + (data[14] + (d xor a xor b));
+  c := c + (LData[14] + (d xor a xor b));
   c := TBits.RotateLeft32(c, 9);
-  b := b + (data[15] + (c xor d xor a));
+  b := b + (LData[15] + (c xor d xor a));
   b := TBits.RotateLeft32(b, 8);
 
-  aa := aa + (data[5] + C1 + ((bb and dd) or (cc and not dd)));
+  aa := aa + (LData[5] + C1 + ((bb and dd) or (cc and not dd)));
   aa := TBits.RotateLeft32(aa, 8);
-  dd := dd + (data[14] + C1 + ((aa and cc) or (bb and not cc)));
+  dd := dd + (LData[14] + C1 + ((aa and cc) or (bb and not cc)));
   dd := TBits.RotateLeft32(dd, 9);
-  cc := cc + (data[7] + C1 + ((dd and bb) or (aa and not bb)));
+  cc := cc + (LData[7] + C1 + ((dd and bb) or (aa and not bb)));
   cc := TBits.RotateLeft32(cc, 9);
-  bb := bb + (data[0] + C1 + ((cc and aa) or (dd and not aa)));
+  bb := bb + (LData[0] + C1 + ((cc and aa) or (dd and not aa)));
   bb := TBits.RotateLeft32(bb, 11);
-  aa := aa + (data[9] + C1 + ((bb and dd) or (cc and not dd)));
+  aa := aa + (LData[9] + C1 + ((bb and dd) or (cc and not dd)));
   aa := TBits.RotateLeft32(aa, 13);
-  dd := dd + (data[2] + C1 + ((aa and cc) or (bb and not cc)));
+  dd := dd + (LData[2] + C1 + ((aa and cc) or (bb and not cc)));
   dd := TBits.RotateLeft32(dd, 15);
-  cc := cc + (data[11] + C1 + ((dd and bb) or (aa and not bb)));
+  cc := cc + (LData[11] + C1 + ((dd and bb) or (aa and not bb)));
   cc := TBits.RotateLeft32(cc, 15);
-  bb := bb + (data[4] + C1 + ((cc and aa) or (dd and not aa)));
+  bb := bb + (LData[4] + C1 + ((cc and aa) or (dd and not aa)));
   bb := TBits.RotateLeft32(bb, 5);
-  aa := aa + (data[13] + C1 + ((bb and dd) or (cc and not dd)));
+  aa := aa + (LData[13] + C1 + ((bb and dd) or (cc and not dd)));
   aa := TBits.RotateLeft32(aa, 7);
-  dd := dd + (data[6] + C1 + ((aa and cc) or (bb and not cc)));
+  dd := dd + (LData[6] + C1 + ((aa and cc) or (bb and not cc)));
   dd := TBits.RotateLeft32(dd, 7);
-  cc := cc + (data[15] + C1 + ((dd and bb) or (aa and not bb)));
+  cc := cc + (LData[15] + C1 + ((dd and bb) or (aa and not bb)));
   cc := TBits.RotateLeft32(cc, 8);
-  bb := bb + (data[8] + C1 + ((cc and aa) or (dd and not aa)));
+  bb := bb + (LData[8] + C1 + ((cc and aa) or (dd and not aa)));
   bb := TBits.RotateLeft32(bb, 11);
-  aa := aa + (data[1] + C1 + ((bb and dd) or (cc and not dd)));
+  aa := aa + (LData[1] + C1 + ((bb and dd) or (cc and not dd)));
   aa := TBits.RotateLeft32(aa, 14);
-  dd := dd + (data[10] + C1 + ((aa and cc) or (bb and not cc)));
+  dd := dd + (LData[10] + C1 + ((aa and cc) or (bb and not cc)));
   dd := TBits.RotateLeft32(dd, 14);
-  cc := cc + (data[3] + C1 + ((dd and bb) or (aa and not bb)));
+  cc := cc + (LData[3] + C1 + ((dd and bb) or (aa and not bb)));
   cc := TBits.RotateLeft32(cc, 12);
-  bb := bb + (data[12] + C1 + ((cc and aa) or (dd and not aa)));
+  bb := bb + (LData[12] + C1 + ((cc and aa) or (dd and not aa)));
   bb := TBits.RotateLeft32(bb, 6);
 
-  aa := aa + (data[7] + C2 + ((b and c) or (not b and d)));
+  aa := aa + (LData[7] + C2 + ((b and c) or (not b and d)));
   aa := TBits.RotateLeft32(aa, 7);
-  d := d + (data[4] + C2 + ((aa and b) or (not aa and c)));
+  d := d + (LData[4] + C2 + ((aa and b) or (not aa and c)));
   d := TBits.RotateLeft32(d, 6);
-  c := c + (data[13] + C2 + ((d and aa) or (not d and b)));
+  c := c + (LData[13] + C2 + ((d and aa) or (not d and b)));
   c := TBits.RotateLeft32(c, 8);
-  b := b + (data[1] + C2 + ((c and d) or (not c and aa)));
+  b := b + (LData[1] + C2 + ((c and d) or (not c and aa)));
   b := TBits.RotateLeft32(b, 13);
-  aa := aa + (data[10] + C2 + ((b and c) or (not b and d)));
+  aa := aa + (LData[10] + C2 + ((b and c) or (not b and d)));
   aa := TBits.RotateLeft32(aa, 11);
-  d := d + (data[6] + C2 + ((aa and b) or (not aa and c)));
+  d := d + (LData[6] + C2 + ((aa and b) or (not aa and c)));
   d := TBits.RotateLeft32(d, 9);
-  c := c + (data[15] + C2 + ((d and aa) or (not d and b)));
+  c := c + (LData[15] + C2 + ((d and aa) or (not d and b)));
   c := TBits.RotateLeft32(c, 7);
-  b := b + (data[3] + C2 + ((c and d) or (not c and aa)));
+  b := b + (LData[3] + C2 + ((c and d) or (not c and aa)));
   b := TBits.RotateLeft32(b, 15);
-  aa := aa + (data[12] + C2 + ((b and c) or (not b and d)));
+  aa := aa + (LData[12] + C2 + ((b and c) or (not b and d)));
   aa := TBits.RotateLeft32(aa, 7);
-  d := d + (data[0] + C2 + ((aa and b) or (not aa and c)));
+  d := d + (LData[0] + C2 + ((aa and b) or (not aa and c)));
   d := TBits.RotateLeft32(d, 12);
-  c := c + (data[9] + C2 + ((d and aa) or (not d and b)));
+  c := c + (LData[9] + C2 + ((d and aa) or (not d and b)));
   c := TBits.RotateLeft32(c, 15);
-  b := b + (data[5] + C2 + ((c and d) or (not c and aa)));
+  b := b + (LData[5] + C2 + ((c and d) or (not c and aa)));
   b := TBits.RotateLeft32(b, 9);
-  aa := aa + (data[2] + C2 + ((b and c) or (not b and d)));
+  aa := aa + (LData[2] + C2 + ((b and c) or (not b and d)));
   aa := TBits.RotateLeft32(aa, 11);
-  d := d + (data[14] + C2 + ((aa and b) or (not aa and c)));
+  d := d + (LData[14] + C2 + ((aa and b) or (not aa and c)));
   d := TBits.RotateLeft32(d, 7);
-  c := c + (data[11] + C2 + ((d and aa) or (not d and b)));
+  c := c + (LData[11] + C2 + ((d and aa) or (not d and b)));
   c := TBits.RotateLeft32(c, 13);
-  b := b + (data[8] + C2 + ((c and d) or (not c and aa)));
+  b := b + (LData[8] + C2 + ((c and d) or (not c and aa)));
   b := TBits.RotateLeft32(b, 12);
 
-  a := a + (data[6] + C3 + ((bb or not cc) xor dd));
+  a := a + (LData[6] + C3 + ((bb or not cc) xor dd));
   a := TBits.RotateLeft32(a, 9);
-  dd := dd + (data[11] + C3 + ((a or not bb) xor cc));
+  dd := dd + (LData[11] + C3 + ((a or not bb) xor cc));
   dd := TBits.RotateLeft32(dd, 13);
-  cc := cc + (data[3] + C3 + ((dd or not a) xor bb));
+  cc := cc + (LData[3] + C3 + ((dd or not a) xor bb));
   cc := TBits.RotateLeft32(cc, 15);
-  bb := bb + (data[7] + C3 + ((cc or not dd) xor a));
+  bb := bb + (LData[7] + C3 + ((cc or not dd) xor a));
   bb := TBits.RotateLeft32(bb, 7);
-  a := a + (data[0] + C3 + ((bb or not cc) xor dd));
+  a := a + (LData[0] + C3 + ((bb or not cc) xor dd));
   a := TBits.RotateLeft32(a, 12);
-  dd := dd + (data[13] + C3 + ((a or not bb) xor cc));
+  dd := dd + (LData[13] + C3 + ((a or not bb) xor cc));
   dd := TBits.RotateLeft32(dd, 8);
-  cc := cc + (data[5] + C3 + ((dd or not a) xor bb));
+  cc := cc + (LData[5] + C3 + ((dd or not a) xor bb));
   cc := TBits.RotateLeft32(cc, 9);
-  bb := bb + (data[10] + C3 + ((cc or not dd) xor a));
+  bb := bb + (LData[10] + C3 + ((cc or not dd) xor a));
   bb := TBits.RotateLeft32(bb, 11);
-  a := a + (data[14] + C3 + ((bb or not cc) xor dd));
+  a := a + (LData[14] + C3 + ((bb or not cc) xor dd));
   a := TBits.RotateLeft32(a, 7);
-  dd := dd + (data[15] + C3 + ((a or not bb) xor cc));
+  dd := dd + (LData[15] + C3 + ((a or not bb) xor cc));
   dd := TBits.RotateLeft32(dd, 7);
-  cc := cc + (data[8] + C3 + ((dd or not a) xor bb));
+  cc := cc + (LData[8] + C3 + ((dd or not a) xor bb));
   cc := TBits.RotateLeft32(cc, 12);
-  bb := bb + (data[12] + C3 + ((cc or not dd) xor a));
+  bb := bb + (LData[12] + C3 + ((cc or not dd) xor a));
   bb := TBits.RotateLeft32(bb, 7);
-  a := a + (data[4] + C3 + ((bb or not cc) xor dd));
+  a := a + (LData[4] + C3 + ((bb or not cc) xor dd));
   a := TBits.RotateLeft32(a, 6);
-  dd := dd + (data[9] + C3 + ((a or not bb) xor cc));
+  dd := dd + (LData[9] + C3 + ((a or not bb) xor cc));
   dd := TBits.RotateLeft32(dd, 15);
-  cc := cc + (data[1] + C3 + ((dd or not a) xor bb));
+  cc := cc + (LData[1] + C3 + ((dd or not a) xor bb));
   cc := TBits.RotateLeft32(cc, 13);
-  bb := bb + (data[2] + C3 + ((cc or not dd) xor a));
+  bb := bb + (LData[2] + C3 + ((cc or not dd) xor a));
   bb := TBits.RotateLeft32(bb, 11);
 
-  aa := aa + (data[3] + C4 + ((bb or not c) xor d));
+  aa := aa + (LData[3] + C4 + ((bb or not c) xor d));
   aa := TBits.RotateLeft32(aa, 11);
-  d := d + (data[10] + C4 + ((aa or not bb) xor c));
+  d := d + (LData[10] + C4 + ((aa or not bb) xor c));
   d := TBits.RotateLeft32(d, 13);
-  c := c + (data[14] + C4 + ((d or not aa) xor bb));
+  c := c + (LData[14] + C4 + ((d or not aa) xor bb));
   c := TBits.RotateLeft32(c, 6);
-  bb := bb + (data[4] + C4 + ((c or not d) xor aa));
+  bb := bb + (LData[4] + C4 + ((c or not d) xor aa));
   bb := TBits.RotateLeft32(bb, 7);
-  aa := aa + (data[9] + C4 + ((bb or not c) xor d));
+  aa := aa + (LData[9] + C4 + ((bb or not c) xor d));
   aa := TBits.RotateLeft32(aa, 14);
-  d := d + (data[15] + C4 + ((aa or not bb) xor c));
+  d := d + (LData[15] + C4 + ((aa or not bb) xor c));
   d := TBits.RotateLeft32(d, 9);
-  c := c + (data[8] + C4 + ((d or not aa) xor bb));
+  c := c + (LData[8] + C4 + ((d or not aa) xor bb));
   c := TBits.RotateLeft32(c, 13);
-  bb := bb + (data[1] + C4 + ((c or not d) xor aa));
+  bb := bb + (LData[1] + C4 + ((c or not d) xor aa));
   bb := TBits.RotateLeft32(bb, 15);
-  aa := aa + (data[2] + C4 + ((bb or not c) xor d));
+  aa := aa + (LData[2] + C4 + ((bb or not c) xor d));
   aa := TBits.RotateLeft32(aa, 14);
-  d := d + (data[7] + C4 + ((aa or not bb) xor c));
+  d := d + (LData[7] + C4 + ((aa or not bb) xor c));
   d := TBits.RotateLeft32(d, 8);
-  c := c + (data[0] + C4 + ((d or not aa) xor bb));
+  c := c + (LData[0] + C4 + ((d or not aa) xor bb));
   c := TBits.RotateLeft32(c, 13);
-  bb := bb + (data[6] + C4 + ((c or not d) xor aa));
+  bb := bb + (LData[6] + C4 + ((c or not d) xor aa));
   bb := TBits.RotateLeft32(bb, 6);
-  aa := aa + (data[13] + C4 + ((bb or not c) xor d));
+  aa := aa + (LData[13] + C4 + ((bb or not c) xor d));
   aa := TBits.RotateLeft32(aa, 5);
-  d := d + (data[11] + C4 + ((aa or not bb) xor c));
+  d := d + (LData[11] + C4 + ((aa or not bb) xor c));
   d := TBits.RotateLeft32(d, 12);
-  c := c + (data[5] + C4 + ((d or not aa) xor bb));
+  c := c + (LData[5] + C4 + ((d or not aa) xor bb));
   c := TBits.RotateLeft32(c, 7);
-  bb := bb + (data[12] + C4 + ((c or not d) xor aa));
+  bb := bb + (LData[12] + C4 + ((c or not d) xor aa));
   bb := TBits.RotateLeft32(bb, 5);
 
-  a := a + (data[15] + C5 + ((b and cc) or (not b and dd)));
+  a := a + (LData[15] + C5 + ((b and cc) or (not b and dd)));
   a := TBits.RotateLeft32(a, 9);
-  dd := dd + (data[5] + C5 + ((a and b) or (not a and cc)));
+  dd := dd + (LData[5] + C5 + ((a and b) or (not a and cc)));
   dd := TBits.RotateLeft32(dd, 7);
-  cc := cc + (data[1] + C5 + ((dd and a) or (not dd and b)));
+  cc := cc + (LData[1] + C5 + ((dd and a) or (not dd and b)));
   cc := TBits.RotateLeft32(cc, 15);
-  b := b + (data[3] + C5 + ((cc and dd) or (not cc and a)));
+  b := b + (LData[3] + C5 + ((cc and dd) or (not cc and a)));
   b := TBits.RotateLeft32(b, 11);
-  a := a + (data[7] + C5 + ((b and cc) or (not b and dd)));
+  a := a + (LData[7] + C5 + ((b and cc) or (not b and dd)));
   a := TBits.RotateLeft32(a, 8);
-  dd := dd + (data[14] + C5 + ((a and b) or (not a and cc)));
+  dd := dd + (LData[14] + C5 + ((a and b) or (not a and cc)));
   dd := TBits.RotateLeft32(dd, 6);
-  cc := cc + (data[6] + C5 + ((dd and a) or (not dd and b)));
+  cc := cc + (LData[6] + C5 + ((dd and a) or (not dd and b)));
   cc := TBits.RotateLeft32(cc, 6);
-  b := b + (data[9] + C5 + ((cc and dd) or (not cc and a)));
+  b := b + (LData[9] + C5 + ((cc and dd) or (not cc and a)));
   b := TBits.RotateLeft32(b, 14);
-  a := a + (data[11] + C5 + ((b and cc) or (not b and dd)));
+  a := a + (LData[11] + C5 + ((b and cc) or (not b and dd)));
   a := TBits.RotateLeft32(a, 12);
-  dd := dd + (data[8] + C5 + ((a and b) or (not a and cc)));
+  dd := dd + (LData[8] + C5 + ((a and b) or (not a and cc)));
   dd := TBits.RotateLeft32(dd, 13);
-  cc := cc + (data[12] + C5 + ((dd and a) or (not dd and b)));
+  cc := cc + (LData[12] + C5 + ((dd and a) or (not dd and b)));
   cc := TBits.RotateLeft32(cc, 5);
-  b := b + (data[2] + C5 + ((cc and dd) or (not cc and a)));
+  b := b + (LData[2] + C5 + ((cc and dd) or (not cc and a)));
   b := TBits.RotateLeft32(b, 14);
-  a := a + (data[10] + C5 + ((b and cc) or (not b and dd)));
+  a := a + (LData[10] + C5 + ((b and cc) or (not b and dd)));
   a := TBits.RotateLeft32(a, 13);
-  dd := dd + (data[0] + C5 + ((a and b) or (not a and cc)));
+  dd := dd + (LData[0] + C5 + ((a and b) or (not a and cc)));
   dd := TBits.RotateLeft32(dd, 13);
-  cc := cc + (data[4] + C5 + ((dd and a) or (not dd and b)));
+  cc := cc + (LData[4] + C5 + ((dd and a) or (not dd and b)));
   cc := TBits.RotateLeft32(cc, 7);
-  b := b + (data[13] + C5 + ((cc and dd) or (not cc and a)));
+  b := b + (LData[13] + C5 + ((cc and dd) or (not cc and a)));
   b := TBits.RotateLeft32(b, 5);
 
-  aa := aa + (data[1] + C6 + ((bb and d) or (cc and not d)));
+  aa := aa + (LData[1] + C6 + ((bb and d) or (cc and not d)));
   aa := TBits.RotateLeft32(aa, 11);
-  d := d + (data[9] + C6 + ((aa and cc) or (bb and not cc)));
+  d := d + (LData[9] + C6 + ((aa and cc) or (bb and not cc)));
   d := TBits.RotateLeft32(d, 12);
-  cc := cc + (data[11] + C6 + ((d and bb) or (aa and not bb)));
+  cc := cc + (LData[11] + C6 + ((d and bb) or (aa and not bb)));
   cc := TBits.RotateLeft32(cc, 14);
-  bb := bb + (data[10] + C6 + ((cc and aa) or (d and not aa)));
+  bb := bb + (LData[10] + C6 + ((cc and aa) or (d and not aa)));
   bb := TBits.RotateLeft32(bb, 15);
-  aa := aa + (data[0] + C6 + ((bb and d) or (cc and not d)));
+  aa := aa + (LData[0] + C6 + ((bb and d) or (cc and not d)));
   aa := TBits.RotateLeft32(aa, 14);
-  d := d + (data[8] + C6 + ((aa and cc) or (bb and not cc)));
+  d := d + (LData[8] + C6 + ((aa and cc) or (bb and not cc)));
   d := TBits.RotateLeft32(d, 15);
-  cc := cc + (data[12] + C6 + ((d and bb) or (aa and not bb)));
+  cc := cc + (LData[12] + C6 + ((d and bb) or (aa and not bb)));
   cc := TBits.RotateLeft32(cc, 9);
-  bb := bb + (data[4] + C6 + ((cc and aa) or (d and not aa)));
+  bb := bb + (LData[4] + C6 + ((cc and aa) or (d and not aa)));
   bb := TBits.RotateLeft32(bb, 8);
-  aa := aa + (data[13] + C6 + ((bb and d) or (cc and not d)));
+  aa := aa + (LData[13] + C6 + ((bb and d) or (cc and not d)));
   aa := TBits.RotateLeft32(aa, 9);
-  d := d + (data[3] + C6 + ((aa and cc) or (bb and not cc)));
+  d := d + (LData[3] + C6 + ((aa and cc) or (bb and not cc)));
   d := TBits.RotateLeft32(d, 14);
-  cc := cc + (data[7] + C6 + ((d and bb) or (aa and not bb)));
+  cc := cc + (LData[7] + C6 + ((d and bb) or (aa and not bb)));
   cc := TBits.RotateLeft32(cc, 5);
-  bb := bb + (data[15] + C6 + ((cc and aa) or (d and not aa)));
+  bb := bb + (LData[15] + C6 + ((cc and aa) or (d and not aa)));
   bb := TBits.RotateLeft32(bb, 6);
-  aa := aa + (data[14] + C6 + ((bb and d) or (cc and not d)));
+  aa := aa + (LData[14] + C6 + ((bb and d) or (cc and not d)));
   aa := TBits.RotateLeft32(aa, 8);
-  d := d + (data[5] + C6 + ((aa and cc) or (bb and not cc)));
+  d := d + (LData[5] + C6 + ((aa and cc) or (bb and not cc)));
   d := TBits.RotateLeft32(d, 6);
-  cc := cc + (data[6] + C6 + ((d and bb) or (aa and not bb)));
+  cc := cc + (LData[6] + C6 + ((d and bb) or (aa and not bb)));
   cc := TBits.RotateLeft32(cc, 5);
-  bb := bb + (data[2] + C6 + ((cc and aa) or (d and not aa)));
+  bb := bb + (LData[2] + C6 + ((cc and aa) or (d and not aa)));
   bb := TBits.RotateLeft32(bb, 12);
 
-  a := a + (data[8] + (b xor c xor dd));
+  a := a + (LData[8] + (b xor c xor dd));
   a := TBits.RotateLeft32(a, 15);
-  dd := dd + (data[6] + (a xor b xor c));
+  dd := dd + (LData[6] + (a xor b xor c));
   dd := TBits.RotateLeft32(dd, 5);
-  c := c + (data[4] + (dd xor a xor b));
+  c := c + (LData[4] + (dd xor a xor b));
   c := TBits.RotateLeft32(c, 8);
-  b := b + (data[1] + (c xor dd xor a));
+  b := b + (LData[1] + (c xor dd xor a));
   b := TBits.RotateLeft32(b, 11);
-  a := a + (data[3] + (b xor c xor dd));
+  a := a + (LData[3] + (b xor c xor dd));
   a := TBits.RotateLeft32(a, 14);
-  dd := dd + (data[11] + (a xor b xor c));
+  dd := dd + (LData[11] + (a xor b xor c));
   dd := TBits.RotateLeft32(dd, 14);
-  c := c + (data[15] + (dd xor a xor b));
+  c := c + (LData[15] + (dd xor a xor b));
   c := TBits.RotateLeft32(c, 6);
-  b := b + (data[0] + (c xor dd xor a));
+  b := b + (LData[0] + (c xor dd xor a));
   b := TBits.RotateLeft32(b, 14);
-  a := a + (data[5] + (b xor c xor dd));
+  a := a + (LData[5] + (b xor c xor dd));
   a := TBits.RotateLeft32(a, 6);
-  dd := dd + (data[12] + (a xor b xor c));
+  dd := dd + (LData[12] + (a xor b xor c));
   dd := TBits.RotateLeft32(dd, 9);
-  c := c + (data[2] + (dd xor a xor b));
+  c := c + (LData[2] + (dd xor a xor b));
   c := TBits.RotateLeft32(c, 12);
-  b := b + (data[13] + (c xor dd xor a));
+  b := b + (LData[13] + (c xor dd xor a));
   b := TBits.RotateLeft32(b, 9);
-  a := a + (data[9] + (b xor c xor dd));
+  a := a + (LData[9] + (b xor c xor dd));
   a := TBits.RotateLeft32(a, 12);
-  dd := dd + (data[7] + (a xor b xor c));
+  dd := dd + (LData[7] + (a xor b xor c));
   dd := TBits.RotateLeft32(dd, 5);
-  c := c + (data[10] + (dd xor a xor b));
+  c := c + (LData[10] + (dd xor a xor b));
   c := TBits.RotateLeft32(c, 15);
-  b := b + (data[14] + (c xor dd xor a));
+  b := b + (LData[14] + (c xor dd xor a));
   b := TBits.RotateLeft32(b, 8);
 
-  Fm_state[0] := Fm_state[0] + aa;
-  Fm_state[1] := Fm_state[1] + bb;
-  Fm_state[2] := Fm_state[2] + cc;
-  Fm_state[3] := Fm_state[3] + dd;
-  Fm_state[4] := Fm_state[4] + a;
-  Fm_state[5] := Fm_state[5] + b;
-  Fm_state[6] := Fm_state[6] + c;
-  Fm_state[7] := Fm_state[7] + d;
-
-  System.FillChar(data, System.SizeOf(data), UInt32(0));
+  FState[0] := FState[0] + aa;
+  FState[1] := FState[1] + bb;
+  FState[2] := FState[2] + cc;
+  FState[3] := FState[3] + dd;
+  FState[4] := FState[4] + a;
+  FState[5] := FState[5] + b;
+  FState[6] := FState[6] + c;
+  FState[7] := FState[7] + d;
 
+  System.FillChar(LData, System.SizeOf(LData), UInt32(0));
 end;
 
 end.

+ 199 - 201
src/libraries/hashlib4pascal/HlpRIPEMD320.pas

@@ -23,8 +23,8 @@ type
   TRIPEMD320 = class sealed(TMDBase, ITransformBlock)
 
   strict protected
-    procedure TransformBlock(a_data: PByte; a_data_length: Int32;
-      a_index: Int32); override;
+    procedure TransformBlock(AData: PByte; ADataLength: Int32;
+      AIndex: Int32); override;
 
   public
     constructor Create();
@@ -39,13 +39,13 @@ implementation
 
 function TRIPEMD320.Clone(): IHash;
 var
-  HashInstance: TRIPEMD320;
+  LHashInstance: TRIPEMD320;
 begin
-  HashInstance := TRIPEMD320.Create();
-  HashInstance.Fm_state := System.Copy(Fm_state);
-  HashInstance.Fm_buffer := Fm_buffer.Clone();
-  HashInstance.Fm_processed_bytes := Fm_processed_bytes;
-  result := HashInstance as IHash;
+  LHashInstance := TRIPEMD320.Create();
+  LHashInstance.FState := System.Copy(FState);
+  LHashInstance.FBuffer := FBuffer.Clone();
+  LHashInstance.FProcessedBytesCount := FProcessedBytesCount;
+  result := LHashInstance as IHash;
   result.BufferSize := BufferSize;
 end;
 
@@ -56,540 +56,538 @@ end;
 
 procedure TRIPEMD320.Initialize;
 begin
-  Fm_state[4] := $C3D2E1F0;
-  Fm_state[5] := $76543210;
-  Fm_state[6] := $FEDCBA98;
-  Fm_state[7] := $89ABCDEF;
-  Fm_state[8] := $01234567;
-  Fm_state[9] := $3C2D1E0F;
+  FState[4] := $C3D2E1F0;
+  FState[5] := $76543210;
+  FState[6] := $FEDCBA98;
+  FState[7] := $89ABCDEF;
+  FState[8] := $01234567;
+  FState[9] := $3C2D1E0F;
 
   Inherited Initialize();
 
 end;
 
-procedure TRIPEMD320.TransformBlock(a_data: PByte; a_data_length: Int32;
-  a_index: Int32);
+procedure TRIPEMD320.TransformBlock(AData: PByte; ADataLength: Int32;
+  AIndex: Int32);
 var
   a, b, c, d, e, aa, bb, cc, dd, ee: UInt32;
-  data: array [0 .. 15] of UInt32;
+  LData: array [0 .. 15] of UInt32;
 begin
+  TConverters.le32_copy(AData, AIndex, @(LData[0]), 0, ADataLength);
 
-  TConverters.le32_copy(a_data, a_index, @(data[0]), 0, a_data_length);
+  a := FState[0];
+  b := FState[1];
+  c := FState[2];
+  d := FState[3];
+  e := FState[4];
+  aa := FState[5];
+  bb := FState[6];
+  cc := FState[7];
+  dd := FState[8];
+  ee := FState[9];
 
-  a := Fm_state[0];
-  b := Fm_state[1];
-  c := Fm_state[2];
-  d := Fm_state[3];
-  e := Fm_state[4];
-  aa := Fm_state[5];
-  bb := Fm_state[6];
-  cc := Fm_state[7];
-  dd := Fm_state[8];
-  ee := Fm_state[9];
-
-  a := a + (data[0] + (b xor c xor d));
+  a := a + (LData[0] + (b xor c xor d));
   a := TBits.RotateLeft32(a, 11) + e;
   c := TBits.RotateLeft32(c, 10);
-  e := e + (data[1] + (a xor b xor c));
+  e := e + (LData[1] + (a xor b xor c));
   e := TBits.RotateLeft32(e, 14) + d;
   b := TBits.RotateLeft32(b, 10);
-  d := d + (data[2] + (e xor a xor b));
+  d := d + (LData[2] + (e xor a xor b));
   d := TBits.RotateLeft32(d, 15) + c;
   a := TBits.RotateLeft32(a, 10);
-  c := c + (data[3] + (d xor e xor a));
+  c := c + (LData[3] + (d xor e xor a));
   c := TBits.RotateLeft32(c, 12) + b;
   e := TBits.RotateLeft32(e, 10);
-  b := b + (data[4] + (c xor d xor e));
+  b := b + (LData[4] + (c xor d xor e));
   b := TBits.RotateLeft32(b, 5) + a;
   d := TBits.RotateLeft32(d, 10);
-  a := a + (data[5] + (b xor c xor d));
+  a := a + (LData[5] + (b xor c xor d));
   a := TBits.RotateLeft32(a, 8) + e;
   c := TBits.RotateLeft32(c, 10);
-  e := e + (data[6] + (a xor b xor c));
+  e := e + (LData[6] + (a xor b xor c));
   e := TBits.RotateLeft32(e, 7) + d;
   b := TBits.RotateLeft32(b, 10);
-  d := d + (data[7] + (e xor a xor b));
+  d := d + (LData[7] + (e xor a xor b));
   d := TBits.RotateLeft32(d, 9) + c;
   a := TBits.RotateLeft32(a, 10);
-  c := c + (data[8] + (d xor e xor a));
+  c := c + (LData[8] + (d xor e xor a));
   c := TBits.RotateLeft32(c, 11) + b;
   e := TBits.RotateLeft32(e, 10);
-  b := b + (data[9] + (c xor d xor e));
+  b := b + (LData[9] + (c xor d xor e));
   b := TBits.RotateLeft32(b, 13) + a;
   d := TBits.RotateLeft32(d, 10);
-  a := a + (data[10] + (b xor c xor d));
+  a := a + (LData[10] + (b xor c xor d));
   a := TBits.RotateLeft32(a, 14) + e;
   c := TBits.RotateLeft32(c, 10);
-  e := e + (data[11] + (a xor b xor c));
+  e := e + (LData[11] + (a xor b xor c));
   e := TBits.RotateLeft32(e, 15) + d;
   b := TBits.RotateLeft32(b, 10);
-  d := d + (data[12] + (e xor a xor b));
+  d := d + (LData[12] + (e xor a xor b));
   d := TBits.RotateLeft32(d, 6) + c;
   a := TBits.RotateLeft32(a, 10);
-  c := c + (data[13] + (d xor e xor a));
+  c := c + (LData[13] + (d xor e xor a));
   c := TBits.RotateLeft32(c, 7) + b;
   e := TBits.RotateLeft32(e, 10);
-  b := b + (data[14] + (c xor d xor e));
+  b := b + (LData[14] + (c xor d xor e));
   b := TBits.RotateLeft32(b, 9) + a;
   d := TBits.RotateLeft32(d, 10);
-  a := a + (data[15] + (b xor c xor d));
+  a := a + (LData[15] + (b xor c xor d));
   a := TBits.RotateLeft32(a, 8) + e;
   c := TBits.RotateLeft32(c, 10);
 
-  aa := aa + (data[5] + C1 + (bb xor (cc or not dd)));
+  aa := aa + (LData[5] + C1 + (bb xor (cc or not dd)));
   aa := TBits.RotateLeft32(aa, 8) + ee;
   cc := TBits.RotateLeft32(cc, 10);
-  ee := ee + (data[14] + C1 + (aa xor (bb or not cc)));
+  ee := ee + (LData[14] + C1 + (aa xor (bb or not cc)));
   ee := TBits.RotateLeft32(ee, 9) + dd;
   bb := TBits.RotateLeft32(bb, 10);
-  dd := dd + (data[7] + C1 + (ee xor (aa or not bb)));
+  dd := dd + (LData[7] + C1 + (ee xor (aa or not bb)));
   dd := TBits.RotateLeft32(dd, 9) + cc;
   aa := TBits.RotateLeft32(aa, 10);
-  cc := cc + (data[0] + C1 + (dd xor (ee or not aa)));
+  cc := cc + (LData[0] + C1 + (dd xor (ee or not aa)));
   cc := TBits.RotateLeft32(cc, 11) + bb;
   ee := TBits.RotateLeft32(ee, 10);
-  bb := bb + (data[9] + C1 + (cc xor (dd or not ee)));
+  bb := bb + (LData[9] + C1 + (cc xor (dd or not ee)));
   bb := TBits.RotateLeft32(bb, 13) + aa;
   dd := TBits.RotateLeft32(dd, 10);
-  aa := aa + (data[2] + C1 + (bb xor (cc or not dd)));
+  aa := aa + (LData[2] + C1 + (bb xor (cc or not dd)));
   aa := TBits.RotateLeft32(aa, 15) + ee;
   cc := TBits.RotateLeft32(cc, 10);
-  ee := ee + (data[11] + C1 + (aa xor (bb or not cc)));
+  ee := ee + (LData[11] + C1 + (aa xor (bb or not cc)));
   ee := TBits.RotateLeft32(ee, 15) + dd;
   bb := TBits.RotateLeft32(bb, 10);
-  dd := dd + (data[4] + C1 + (ee xor (aa or not bb)));
+  dd := dd + (LData[4] + C1 + (ee xor (aa or not bb)));
   dd := TBits.RotateLeft32(dd, 5) + cc;
   aa := TBits.RotateLeft32(aa, 10);
-  cc := cc + (data[13] + C1 + (dd xor (ee or not aa)));
+  cc := cc + (LData[13] + C1 + (dd xor (ee or not aa)));
   cc := TBits.RotateLeft32(cc, 7) + bb;
   ee := TBits.RotateLeft32(ee, 10);
-  bb := bb + (data[6] + C1 + (cc xor (dd or not ee)));
+  bb := bb + (LData[6] + C1 + (cc xor (dd or not ee)));
   bb := TBits.RotateLeft32(bb, 7) + aa;
   dd := TBits.RotateLeft32(dd, 10);
-  aa := aa + (data[15] + C1 + (bb xor (cc or not dd)));
+  aa := aa + (LData[15] + C1 + (bb xor (cc or not dd)));
   aa := TBits.RotateLeft32(aa, 8) + ee;
   cc := TBits.RotateLeft32(cc, 10);
-  ee := ee + (data[8] + C1 + (aa xor (bb or not cc)));
+  ee := ee + (LData[8] + C1 + (aa xor (bb or not cc)));
   ee := TBits.RotateLeft32(ee, 11) + dd;
   bb := TBits.RotateLeft32(bb, 10);
-  dd := dd + (data[1] + C1 + (ee xor (aa or not bb)));
+  dd := dd + (LData[1] + C1 + (ee xor (aa or not bb)));
   dd := TBits.RotateLeft32(dd, 14) + cc;
   aa := TBits.RotateLeft32(aa, 10);
-  cc := cc + (data[10] + C1 + (dd xor (ee or not aa)));
+  cc := cc + (LData[10] + C1 + (dd xor (ee or not aa)));
   cc := TBits.RotateLeft32(cc, 14) + bb;
   ee := TBits.RotateLeft32(ee, 10);
-  bb := bb + (data[3] + C1 + (cc xor (dd or not ee)));
+  bb := bb + (LData[3] + C1 + (cc xor (dd or not ee)));
   bb := TBits.RotateLeft32(bb, 12) + aa;
   dd := TBits.RotateLeft32(dd, 10);
-  aa := aa + (data[12] + C1 + (bb xor (cc or not dd)));
+  aa := aa + (LData[12] + C1 + (bb xor (cc or not dd)));
   aa := TBits.RotateLeft32(aa, 6) + ee;
   cc := TBits.RotateLeft32(cc, 10);
 
-  e := e + (data[7] + C2 + ((aa and b) or (not aa and c)));
+  e := e + (LData[7] + C2 + ((aa and b) or (not aa and c)));
   e := TBits.RotateLeft32(e, 7) + d;
   b := TBits.RotateLeft32(b, 10);
-  d := d + (data[4] + C2 + ((e and aa) or (not e and b)));
+  d := d + (LData[4] + C2 + ((e and aa) or (not e and b)));
   d := TBits.RotateLeft32(d, 6) + c;
   aa := TBits.RotateLeft32(aa, 10);
-  c := c + (data[13] + C2 + ((d and e) or (not d and aa)));
+  c := c + (LData[13] + C2 + ((d and e) or (not d and aa)));
   c := TBits.RotateLeft32(c, 8) + b;
   e := TBits.RotateLeft32(e, 10);
-  b := b + (data[1] + C2 + ((c and d) or (not c and e)));
+  b := b + (LData[1] + C2 + ((c and d) or (not c and e)));
   b := TBits.RotateLeft32(b, 13) + aa;
   d := TBits.RotateLeft32(d, 10);
-  aa := aa + (data[10] + C2 + ((b and c) or (not b and d)));
+  aa := aa + (LData[10] + C2 + ((b and c) or (not b and d)));
   aa := TBits.RotateLeft32(aa, 11) + e;
   c := TBits.RotateLeft32(c, 10);
-  e := e + (data[6] + C2 + ((aa and b) or (not aa and c)));
+  e := e + (LData[6] + C2 + ((aa and b) or (not aa and c)));
   e := TBits.RotateLeft32(e, 9) + d;
   b := TBits.RotateLeft32(b, 10);
-  d := d + (data[15] + C2 + ((e and aa) or (not e and b)));
+  d := d + (LData[15] + C2 + ((e and aa) or (not e and b)));
   d := TBits.RotateLeft32(d, 7) + c;
   aa := TBits.RotateLeft32(aa, 10);
-  c := c + (data[3] + C2 + ((d and e) or (not d and aa)));
+  c := c + (LData[3] + C2 + ((d and e) or (not d and aa)));
   c := TBits.RotateLeft32(c, 15) + b;
   e := TBits.RotateLeft32(e, 10);
-  b := b + (data[12] + C2 + ((c and d) or (not c and e)));
+  b := b + (LData[12] + C2 + ((c and d) or (not c and e)));
   b := TBits.RotateLeft32(b, 7) + aa;
   d := TBits.RotateLeft32(d, 10);
-  aa := aa + (data[0] + C2 + ((b and c) or (not b and d)));
+  aa := aa + (LData[0] + C2 + ((b and c) or (not b and d)));
   aa := TBits.RotateLeft32(aa, 12) + e;
   c := TBits.RotateLeft32(c, 10);
-  e := e + (data[9] + C2 + ((aa and b) or (not aa and c)));
+  e := e + (LData[9] + C2 + ((aa and b) or (not aa and c)));
   e := TBits.RotateLeft32(e, 15) + d;
   b := TBits.RotateLeft32(b, 10);
-  d := d + (data[5] + C2 + ((e and aa) or (not e and b)));
+  d := d + (LData[5] + C2 + ((e and aa) or (not e and b)));
   d := TBits.RotateLeft32(d, 9) + c;
   aa := TBits.RotateLeft32(aa, 10);
-  c := c + (data[2] + C2 + ((d and e) or (not d and aa)));
+  c := c + (LData[2] + C2 + ((d and e) or (not d and aa)));
   c := TBits.RotateLeft32(c, 11) + b;
   e := TBits.RotateLeft32(e, 10);
-  b := b + (data[14] + C2 + ((c and d) or (not c and e)));
+  b := b + (LData[14] + C2 + ((c and d) or (not c and e)));
   b := TBits.RotateLeft32(b, 7) + aa;
   d := TBits.RotateLeft32(d, 10);
-  aa := aa + (data[11] + C2 + ((b and c) or (not b and d)));
+  aa := aa + (LData[11] + C2 + ((b and c) or (not b and d)));
   aa := TBits.RotateLeft32(aa, 13) + e;
   c := TBits.RotateLeft32(c, 10);
-  e := e + (data[8] + C2 + ((aa and b) or (not aa and c)));
+  e := e + (LData[8] + C2 + ((aa and b) or (not aa and c)));
   e := TBits.RotateLeft32(e, 12) + d;
   b := TBits.RotateLeft32(b, 10);
 
-  ee := ee + (data[6] + C3 + ((a and cc) or (bb and not cc)));
+  ee := ee + (LData[6] + C3 + ((a and cc) or (bb and not cc)));
   ee := TBits.RotateLeft32(ee, 9) + dd;
   bb := TBits.RotateLeft32(bb, 10);
-  dd := dd + (data[11] + C3 + ((ee and bb) or (a and not bb)));
+  dd := dd + (LData[11] + C3 + ((ee and bb) or (a and not bb)));
   dd := TBits.RotateLeft32(dd, 13) + cc;
   a := TBits.RotateLeft32(a, 10);
-  cc := cc + (data[3] + C3 + ((dd and a) or (ee and not a)));
+  cc := cc + (LData[3] + C3 + ((dd and a) or (ee and not a)));
   cc := TBits.RotateLeft32(cc, 15) + bb;
   ee := TBits.RotateLeft32(ee, 10);
-  bb := bb + (data[7] + C3 + ((cc and ee) or (dd and not ee)));
+  bb := bb + (LData[7] + C3 + ((cc and ee) or (dd and not ee)));
   bb := TBits.RotateLeft32(bb, 7) + a;
   dd := TBits.RotateLeft32(dd, 10);
-  a := a + (data[0] + C3 + ((bb and dd) or (cc and not dd)));
+  a := a + (LData[0] + C3 + ((bb and dd) or (cc and not dd)));
   a := TBits.RotateLeft32(a, 12) + ee;
   cc := TBits.RotateLeft32(cc, 10);
-  ee := ee + (data[13] + C3 + ((a and cc) or (bb and not cc)));
+  ee := ee + (LData[13] + C3 + ((a and cc) or (bb and not cc)));
   ee := TBits.RotateLeft32(ee, 8) + dd;
   bb := TBits.RotateLeft32(bb, 10);
-  dd := dd + (data[5] + C3 + ((ee and bb) or (a and not bb)));
+  dd := dd + (LData[5] + C3 + ((ee and bb) or (a and not bb)));
   dd := TBits.RotateLeft32(dd, 9) + cc;
   a := TBits.RotateLeft32(a, 10);
-  cc := cc + (data[10] + C3 + ((dd and a) or (ee and not a)));
+  cc := cc + (LData[10] + C3 + ((dd and a) or (ee and not a)));
   cc := TBits.RotateLeft32(cc, 11) + bb;
   ee := TBits.RotateLeft32(ee, 10);
-  bb := bb + (data[14] + C3 + ((cc and ee) or (dd and not ee)));
+  bb := bb + (LData[14] + C3 + ((cc and ee) or (dd and not ee)));
   bb := TBits.RotateLeft32(bb, 7) + a;
   dd := TBits.RotateLeft32(dd, 10);
-  a := a + (data[15] + C3 + ((bb and dd) or (cc and not dd)));
+  a := a + (LData[15] + C3 + ((bb and dd) or (cc and not dd)));
   a := TBits.RotateLeft32(a, 7) + ee;
   cc := TBits.RotateLeft32(cc, 10);
-  ee := ee + (data[8] + C3 + ((a and cc) or (bb and not cc)));
+  ee := ee + (LData[8] + C3 + ((a and cc) or (bb and not cc)));
   ee := TBits.RotateLeft32(ee, 12) + dd;
   bb := TBits.RotateLeft32(bb, 10);
-  dd := dd + (data[12] + C3 + ((ee and bb) or (a and not bb)));
+  dd := dd + (LData[12] + C3 + ((ee and bb) or (a and not bb)));
   dd := TBits.RotateLeft32(dd, 7) + cc;
   a := TBits.RotateLeft32(a, 10);
-  cc := cc + (data[4] + C3 + ((dd and a) or (ee and not a)));
+  cc := cc + (LData[4] + C3 + ((dd and a) or (ee and not a)));
   cc := TBits.RotateLeft32(cc, 6) + bb;
   ee := TBits.RotateLeft32(ee, 10);
-  bb := bb + (data[9] + C3 + ((cc and ee) or (dd and not ee)));
+  bb := bb + (LData[9] + C3 + ((cc and ee) or (dd and not ee)));
   bb := TBits.RotateLeft32(bb, 15) + a;
   dd := TBits.RotateLeft32(dd, 10);
-  a := a + (data[1] + C3 + ((bb and dd) or (cc and not dd)));
+  a := a + (LData[1] + C3 + ((bb and dd) or (cc and not dd)));
   a := TBits.RotateLeft32(a, 13) + ee;
   cc := TBits.RotateLeft32(cc, 10);
-  ee := ee + (data[2] + C3 + ((a and cc) or (bb and not cc)));
+  ee := ee + (LData[2] + C3 + ((a and cc) or (bb and not cc)));
   ee := TBits.RotateLeft32(ee, 11) + dd;
   bb := TBits.RotateLeft32(bb, 10);
 
-  d := d + (data[3] + C4 + ((e or not aa) xor bb));
+  d := d + (LData[3] + C4 + ((e or not aa) xor bb));
   d := TBits.RotateLeft32(d, 11) + c;
   aa := TBits.RotateLeft32(aa, 10);
-  c := c + (data[10] + C4 + ((d or not e) xor aa));
+  c := c + (LData[10] + C4 + ((d or not e) xor aa));
   c := TBits.RotateLeft32(c, 13) + bb;
   e := TBits.RotateLeft32(e, 10);
-  bb := bb + (data[14] + C4 + ((c or not d) xor e));
+  bb := bb + (LData[14] + C4 + ((c or not d) xor e));
   bb := TBits.RotateLeft32(bb, 6) + aa;
   d := TBits.RotateLeft32(d, 10);
-  aa := aa + (data[4] + C4 + ((bb or not c) xor d));
+  aa := aa + (LData[4] + C4 + ((bb or not c) xor d));
   aa := TBits.RotateLeft32(aa, 7) + e;
   c := TBits.RotateLeft32(c, 10);
-  e := e + (data[9] + C4 + ((aa or not bb) xor c));
+  e := e + (LData[9] + C4 + ((aa or not bb) xor c));
   e := TBits.RotateLeft32(e, 14) + d;
   bb := TBits.RotateLeft32(bb, 10);
-  d := d + (data[15] + C4 + ((e or not aa) xor bb));
+  d := d + (LData[15] + C4 + ((e or not aa) xor bb));
   d := TBits.RotateLeft32(d, 9) + c;
   aa := TBits.RotateLeft32(aa, 10);
-  c := c + (data[8] + C4 + ((d or not e) xor aa));
+  c := c + (LData[8] + C4 + ((d or not e) xor aa));
   c := TBits.RotateLeft32(c, 13) + bb;
   e := TBits.RotateLeft32(e, 10);
-  bb := bb + (data[1] + C4 + ((c or not d) xor e));
+  bb := bb + (LData[1] + C4 + ((c or not d) xor e));
   bb := TBits.RotateLeft32(bb, 15) + aa;
   d := TBits.RotateLeft32(d, 10);
-  aa := aa + (data[2] + C4 + ((bb or not c) xor d));
+  aa := aa + (LData[2] + C4 + ((bb or not c) xor d));
   aa := TBits.RotateLeft32(aa, 14) + e;
   c := TBits.RotateLeft32(c, 10);
-  e := e + (data[7] + C4 + ((aa or not bb) xor c));
+  e := e + (LData[7] + C4 + ((aa or not bb) xor c));
   e := TBits.RotateLeft32(e, 8) + d;
   bb := TBits.RotateLeft32(bb, 10);
-  d := d + (data[0] + C4 + ((e or not aa) xor bb));
+  d := d + (LData[0] + C4 + ((e or not aa) xor bb));
   d := TBits.RotateLeft32(d, 13) + c;
   aa := TBits.RotateLeft32(aa, 10);
-  c := c + (data[6] + C4 + ((d or not e) xor aa));
+  c := c + (LData[6] + C4 + ((d or not e) xor aa));
   c := TBits.RotateLeft32(c, 6) + bb;
   e := TBits.RotateLeft32(e, 10);
-  bb := bb + (data[13] + C4 + ((c or not d) xor e));
+  bb := bb + (LData[13] + C4 + ((c or not d) xor e));
   bb := TBits.RotateLeft32(bb, 5) + aa;
   d := TBits.RotateLeft32(d, 10);
-  aa := aa + (data[11] + C4 + ((bb or not c) xor d));
+  aa := aa + (LData[11] + C4 + ((bb or not c) xor d));
   aa := TBits.RotateLeft32(aa, 12) + e;
   c := TBits.RotateLeft32(c, 10);
-  e := e + (data[5] + C4 + ((aa or not bb) xor c));
+  e := e + (LData[5] + C4 + ((aa or not bb) xor c));
   e := TBits.RotateLeft32(e, 7) + d;
   bb := TBits.RotateLeft32(bb, 10);
-  d := d + (data[12] + C4 + ((e or not aa) xor bb));
+  d := d + (LData[12] + C4 + ((e or not aa) xor bb));
   d := TBits.RotateLeft32(d, 5) + c;
   aa := TBits.RotateLeft32(aa, 10);
 
-  dd := dd + (data[15] + C5 + ((ee or not a) xor b));
+  dd := dd + (LData[15] + C5 + ((ee or not a) xor b));
   dd := TBits.RotateLeft32(dd, 9) + cc;
   a := TBits.RotateLeft32(a, 10);
-  cc := cc + (data[5] + C5 + ((dd or not ee) xor a));
+  cc := cc + (LData[5] + C5 + ((dd or not ee) xor a));
   cc := TBits.RotateLeft32(cc, 7) + b;
   ee := TBits.RotateLeft32(ee, 10);
-  b := b + (data[1] + C5 + ((cc or not dd) xor ee));
+  b := b + (LData[1] + C5 + ((cc or not dd) xor ee));
   b := TBits.RotateLeft32(b, 15) + a;
   dd := TBits.RotateLeft32(dd, 10);
-  a := a + (data[3] + C5 + ((b or not cc) xor dd));
+  a := a + (LData[3] + C5 + ((b or not cc) xor dd));
   a := TBits.RotateLeft32(a, 11) + ee;
   cc := TBits.RotateLeft32(cc, 10);
-  ee := ee + (data[7] + C5 + ((a or not b) xor cc));
+  ee := ee + (LData[7] + C5 + ((a or not b) xor cc));
   ee := TBits.RotateLeft32(ee, 8) + dd;
   b := TBits.RotateLeft32(b, 10);
-  dd := dd + (data[14] + C5 + ((ee or not a) xor b));
+  dd := dd + (LData[14] + C5 + ((ee or not a) xor b));
   dd := TBits.RotateLeft32(dd, 6) + cc;
   a := TBits.RotateLeft32(a, 10);
-  cc := cc + (data[6] + C5 + ((dd or not ee) xor a));
+  cc := cc + (LData[6] + C5 + ((dd or not ee) xor a));
   cc := TBits.RotateLeft32(cc, 6) + b;
   ee := TBits.RotateLeft32(ee, 10);
-  b := b + (data[9] + C5 + ((cc or not dd) xor ee));
+  b := b + (LData[9] + C5 + ((cc or not dd) xor ee));
   b := TBits.RotateLeft32(b, 14) + a;
   dd := TBits.RotateLeft32(dd, 10);
-  a := a + (data[11] + C5 + ((b or not cc) xor dd));
+  a := a + (LData[11] + C5 + ((b or not cc) xor dd));
   a := TBits.RotateLeft32(a, 12) + ee;
   cc := TBits.RotateLeft32(cc, 10);
-  ee := ee + (data[8] + C5 + ((a or not b) xor cc));
+  ee := ee + (LData[8] + C5 + ((a or not b) xor cc));
   ee := TBits.RotateLeft32(ee, 13) + dd;
   b := TBits.RotateLeft32(b, 10);
-  dd := dd + (data[12] + C5 + ((ee or not a) xor b));
+  dd := dd + (LData[12] + C5 + ((ee or not a) xor b));
   dd := TBits.RotateLeft32(dd, 5) + cc;
   a := TBits.RotateLeft32(a, 10);
-  cc := cc + (data[2] + C5 + ((dd or not ee) xor a));
+  cc := cc + (LData[2] + C5 + ((dd or not ee) xor a));
   cc := TBits.RotateLeft32(cc, 14) + b;
   ee := TBits.RotateLeft32(ee, 10);
-  b := b + (data[10] + C5 + ((cc or not dd) xor ee));
+  b := b + (LData[10] + C5 + ((cc or not dd) xor ee));
   b := TBits.RotateLeft32(b, 13) + a;
   dd := TBits.RotateLeft32(dd, 10);
-  a := a + (data[0] + C5 + ((b or not cc) xor dd));
+  a := a + (LData[0] + C5 + ((b or not cc) xor dd));
   a := TBits.RotateLeft32(a, 13) + ee;
   cc := TBits.RotateLeft32(cc, 10);
-  ee := ee + (data[4] + C5 + ((a or not b) xor cc));
+  ee := ee + (LData[4] + C5 + ((a or not b) xor cc));
   ee := TBits.RotateLeft32(ee, 7) + dd;
   b := TBits.RotateLeft32(b, 10);
-  dd := dd + (data[13] + C5 + ((ee or not a) xor b));
+  dd := dd + (LData[13] + C5 + ((ee or not a) xor b));
   dd := TBits.RotateLeft32(dd, 5) + cc;
   a := TBits.RotateLeft32(a, 10);
 
-  cc := cc + (data[1] + C6 + ((d and aa) or (e and not aa)));
+  cc := cc + (LData[1] + C6 + ((d and aa) or (e and not aa)));
   cc := TBits.RotateLeft32(cc, 11) + bb;
   e := TBits.RotateLeft32(e, 10);
-  bb := bb + (data[9] + C6 + ((cc and e) or (d and not e)));
+  bb := bb + (LData[9] + C6 + ((cc and e) or (d and not e)));
   bb := TBits.RotateLeft32(bb, 12) + aa;
   d := TBits.RotateLeft32(d, 10);
-  aa := aa + (data[11] + C6 + ((bb and d) or (cc and not d)));
+  aa := aa + (LData[11] + C6 + ((bb and d) or (cc and not d)));
   aa := TBits.RotateLeft32(aa, 14) + e;
   cc := TBits.RotateLeft32(cc, 10);
-  e := e + (data[10] + C6 + ((aa and cc) or (bb and not cc)));
+  e := e + (LData[10] + C6 + ((aa and cc) or (bb and not cc)));
   e := TBits.RotateLeft32(e, 15) + d;
   bb := TBits.RotateLeft32(bb, 10);
-  d := d + (data[0] + C6 + ((e and bb) or (aa and not bb)));
+  d := d + (LData[0] + C6 + ((e and bb) or (aa and not bb)));
   d := TBits.RotateLeft32(d, 14) + cc;
   aa := TBits.RotateLeft32(aa, 10);
-  cc := cc + (data[8] + C6 + ((d and aa) or (e and not aa)));
+  cc := cc + (LData[8] + C6 + ((d and aa) or (e and not aa)));
   cc := TBits.RotateLeft32(cc, 15) + bb;
   e := TBits.RotateLeft32(e, 10);
-  bb := bb + (data[12] + C6 + ((cc and e) or (d and not e)));
+  bb := bb + (LData[12] + C6 + ((cc and e) or (d and not e)));
   bb := TBits.RotateLeft32(bb, 9) + aa;
   d := TBits.RotateLeft32(d, 10);
-  aa := aa + (data[4] + C6 + ((bb and d) or (cc and not d)));
+  aa := aa + (LData[4] + C6 + ((bb and d) or (cc and not d)));
   aa := TBits.RotateLeft32(aa, 8) + e;
   cc := TBits.RotateLeft32(cc, 10);
-  e := e + (data[13] + C6 + ((aa and cc) or (bb and not cc)));
+  e := e + (LData[13] + C6 + ((aa and cc) or (bb and not cc)));
   e := TBits.RotateLeft32(e, 9) + d;
   bb := TBits.RotateLeft32(bb, 10);
-  d := d + (data[3] + C6 + ((e and bb) or (aa and not bb)));
+  d := d + (LData[3] + C6 + ((e and bb) or (aa and not bb)));
   d := TBits.RotateLeft32(d, 14) + cc;
   aa := TBits.RotateLeft32(aa, 10);
-  cc := cc + (data[7] + C6 + ((d and aa) or (e and not aa)));
+  cc := cc + (LData[7] + C6 + ((d and aa) or (e and not aa)));
   cc := TBits.RotateLeft32(cc, 5) + bb;
   e := TBits.RotateLeft32(e, 10);
-  bb := bb + (data[15] + C6 + ((cc and e) or (d and not e)));
+  bb := bb + (LData[15] + C6 + ((cc and e) or (d and not e)));
   bb := TBits.RotateLeft32(bb, 6) + aa;
   d := TBits.RotateLeft32(d, 10);
-  aa := aa + (data[14] + C6 + ((bb and d) or (cc and not d)));
+  aa := aa + (LData[14] + C6 + ((bb and d) or (cc and not d)));
   aa := TBits.RotateLeft32(aa, 8) + e;
   cc := TBits.RotateLeft32(cc, 10);
-  e := e + (data[5] + C6 + ((aa and cc) or (bb and not cc)));
+  e := e + (LData[5] + C6 + ((aa and cc) or (bb and not cc)));
   e := TBits.RotateLeft32(e, 6) + d;
   bb := TBits.RotateLeft32(bb, 10);
-  d := d + (data[6] + C6 + ((e and bb) or (aa and not bb)));
+  d := d + (LData[6] + C6 + ((e and bb) or (aa and not bb)));
   d := TBits.RotateLeft32(d, 5) + cc;
   aa := TBits.RotateLeft32(aa, 10);
-  cc := cc + (data[2] + C6 + ((d and aa) or (e and not aa)));
+  cc := cc + (LData[2] + C6 + ((d and aa) or (e and not aa)));
   cc := TBits.RotateLeft32(cc, 12) + bb;
   e := TBits.RotateLeft32(e, 10);
 
-  c := c + (data[8] + C7 + ((dd and ee) or (not dd and a)));
+  c := c + (LData[8] + C7 + ((dd and ee) or (not dd and a)));
   c := TBits.RotateLeft32(c, 15) + b;
   ee := TBits.RotateLeft32(ee, 10);
-  b := b + (data[6] + C7 + ((c and dd) or (not c and ee)));
+  b := b + (LData[6] + C7 + ((c and dd) or (not c and ee)));
   b := TBits.RotateLeft32(b, 5) + a;
   dd := TBits.RotateLeft32(dd, 10);
-  a := a + (data[4] + C7 + ((b and c) or (not b and dd)));
+  a := a + (LData[4] + C7 + ((b and c) or (not b and dd)));
   a := TBits.RotateLeft32(a, 8) + ee;
   c := TBits.RotateLeft32(c, 10);
-  ee := ee + (data[1] + C7 + ((a and b) or (not a and c)));
+  ee := ee + (LData[1] + C7 + ((a and b) or (not a and c)));
   ee := TBits.RotateLeft32(ee, 11) + dd;
   b := TBits.RotateLeft32(b, 10);
-  dd := dd + (data[3] + C7 + ((ee and a) or (not ee and b)));
+  dd := dd + (LData[3] + C7 + ((ee and a) or (not ee and b)));
   dd := TBits.RotateLeft32(dd, 14) + c;
   a := TBits.RotateLeft32(a, 10);
-  c := c + (data[11] + C7 + ((dd and ee) or (not dd and a)));
+  c := c + (LData[11] + C7 + ((dd and ee) or (not dd and a)));
   c := TBits.RotateLeft32(c, 14) + b;
   ee := TBits.RotateLeft32(ee, 10);
-  b := b + (data[15] + C7 + ((c and dd) or (not c and ee)));
+  b := b + (LData[15] + C7 + ((c and dd) or (not c and ee)));
   b := TBits.RotateLeft32(b, 6) + a;
   dd := TBits.RotateLeft32(dd, 10);
-  a := a + (data[0] + C7 + ((b and c) or (not b and dd)));
+  a := a + (LData[0] + C7 + ((b and c) or (not b and dd)));
   a := TBits.RotateLeft32(a, 14) + ee;
   c := TBits.RotateLeft32(c, 10);
-  ee := ee + (data[5] + C7 + ((a and b) or (not a and c)));
+  ee := ee + (LData[5] + C7 + ((a and b) or (not a and c)));
   ee := TBits.RotateLeft32(ee, 6) + dd;
   b := TBits.RotateLeft32(b, 10);
-  dd := dd + (data[12] + C7 + ((ee and a) or (not ee and b)));
+  dd := dd + (LData[12] + C7 + ((ee and a) or (not ee and b)));
   dd := TBits.RotateLeft32(dd, 9) + c;
   a := TBits.RotateLeft32(a, 10);
-  c := c + (data[2] + C7 + ((dd and ee) or (not dd and a)));
+  c := c + (LData[2] + C7 + ((dd and ee) or (not dd and a)));
   c := TBits.RotateLeft32(c, 12) + b;
   ee := TBits.RotateLeft32(ee, 10);
-  b := b + (data[13] + C7 + ((c and dd) or (not c and ee)));
+  b := b + (LData[13] + C7 + ((c and dd) or (not c and ee)));
   b := TBits.RotateLeft32(b, 9) + a;
   dd := TBits.RotateLeft32(dd, 10);
-  a := a + (data[9] + C7 + ((b and c) or (not b and dd)));
+  a := a + (LData[9] + C7 + ((b and c) or (not b and dd)));
   a := TBits.RotateLeft32(a, 12) + ee;
   c := TBits.RotateLeft32(c, 10);
-  ee := ee + (data[7] + C7 + ((a and b) or (not a and c)));
+  ee := ee + (LData[7] + C7 + ((a and b) or (not a and c)));
   ee := TBits.RotateLeft32(ee, 5) + dd;
   b := TBits.RotateLeft32(b, 10);
-  dd := dd + (data[10] + C7 + ((ee and a) or (not ee and b)));
+  dd := dd + (LData[10] + C7 + ((ee and a) or (not ee and b)));
   dd := TBits.RotateLeft32(dd, 15) + c;
   a := TBits.RotateLeft32(a, 10);
-  c := c + (data[14] + C7 + ((dd and ee) or (not dd and a)));
+  c := c + (LData[14] + C7 + ((dd and ee) or (not dd and a)));
   c := TBits.RotateLeft32(c, 8) + b;
   ee := TBits.RotateLeft32(ee, 10);
 
-  bb := bb + (data[4] + C8 + (cc xor (dd or not e)));
+  bb := bb + (LData[4] + C8 + (cc xor (dd or not e)));
   bb := TBits.RotateLeft32(bb, 9) + aa;
   dd := TBits.RotateLeft32(dd, 10);
-  aa := aa + (data[0] + C8 + (bb xor (cc or not dd)));
+  aa := aa + (LData[0] + C8 + (bb xor (cc or not dd)));
   aa := TBits.RotateLeft32(aa, 15) + e;
   cc := TBits.RotateLeft32(cc, 10);
-  e := e + (data[5] + C8 + (aa xor (bb or not cc)));
+  e := e + (LData[5] + C8 + (aa xor (bb or not cc)));
   e := TBits.RotateLeft32(e, 5) + dd;
   bb := TBits.RotateLeft32(bb, 10);
-  dd := dd + (data[9] + C8 + (e xor (aa or not bb)));
+  dd := dd + (LData[9] + C8 + (e xor (aa or not bb)));
   dd := TBits.RotateLeft32(dd, 11) + cc;
   aa := TBits.RotateLeft32(aa, 10);
-  cc := cc + (data[7] + C8 + (dd xor (e or not aa)));
+  cc := cc + (LData[7] + C8 + (dd xor (e or not aa)));
   cc := TBits.RotateLeft32(cc, 6) + bb;
   e := TBits.RotateLeft32(e, 10);
-  bb := bb + (data[12] + C8 + (cc xor (dd or not e)));
+  bb := bb + (LData[12] + C8 + (cc xor (dd or not e)));
   bb := TBits.RotateLeft32(bb, 8) + aa;
   dd := TBits.RotateLeft32(dd, 10);
-  aa := aa + (data[2] + C8 + (bb xor (cc or not dd)));
+  aa := aa + (LData[2] + C8 + (bb xor (cc or not dd)));
   aa := TBits.RotateLeft32(aa, 13) + e;
   cc := TBits.RotateLeft32(cc, 10);
-  e := e + (data[10] + C8 + (aa xor (bb or not cc)));
+  e := e + (LData[10] + C8 + (aa xor (bb or not cc)));
   e := TBits.RotateLeft32(e, 12) + dd;
   bb := TBits.RotateLeft32(bb, 10);
-  dd := dd + (data[14] + C8 + (e xor (aa or not bb)));
+  dd := dd + (LData[14] + C8 + (e xor (aa or not bb)));
   dd := TBits.RotateLeft32(dd, 5) + cc;
   aa := TBits.RotateLeft32(aa, 10);
-  cc := cc + (data[1] + C8 + (dd xor (e or not aa)));
+  cc := cc + (LData[1] + C8 + (dd xor (e or not aa)));
   cc := TBits.RotateLeft32(cc, 12) + bb;
   e := TBits.RotateLeft32(e, 10);
-  bb := bb + (data[3] + C8 + (cc xor (dd or not e)));
+  bb := bb + (LData[3] + C8 + (cc xor (dd or not e)));
   bb := TBits.RotateLeft32(bb, 13) + aa;
   dd := TBits.RotateLeft32(dd, 10);
-  aa := aa + (data[8] + C8 + (bb xor (cc or not dd)));
+  aa := aa + (LData[8] + C8 + (bb xor (cc or not dd)));
   aa := TBits.RotateLeft32(aa, 14) + e;
   cc := TBits.RotateLeft32(cc, 10);
-  e := e + (data[11] + C8 + (aa xor (bb or not cc)));
+  e := e + (LData[11] + C8 + (aa xor (bb or not cc)));
   e := TBits.RotateLeft32(e, 11) + dd;
   bb := TBits.RotateLeft32(bb, 10);
-  dd := dd + (data[6] + C8 + (e xor (aa or not bb)));
+  dd := dd + (LData[6] + C8 + (e xor (aa or not bb)));
   dd := TBits.RotateLeft32(dd, 8) + cc;
   aa := TBits.RotateLeft32(aa, 10);
-  cc := cc + (data[15] + C8 + (dd xor (e or not aa)));
+  cc := cc + (LData[15] + C8 + (dd xor (e or not aa)));
   cc := TBits.RotateLeft32(cc, 5) + bb;
   e := TBits.RotateLeft32(e, 10);
-  bb := bb + (data[13] + C8 + (cc xor (dd or not e)));
+  bb := bb + (LData[13] + C8 + (cc xor (dd or not e)));
   bb := TBits.RotateLeft32(bb, 6) + aa;
   dd := TBits.RotateLeft32(dd, 10);
 
-  b := b + (data[12] + (c xor d xor ee));
+  b := b + (LData[12] + (c xor d xor ee));
   b := TBits.RotateLeft32(b, 8) + a;
   d := TBits.RotateLeft32(d, 10);
-  a := a + (data[15] + (b xor c xor d));
+  a := a + (LData[15] + (b xor c xor d));
   a := TBits.RotateLeft32(a, 5) + ee;
   c := TBits.RotateLeft32(c, 10);
-  ee := ee + (data[10] + (a xor b xor c));
+  ee := ee + (LData[10] + (a xor b xor c));
   ee := TBits.RotateLeft32(ee, 12) + d;
   b := TBits.RotateLeft32(b, 10);
-  d := d + (data[4] + (ee xor a xor b));
+  d := d + (LData[4] + (ee xor a xor b));
   d := TBits.RotateLeft32(d, 9) + c;
   a := TBits.RotateLeft32(a, 10);
-  c := c + (data[1] + (d xor ee xor a));
+  c := c + (LData[1] + (d xor ee xor a));
   c := TBits.RotateLeft32(c, 12) + b;
   ee := TBits.RotateLeft32(ee, 10);
-  b := b + (data[5] + (c xor d xor ee));
+  b := b + (LData[5] + (c xor d xor ee));
   b := TBits.RotateLeft32(b, 5) + a;
   d := TBits.RotateLeft32(d, 10);
-  a := a + (data[8] + (b xor c xor d));
+  a := a + (LData[8] + (b xor c xor d));
   a := TBits.RotateLeft32(a, 14) + ee;
   c := TBits.RotateLeft32(c, 10);
-  ee := ee + (data[7] + (a xor b xor c));
+  ee := ee + (LData[7] + (a xor b xor c));
   ee := TBits.RotateLeft32(ee, 6) + d;
   b := TBits.RotateLeft32(b, 10);
-  d := d + (data[6] + (ee xor a xor b));
+  d := d + (LData[6] + (ee xor a xor b));
   d := TBits.RotateLeft32(d, 8) + c;
   a := TBits.RotateLeft32(a, 10);
-  c := c + (data[2] + (d xor ee xor a));
+  c := c + (LData[2] + (d xor ee xor a));
   c := TBits.RotateLeft32(c, 13) + b;
   ee := TBits.RotateLeft32(ee, 10);
-  b := b + (data[13] + (c xor d xor ee));
+  b := b + (LData[13] + (c xor d xor ee));
   b := TBits.RotateLeft32(b, 6) + a;
   d := TBits.RotateLeft32(d, 10);
-  a := a + (data[14] + (b xor c xor d));
+  a := a + (LData[14] + (b xor c xor d));
   a := TBits.RotateLeft32(a, 5) + ee;
   c := TBits.RotateLeft32(c, 10);
-  ee := ee + (data[0] + (a xor b xor c));
+  ee := ee + (LData[0] + (a xor b xor c));
   ee := TBits.RotateLeft32(ee, 15) + d;
   b := TBits.RotateLeft32(b, 10);
-  d := d + (data[3] + (ee xor a xor b));
+  d := d + (LData[3] + (ee xor a xor b));
   d := TBits.RotateLeft32(d, 13) + c;
   a := TBits.RotateLeft32(a, 10);
-  c := c + (data[9] + (d xor ee xor a));
+  c := c + (LData[9] + (d xor ee xor a));
   c := TBits.RotateLeft32(c, 11) + b;
   ee := TBits.RotateLeft32(ee, 10);
-  b := b + (data[11] + (c xor d xor ee));
+  b := b + (LData[11] + (c xor d xor ee));
   b := TBits.RotateLeft32(b, 11) + a;
   d := TBits.RotateLeft32(d, 10);
 
-  Fm_state[0] := Fm_state[0] + aa;
-  Fm_state[1] := Fm_state[1] + bb;
-  Fm_state[2] := Fm_state[2] + cc;
-  Fm_state[3] := Fm_state[3] + dd;
-  Fm_state[4] := Fm_state[4] + ee;
-  Fm_state[5] := Fm_state[5] + a;
-  Fm_state[6] := Fm_state[6] + b;
-  Fm_state[7] := Fm_state[7] + c;
-  Fm_state[8] := Fm_state[8] + d;
-  Fm_state[9] := Fm_state[9] + e;
-
-  System.FillChar(data, System.SizeOf(data), UInt32(0));
+  FState[0] := FState[0] + aa;
+  FState[1] := FState[1] + bb;
+  FState[2] := FState[2] + cc;
+  FState[3] := FState[3] + dd;
+  FState[4] := FState[4] + ee;
+  FState[5] := FState[5] + a;
+  FState[6] := FState[6] + b;
+  FState[7] := FState[7] + c;
+  FState[8] := FState[8] + d;
+  FState[9] := FState[9] + e;
 
+  System.FillChar(LData, System.SizeOf(LData), UInt32(0));
 end;
 
 end.

+ 24 - 24
src/libraries/hashlib4pascal/HlpRS.pas

@@ -15,8 +15,8 @@ uses
 type
   TRS = class sealed(THash, IHash32, ITransformBlock)
   strict private
-
-    Fm_hash, Fm_a: UInt32;
+  var
+    FHash, FA: UInt32;
 
   const
     B = UInt32(378551);
@@ -24,8 +24,8 @@ type
   public
     constructor Create();
     procedure Initialize(); override;
-    procedure TransformBytes(const a_data: THashLibByteArray;
-      a_index, a_length: Int32); override;
+    procedure TransformBytes(const AData: THashLibByteArray;
+      AIndex, ALength: Int32); override;
     function TransformFinal(): IHashResult; override;
     function Clone(): IHash; override;
   end;
@@ -36,12 +36,12 @@ implementation
 
 function TRS.Clone(): IHash;
 var
-  HashInstance: TRS;
+  LHashInstance: TRS;
 begin
-  HashInstance := TRS.Create();
-  HashInstance.Fm_hash := Fm_hash;
-  HashInstance.Fm_a := Fm_a;
-  result := HashInstance as IHash;
+  LHashInstance := TRS.Create();
+  LHashInstance.FHash := FHash;
+  LHashInstance.FA := FA;
+  result := LHashInstance as IHash;
   result.BufferSize := BufferSize;
 end;
 
@@ -52,34 +52,34 @@ end;
 
 procedure TRS.Initialize;
 begin
-  Fm_hash := 0;
-  Fm_a := 63689;
+  FHash := 0;
+  FA := 63689;
 end;
 
-procedure TRS.TransformBytes(const a_data: THashLibByteArray;
-  a_index, a_length: Int32);
+procedure TRS.TransformBytes(const AData: THashLibByteArray;
+  AIndex, ALength: Int32);
 var
-  i: Int32;
+  LIdx: Int32;
 begin
 {$IFDEF DEBUG}
-  System.Assert(a_index >= 0);
-  System.Assert(a_length >= 0);
-  System.Assert(a_index + a_length <= System.Length(a_data));
+  System.Assert(AIndex >= 0);
+  System.Assert(ALength >= 0);
+  System.Assert(AIndex + ALength <= System.Length(AData));
 {$ENDIF DEBUG}
-  i := a_index;
-  while a_length > 0 do
+  LIdx := AIndex;
+  while ALength > 0 do
   begin
-    Fm_hash := (Fm_hash * Fm_a) + a_data[i];
-    Fm_a := Fm_a * B;
-    System.Inc(i);
-    System.Dec(a_length);
+    FHash := (FHash * FA) + AData[LIdx];
+    FA := FA * B;
+    System.Inc(LIdx);
+    System.Dec(ALength);
   end;
 
 end;
 
 function TRS.TransformFinal: IHashResult;
 begin
-  result := THashResult.Create(Fm_hash);
+  result := THashResult.Create(FHash);
   Initialize();
 end;
 

+ 94 - 102
src/libraries/hashlib4pascal/HlpRadioGatun32.pas

@@ -22,18 +22,17 @@ type
   TRadioGatun32 = class sealed(TBlockHash, ICryptoNotBuildIn, ITransformBlock)
 
   strict private
-
-    Fm_mill: THashLibUInt32Array;
-
-    Fm_belt: THashLibMatrixUInt32Array;
+  var
+    FMill: THashLibUInt32Array;
+    FBelt: THashLibMatrixUInt32Array;
 
     procedure RoundFunction();
 
   strict protected
     procedure Finish(); override;
     function GetResult(): THashLibByteArray; override;
-    procedure TransformBlock(a_data: PByte; a_data_length: Int32;
-      a_index: Int32); override;
+    procedure TransformBlock(AData: PByte; ADataLength: Int32;
+      AIndex: Int32); override;
 
   public
     constructor Create();
@@ -48,187 +47,180 @@ implementation
 
 function TRadioGatun32.Clone(): IHash;
 var
-  HashInstance: TRadioGatun32;
-  Idx: Int32;
+  LHashInstance: TRadioGatun32;
+  LIdx: Int32;
 begin
-  HashInstance := TRadioGatun32.Create();
-  HashInstance.Fm_mill := System.Copy(Fm_mill);
+  LHashInstance := TRadioGatun32.Create();
+  LHashInstance.FMill := System.Copy(FMill);
   // since System.Copy() does not support jagged arrays (multidimensional dynamic arrays, we improvise)
-  for Idx := System.Low(Fm_belt) to System.High(Fm_belt) do
+  for LIdx := System.Low(FBelt) to System.High(FBelt) do
   begin
-    HashInstance.Fm_belt[Idx] := System.Copy(Fm_belt[Idx]);
+    LHashInstance.FBelt[LIdx] := System.Copy(FBelt[LIdx]);
   end;
-  HashInstance.Fm_buffer := Fm_buffer.Clone();
-  HashInstance.Fm_processed_bytes := Fm_processed_bytes;
-  result := HashInstance as IHash;
+  LHashInstance.FBuffer := FBuffer.Clone();
+  LHashInstance.FProcessedBytesCount := FProcessedBytesCount;
+  result := LHashInstance as IHash;
   result.BufferSize := BufferSize;
 end;
 
 constructor TRadioGatun32.Create;
 var
-  i: Int32;
+  LIdx: Int32;
 begin
-
   Inherited Create(32, 12);
-  System.SetLength(Fm_mill, 19);
+  System.SetLength(FMill, 19);
 
-  System.SetLength(Fm_belt, 13);
-  i := 0;
-  while i < 13 do
+  System.SetLength(FBelt, 13);
+  LIdx := 0;
+  while LIdx < 13 do
   begin
-    System.SetLength(Fm_belt[i], 3);
+    System.SetLength(FBelt[LIdx], 3);
 
-    System.Inc(i);
+    System.Inc(LIdx);
   end;
-
 end;
 
 procedure TRadioGatun32.Finish;
 var
-  padding_size, i: Int32;
-  pad: THashLibByteArray;
+  LPaddingSize, LIdx: Int32;
+  LPad: THashLibByteArray;
 begin
-  padding_size := 12 - ((Int32(Fm_processed_bytes)) mod 12);
+  LPaddingSize := 12 - ((Int32(FProcessedBytesCount)) mod 12);
 
-  System.SetLength(pad, padding_size);
-  pad[0] := $01;
-  TransformBytes(pad, 0, padding_size);
-  i := 0;
-  while i < 16 do
+  System.SetLength(LPad, LPaddingSize);
+  LPad[0] := $01;
+  TransformBytes(LPad, 0, LPaddingSize);
+  LIdx := 0;
+  while LIdx < 16 do
   begin
     RoundFunction();
-    System.Inc(i);
+    System.Inc(LIdx);
   end;
-
 end;
 
 function TRadioGatun32.GetResult: THashLibByteArray;
 var
-  tempRes: THashLibUInt32Array;
-  i: Int32;
+  LBuffer: THashLibUInt32Array;
+  LIdx: Int32;
 begin
-  System.SetLength(tempRes, 8);
+  System.SetLength(LBuffer, 8);
 
-  System.SetLength(result, System.Length(tempRes) * System.SizeOf(UInt32));
+  System.SetLength(result, System.Length(LBuffer) * System.SizeOf(UInt32));
 
-  i := 0;
+  LIdx := 0;
 
-  while i < 4 do
+  while LIdx < 4 do
   begin
     RoundFunction();
 
-    System.Move(Fm_mill[1], tempRes[i * 2], 2 * System.SizeOf(UInt32));
-    System.Inc(i);
+    System.Move(FMill[1], LBuffer[LIdx * 2], 2 * System.SizeOf(UInt32));
+    System.Inc(LIdx);
   end;
 
-  TConverters.le32_copy(PCardinal(tempRes), 0, PByte(result), 0,
+  TConverters.le32_copy(PCardinal(LBuffer), 0, PByte(result), 0,
     System.Length(result));
 end;
 
 procedure TRadioGatun32.Initialize;
 var
-  i: Int32;
+  LIdx: Int32;
 begin
+  TArrayUtils.ZeroFill(FMill);
 
-  TArrayUtils.ZeroFill(Fm_mill);
-
-  i := 0;
-  while i < 13 do
+  LIdx := 0;
+  while LIdx < 13 do
   begin
-
-    TArrayUtils.ZeroFill(Fm_belt[i]);
-
-    System.Inc(i);
+    TArrayUtils.ZeroFill(FBelt[LIdx]);
+    System.Inc(LIdx);
   end;
-
   Inherited Initialize();
-
 end;
 
 procedure TRadioGatun32.RoundFunction;
 var
-  q: THashLibUInt32Array;
-  a: array [0 .. 18] of UInt32;
-  i: Int32;
+  LQ: THashLibUInt32Array;
+  LA: array [0 .. 18] of UInt32;
+  LIdx: Int32;
 begin
-
-  q := Fm_belt[12];
-  i := 12;
-  while i > 0 do
+  LQ := FBelt[12];
+  LIdx := 12;
+  while LIdx > 0 do
   begin
-    Fm_belt[i] := Fm_belt[i - 1];
-    System.Dec(i);
+    FBelt[LIdx] := FBelt[LIdx - 1];
+    System.Dec(LIdx);
   end;
 
-  Fm_belt[0] := q;
+  FBelt[0] := LQ;
 
-  i := 0;
-  while i < 12 do
+  LIdx := 0;
+  while LIdx < 12 do
   begin
-    Fm_belt[i + 1][i mod 3] := Fm_belt[i + 1][i mod 3] xor Fm_mill[i + 1];
-    System.Inc(i);
+    FBelt[LIdx + 1][LIdx mod 3] := FBelt[LIdx + 1][LIdx mod 3] xor FMill
+      [LIdx + 1];
+    System.Inc(LIdx);
   end;
 
-  i := 0;
-  while i < 19 do
+  LIdx := 0;
+  while LIdx < 19 do
   begin
-    a[i] := Fm_mill[i] xor (Fm_mill[(i + 1) mod 19] or
-      not Fm_mill[(i + 2) mod 19]);
-    System.Inc(i);
+    LA[LIdx] := FMill[LIdx] xor (FMill[(LIdx + 1) mod 19] or
+      not FMill[(LIdx + 2) mod 19]);
+    System.Inc(LIdx);
   end;
 
-  i := 0;
-  while i < 19 do
+  LIdx := 0;
+  while LIdx < 19 do
   begin
-    Fm_mill[i] := TBits.RotateRight32(a[(7 * i) mod 19], (i * (i + 1)) shr 1);
-    System.Inc(i);
+    FMill[LIdx] := TBits.RotateRight32(LA[(7 * LIdx) mod 19],
+      (LIdx * (LIdx + 1)) shr 1);
+    System.Inc(LIdx);
   end;
 
-  i := 0;
-  while i < 19 do
+  LIdx := 0;
+  while LIdx < 19 do
   begin
-    a[i] := Fm_mill[i] xor Fm_mill[(i + 1) mod 19] xor Fm_mill[(i + 4) mod 19];
-    System.Inc(i);
+    LA[LIdx] := FMill[LIdx] xor FMill[(LIdx + 1) mod 19] xor FMill
+      [(LIdx + 4) mod 19];
+    System.Inc(LIdx);
   end;
 
-  a[0] := a[0] xor 1;
+  LA[0] := LA[0] xor 1;
 
-  i := 0;
-  while i < 19 do
+  LIdx := 0;
+  while LIdx < 19 do
   begin
-    Fm_mill[i] := a[i];
-    System.Inc(i);
+    FMill[LIdx] := LA[LIdx];
+    System.Inc(LIdx);
   end;
 
-  i := 0;
-  while i < 3 do
+  LIdx := 0;
+  while LIdx < 3 do
   begin
-    Fm_mill[i + 13] := Fm_mill[i + 13] xor q[i];
-    System.Inc(i);
+    FMill[LIdx + 13] := FMill[LIdx + 13] xor LQ[LIdx];
+    System.Inc(LIdx);
   end;
 
 end;
 
-procedure TRadioGatun32.TransformBlock(a_data: PByte; a_data_length: Int32;
-  a_index: Int32);
+procedure TRadioGatun32.TransformBlock(AData: PByte; ADataLength: Int32;
+  AIndex: Int32);
 var
-  data: array [0 .. 2] of UInt32;
-  i: Int32;
+  LData: array [0 .. 2] of UInt32;
+  LIdx: Int32;
 begin
-  TConverters.le32_copy(a_data, a_index, @(data[0]), 0, a_data_length);
+  TConverters.le32_copy(AData, AIndex, @(LData[0]), 0, ADataLength);
 
-  i := 0;
-  while i < 3 do
+  LIdx := 0;
+  while LIdx < 3 do
   begin
-    Fm_mill[i + 16] := Fm_mill[i + 16] xor data[i];
-    Fm_belt[0][i] := Fm_belt[0][i] xor data[i];
-
-    System.Inc(i);
+    FMill[LIdx + 16] := FMill[LIdx + 16] xor LData[LIdx];
+    FBelt[0][LIdx] := FBelt[0][LIdx] xor LData[LIdx];
+    System.Inc(LIdx);
   end;
 
   RoundFunction();
 
-  System.FillChar(data, System.SizeOf(data), UInt32(0));
+  System.FillChar(LData, System.SizeOf(LData), UInt32(0));
 end;
 
 end.

+ 94 - 101
src/libraries/hashlib4pascal/HlpRadioGatun64.pas

@@ -22,18 +22,17 @@ type
   TRadioGatun64 = class sealed(TBlockHash, ICryptoNotBuildIn, ITransformBlock)
 
   strict private
-
-    Fm_mill: THashLibUInt64Array;
-
-    Fm_belt: THashLibMatrixUInt64Array;
+  var
+    FMill: THashLibUInt64Array;
+    FBelt: THashLibMatrixUInt64Array;
 
     procedure RoundFunction();
 
   strict protected
     procedure Finish(); override;
     function GetResult(): THashLibByteArray; override;
-    procedure TransformBlock(a_data: PByte; a_data_length: Int32;
-      a_index: Int32); override;
+    procedure TransformBlock(AData: PByte; ADataLength: Int32;
+      AIndex: Int32); override;
 
   public
     constructor Create();
@@ -48,183 +47,177 @@ implementation
 
 function TRadioGatun64.Clone(): IHash;
 var
-  HashInstance: TRadioGatun64;
-  Idx: Int32;
+  LHashInstance: TRadioGatun64;
+  LIdx: Int32;
 begin
-  HashInstance := TRadioGatun64.Create();
-  HashInstance.Fm_mill := System.Copy(Fm_mill);
+  LHashInstance := TRadioGatun64.Create();
+  LHashInstance.FMill := System.Copy(FMill);
   // since System.Copy() does not support jagged arrays (multidimensional dynamic arrays, we improvise)
-  for Idx := System.Low(Fm_belt) to System.High(Fm_belt) do
+  for LIdx := System.Low(FBelt) to System.High(FBelt) do
   begin
-    HashInstance.Fm_belt[Idx] := System.Copy(Fm_belt[Idx]);
+    LHashInstance.FBelt[LIdx] := System.Copy(FBelt[LIdx]);
   end;
-  HashInstance.Fm_buffer := Fm_buffer.Clone();
-  HashInstance.Fm_processed_bytes := Fm_processed_bytes;
-  result := HashInstance as IHash;
+  LHashInstance.FBuffer := FBuffer.Clone();
+  LHashInstance.FProcessedBytesCount := FProcessedBytesCount;
+  result := LHashInstance as IHash;
   result.BufferSize := BufferSize;
 end;
 
 constructor TRadioGatun64.Create;
 var
-  i: Int32;
+  LIdx: Int32;
 begin
-
   Inherited Create(32, 24);
-  System.SetLength(Fm_mill, 19);
+  System.SetLength(FMill, 19);
 
-  System.SetLength(Fm_belt, 13);
-  i := 0;
-  while i < 13 do
+  System.SetLength(FBelt, 13);
+  LIdx := 0;
+  while LIdx < 13 do
   begin
-    System.SetLength(Fm_belt[i], 3);
-
-    System.Inc(i);
+    System.SetLength(FBelt[LIdx], 3);
+    System.Inc(LIdx);
   end;
-
 end;
 
 procedure TRadioGatun64.Finish;
 var
-  padding_size, i: Int32;
-  pad: THashLibByteArray;
+  LPaddingSize, LIdx: Int32;
+  LPad: THashLibByteArray;
 begin
-  padding_size := 24 - ((Int32(Fm_processed_bytes)) mod 24);
+  LPaddingSize := 24 - ((Int32(FProcessedBytesCount)) mod 24);
 
-  System.SetLength(pad, padding_size);
-  pad[0] := $01;
-  TransformBytes(pad, 0, padding_size);
-  i := 0;
-  while i < 16 do
+  System.SetLength(LPad, LPaddingSize);
+  LPad[0] := $01;
+  TransformBytes(LPad, 0, LPaddingSize);
+  LIdx := 0;
+  while LIdx < 16 do
   begin
     RoundFunction();
-    System.Inc(i);
+    System.Inc(LIdx);
   end;
-
 end;
 
 function TRadioGatun64.GetResult: THashLibByteArray;
 var
-  tempRes: THashLibUInt64Array;
-  i: Int32;
+  LBuffer: THashLibUInt64Array;
+  LIdx: Int32;
 begin
-  System.SetLength(tempRes, 4);
+  System.SetLength(LBuffer, 4);
 
-  System.SetLength(result, System.Length(tempRes) * System.SizeOf(UInt64));
-  i := 0;
+  System.SetLength(result, System.Length(LBuffer) * System.SizeOf(UInt64));
+  LIdx := 0;
 
-  while i < 2 do
+  while LIdx < 2 do
   begin
     RoundFunction();
 
-    System.Move(Fm_mill[1], tempRes[i * 2], 2 * System.SizeOf(UInt64));
-    System.Inc(i);
+    System.Move(FMill[1], LBuffer[LIdx * 2], 2 * System.SizeOf(UInt64));
+    System.Inc(LIdx);
   end;
 
-  TConverters.le64_copy(PCardinal(tempRes), 0, PByte(result), 0,
+  TConverters.le64_copy(PCardinal(LBuffer), 0, PByte(result), 0,
     System.Length(result));
 end;
 
 procedure TRadioGatun64.Initialize;
 var
-  i: Int32;
+  LIdx: Int32;
 begin
-  TArrayUtils.ZeroFill(Fm_mill);
+  TArrayUtils.ZeroFill(FMill);
 
-  i := 0;
-  while i < 13 do
+  LIdx := 0;
+  while LIdx < 13 do
   begin
-    TArrayUtils.ZeroFill(Fm_belt[i]);
-    System.Inc(i);
+    TArrayUtils.ZeroFill(FBelt[LIdx]);
+    System.Inc(LIdx);
   end;
 
   Inherited Initialize();
-
 end;
 
 procedure TRadioGatun64.RoundFunction;
 var
-  q: THashLibUInt64Array;
-  a: array [0 .. 18] of UInt64;
-  i: Int32;
+  LQ: THashLibUInt64Array;
+  LA: array [0 .. 18] of UInt64;
+  LIdx: Int32;
 begin
-
-  q := Fm_belt[12];
-  i := 12;
-  while i > 0 do
+  LQ := FBelt[12];
+  LIdx := 12;
+  while LIdx > 0 do
   begin
-    Fm_belt[i] := Fm_belt[i - 1];
-    System.Dec(i);
+    FBelt[LIdx] := FBelt[LIdx - 1];
+    System.Dec(LIdx);
   end;
 
-  Fm_belt[0] := q;
+  FBelt[0] := LQ;
 
-  i := 0;
-  while i < 12 do
+  LIdx := 0;
+  while LIdx < 12 do
   begin
-    Fm_belt[i + 1][i mod 3] := Fm_belt[i + 1][i mod 3] xor Fm_mill[i + 1];
-    System.Inc(i);
+    FBelt[LIdx + 1][LIdx mod 3] := FBelt[LIdx + 1][LIdx mod 3] xor FMill
+      [LIdx + 1];
+    System.Inc(LIdx);
   end;
 
-  i := 0;
-  while i < 19 do
+  LIdx := 0;
+  while LIdx < 19 do
   begin
-    a[i] := Fm_mill[i] xor (Fm_mill[(i + 1) mod 19] or
-      not Fm_mill[(i + 2) mod 19]);
-    System.Inc(i);
+    LA[LIdx] := FMill[LIdx] xor (FMill[(LIdx + 1) mod 19] or
+      not FMill[(LIdx + 2) mod 19]);
+    System.Inc(LIdx);
   end;
 
-  i := 0;
-  while i < 19 do
+  LIdx := 0;
+  while LIdx < 19 do
   begin
-    Fm_mill[i] := TBits.RotateRight64(a[(7 * i) mod 19], (i * (i + 1)) shr 1);
-    System.Inc(i);
+    FMill[LIdx] := TBits.RotateRight64(LA[(7 * LIdx) mod 19],
+      (LIdx * (LIdx + 1)) shr 1);
+    System.Inc(LIdx);
   end;
 
-  i := 0;
-  while i < 19 do
+  LIdx := 0;
+  while LIdx < 19 do
   begin
-    a[i] := Fm_mill[i] xor Fm_mill[(i + 1) mod 19] xor Fm_mill[(i + 4) mod 19];
-    System.Inc(i);
+    LA[LIdx] := FMill[LIdx] xor FMill[(LIdx + 1) mod 19] xor FMill
+      [(LIdx + 4) mod 19];
+    System.Inc(LIdx);
   end;
 
-  a[0] := a[0] xor 1;
+  LA[0] := LA[0] xor 1;
 
-  i := 0;
-  while i < 19 do
+  LIdx := 0;
+  while LIdx < 19 do
   begin
-    Fm_mill[i] := a[i];
-    System.Inc(i);
+    FMill[LIdx] := LA[LIdx];
+    System.Inc(LIdx);
   end;
 
-  i := 0;
-  while i < 3 do
+  LIdx := 0;
+  while LIdx < 3 do
   begin
-    Fm_mill[i + 13] := Fm_mill[i + 13] xor q[i];
-    System.Inc(i);
+    FMill[LIdx + 13] := FMill[LIdx + 13] xor LQ[LIdx];
+    System.Inc(LIdx);
   end;
-
 end;
 
-procedure TRadioGatun64.TransformBlock(a_data: PByte; a_data_length: Int32;
-  a_index: Int32);
+procedure TRadioGatun64.TransformBlock(AData: PByte; ADataLength: Int32;
+  AIndex: Int32);
 var
-  data: array [0 .. 2] of UInt64;
-  i: Int32;
+  LData: array [0 .. 2] of UInt64;
+  LIdx: Int32;
 begin
-
-  TConverters.le64_copy(a_data, a_index, @(data[0]), 0, a_data_length);
-  i := 0;
-  while i < 3 do
+  TConverters.le64_copy(AData, AIndex, @(LData[0]), 0, ADataLength);
+  LIdx := 0;
+  while LIdx < 3 do
   begin
-    Fm_mill[i + 16] := Fm_mill[i + 16] xor data[i];
-    Fm_belt[0][i] := Fm_belt[0][i] xor data[i];
-
-    System.Inc(i);
+    FMill[LIdx + 16] := FMill[LIdx + 16] xor LData[LIdx];
+    FBelt[0][LIdx] := FBelt[0][LIdx] xor LData[LIdx];
+    System.Inc(LIdx);
   end;
 
   RoundFunction();
 
-  System.FillChar(data, System.SizeOf(data), UInt64(0));
+  System.FillChar(LData, System.SizeOf(LData), UInt64(0));
 end;
 
 end.

+ 21 - 23
src/libraries/hashlib4pascal/HlpRotating.pas

@@ -16,14 +16,14 @@ uses
 type
   TRotating = class sealed(THash, IHash32, ITransformBlock)
   strict private
-
-    Fm_hash: UInt32;
+  var
+    FHash: UInt32;
 
   public
     constructor Create();
     procedure Initialize(); override;
-    procedure TransformBytes(const a_data: THashLibByteArray;
-      a_index, a_length: Int32); override;
+    procedure TransformBytes(const AData: THashLibByteArray;
+      AIndex, ALength: Int32); override;
     function TransformFinal(): IHashResult; override;
     function Clone(): IHash; override;
   end;
@@ -34,11 +34,11 @@ implementation
 
 function TRotating.Clone(): IHash;
 var
-  HashInstance: TRotating;
+  LHashInstance: TRotating;
 begin
-  HashInstance := TRotating.Create();
-  HashInstance.Fm_hash := Fm_hash;
-  result := HashInstance as IHash;
+  LHashInstance := TRotating.Create();
+  LHashInstance.FHash := FHash;
+  result := LHashInstance as IHash;
   result.BufferSize := BufferSize;
 end;
 
@@ -49,33 +49,31 @@ end;
 
 procedure TRotating.Initialize;
 begin
-  Fm_hash := 0;
+  FHash := 0;
 end;
 
-procedure TRotating.TransformBytes(const a_data: THashLibByteArray;
-  a_index, a_length: Int32);
+procedure TRotating.TransformBytes(const AData: THashLibByteArray;
+  AIndex, ALength: Int32);
 var
-  i: Int32;
+  LIdx: Int32;
 begin
 {$IFDEF DEBUG}
-  System.Assert(a_index >= 0);
-  System.Assert(a_length >= 0);
-  System.Assert(a_index + a_length <= System.Length(a_data));
+  System.Assert(AIndex >= 0);
+  System.Assert(ALength >= 0);
+  System.Assert(AIndex + ALength <= System.Length(AData));
 {$ENDIF DEBUG}
-  i := a_index;
-  while a_length > 0 do
+  LIdx := AIndex;
+  while ALength > 0 do
   begin
-
-    Fm_hash := TBits.RotateLeft32(Fm_hash, 4) xor a_data[i];
-    System.Inc(i);
-    System.Dec(a_length);
+    FHash := TBits.RotateLeft32(FHash, 4) xor AData[LIdx];
+    System.Inc(LIdx);
+    System.Dec(ALength);
   end;
-
 end;
 
 function TRotating.TransformFinal: IHashResult;
 begin
-  result := THashResult.Create(Fm_hash);
+  result := THashResult.Create(FHash);
   Initialize();
 end;
 

+ 22 - 23
src/libraries/hashlib4pascal/HlpSDBM.pas

@@ -15,14 +15,14 @@ uses
 type
   TSDBM = class sealed(THash, IHash32, ITransformBlock)
   strict private
-
-    Fm_hash: UInt32;
+  var
+    FHash: UInt32;
 
   public
     constructor Create();
     procedure Initialize(); override;
-    procedure TransformBytes(const a_data: THashLibByteArray;
-      a_index, a_length: Int32); override;
+    procedure TransformBytes(const AData: THashLibByteArray;
+      AIndex, ALength: Int32); override;
     function TransformFinal(): IHashResult; override;
     function Clone(): IHash; override;
   end;
@@ -33,11 +33,11 @@ implementation
 
 function TSDBM.Clone(): IHash;
 var
-  HashInstance: TSDBM;
+  LHashInstance: TSDBM;
 begin
-  HashInstance := TSDBM.Create();
-  HashInstance.Fm_hash := Fm_hash;
-  result := HashInstance as IHash;
+  LHashInstance := TSDBM.Create();
+  LHashInstance.FHash := FHash;
+  result := LHashInstance as IHash;
   result.BufferSize := BufferSize;
 end;
 
@@ -48,33 +48,32 @@ end;
 
 procedure TSDBM.Initialize;
 begin
-  Fm_hash := 0;
+  FHash := 0;
 end;
 
-procedure TSDBM.TransformBytes(const a_data: THashLibByteArray;
-  a_index, a_length: Int32);
+procedure TSDBM.TransformBytes(const AData: THashLibByteArray;
+  AIndex, ALength: Int32);
 var
-  i: Int32;
+  LIdx: Int32;
 begin
 {$IFDEF DEBUG}
-  System.Assert(a_index >= 0);
-  System.Assert(a_length >= 0);
-  System.Assert(a_index + a_length <= System.Length(a_data));
+  System.Assert(AIndex >= 0);
+  System.Assert(ALength >= 0);
+  System.Assert(AIndex + ALength <= System.Length(AData));
 {$ENDIF DEBUG}
-  i := a_index;
-  while a_length > 0 do
+  LIdx := AIndex;
+  while ALength > 0 do
   begin
-    Fm_hash := UInt32(a_data[i] + Int64(Fm_hash shl 6) + Int64(Fm_hash shl 16)
-      - Fm_hash);
-    System.Inc(i);
-    System.Dec(a_length);
+    FHash := UInt32(AData[LIdx] + Int64(FHash shl 6) +
+      Int64(FHash shl 16) - FHash);
+    System.Inc(LIdx);
+    System.Dec(ALength);
   end;
-
 end;
 
 function TSDBM.TransformFinal: IHashResult;
 begin
-  result := THashResult.Create(Fm_hash);
+  result := THashResult.Create(FHash);
   Initialize();
 end;
 

+ 265 - 272
src/libraries/hashlib4pascal/HlpSHA0.pas

@@ -24,8 +24,8 @@ type
   TSHA0 = class(TBlockHash, ICryptoNotBuildIn, ITransformBlock)
 
   strict protected
-
-    Fm_state: THashLibUInt32Array;
+  var
+    FState: THashLibUInt32Array;
 
 {$REGION 'Consts'}
 
@@ -38,9 +38,9 @@ type
 
 {$ENDREGION}
     procedure Finish(); override;
-    procedure Expand(a_data: PCardinal); virtual;
-    procedure TransformBlock(a_data: PByte; a_data_length: Int32;
-      a_index: Int32); override;
+    procedure Expand(AData: PCardinal); virtual;
+    procedure TransformBlock(AData: PByte; ADataLength: Int32;
+      AIndex: Int32); override;
     function GetResult(): THashLibByteArray; override;
 
   public
@@ -56,526 +56,519 @@ implementation
 
 function TSHA0.Clone(): IHash;
 var
-  HashInstance: TSHA0;
+  LHashInstance: TSHA0;
 begin
-  HashInstance := TSHA0.Create();
-  HashInstance.Fm_state := System.Copy(Fm_state);
-  HashInstance.Fm_buffer := Fm_buffer.Clone();
-  HashInstance.Fm_processed_bytes := Fm_processed_bytes;
-  result := HashInstance as IHash;
+  LHashInstance := TSHA0.Create();
+  LHashInstance.FState := System.Copy(FState);
+  LHashInstance.FBuffer := FBuffer.Clone();
+  LHashInstance.FProcessedBytesCount := FProcessedBytesCount;
+  result := LHashInstance as IHash;
   result.BufferSize := BufferSize;
 end;
 
 constructor TSHA0.Create;
 begin
   Inherited Create(20, 64);
-  System.SetLength(Fm_state, 5);
+  System.SetLength(FState, 5);
 end;
 
-procedure TSHA0.Expand(a_data: PCardinal);
+procedure TSHA0.Expand(AData: PCardinal);
 {$IFNDEF USE_UNROLLED_VARIANT}
 var
-  j: Int32;
+  LJdx: Int32;
 {$ENDIF USE_UNROLLED_VARIANT}
 begin
-
 {$IFDEF USE_UNROLLED_VARIANT}
-  a_data[16] := ((a_data[16 - 3] xor a_data[16 - 8]) xor a_data[16 - 14])
-    xor a_data[0];
-  a_data[17] := ((a_data[17 - 3] xor a_data[17 - 8]) xor a_data[17 - 14])
-    xor a_data[17 - 16];
-  a_data[18] := ((a_data[18 - 3] xor a_data[18 - 8]) xor a_data[18 - 14])
-    xor a_data[18 - 16];
-  a_data[19] := ((a_data[19 - 3] xor a_data[19 - 8]) xor a_data[19 - 14])
-    xor a_data[19 - 16];
-  a_data[20] := ((a_data[20 - 3] xor a_data[20 - 8]) xor a_data[20 - 14])
-    xor a_data[20 - 16];
-  a_data[21] := ((a_data[21 - 3] xor a_data[21 - 8]) xor a_data[21 - 14])
-    xor a_data[21 - 16];
-  a_data[22] := ((a_data[22 - 3] xor a_data[22 - 8]) xor a_data[22 - 14])
-    xor a_data[22 - 16];
-  a_data[23] := ((a_data[23 - 3] xor a_data[23 - 8]) xor a_data[23 - 14])
-    xor a_data[23 - 16];
-  a_data[24] := ((a_data[24 - 3] xor a_data[24 - 8]) xor a_data[24 - 14])
-    xor a_data[24 - 16];
-  a_data[25] := ((a_data[25 - 3] xor a_data[25 - 8]) xor a_data[25 - 14])
-    xor a_data[25 - 16];
-  a_data[26] := ((a_data[26 - 3] xor a_data[26 - 8]) xor a_data[26 - 14])
-    xor a_data[26 - 16];
-  a_data[27] := ((a_data[27 - 3] xor a_data[27 - 8]) xor a_data[27 - 14])
-    xor a_data[27 - 16];
-  a_data[28] := ((a_data[28 - 3] xor a_data[28 - 8]) xor a_data[28 - 14])
-    xor a_data[28 - 16];
-  a_data[29] := ((a_data[29 - 3] xor a_data[29 - 8]) xor a_data[29 - 14])
-    xor a_data[29 - 16];
-  a_data[30] := ((a_data[30 - 3] xor a_data[30 - 8]) xor a_data[30 - 14])
-    xor a_data[30 - 16];
-  a_data[31] := ((a_data[31 - 3] xor a_data[31 - 8]) xor a_data[31 - 14])
-    xor a_data[31 - 16];
-  a_data[32] := ((a_data[32 - 3] xor a_data[32 - 8]) xor a_data[32 - 14])
-    xor a_data[32 - 16];
-  a_data[33] := ((a_data[33 - 3] xor a_data[33 - 8]) xor a_data[33 - 14])
-    xor a_data[33 - 16];
-  a_data[34] := ((a_data[34 - 3] xor a_data[34 - 8]) xor a_data[34 - 14])
-    xor a_data[34 - 16];
-  a_data[35] := ((a_data[35 - 3] xor a_data[35 - 8]) xor a_data[35 - 14])
-    xor a_data[35 - 16];
-  a_data[36] := ((a_data[36 - 3] xor a_data[36 - 8]) xor a_data[36 - 14])
-    xor a_data[36 - 16];
-  a_data[37] := ((a_data[37 - 3] xor a_data[37 - 8]) xor a_data[37 - 14])
-    xor a_data[37 - 16];
-  a_data[38] := ((a_data[38 - 3] xor a_data[38 - 8]) xor a_data[38 - 14])
-    xor a_data[38 - 16];
-  a_data[39] := ((a_data[39 - 3] xor a_data[39 - 8]) xor a_data[39 - 14])
-    xor a_data[39 - 16];
-  a_data[40] := ((a_data[40 - 3] xor a_data[40 - 8]) xor a_data[40 - 14])
-    xor a_data[40 - 16];
-  a_data[41] := ((a_data[41 - 3] xor a_data[41 - 8]) xor a_data[41 - 14])
-    xor a_data[41 - 16];
-  a_data[42] := ((a_data[42 - 3] xor a_data[42 - 8]) xor a_data[42 - 14])
-    xor a_data[42 - 16];
-  a_data[43] := ((a_data[43 - 3] xor a_data[43 - 8]) xor a_data[43 - 14])
-    xor a_data[43 - 16];
-  a_data[44] := ((a_data[44 - 3] xor a_data[44 - 8]) xor a_data[44 - 14])
-    xor a_data[44 - 16];
-  a_data[45] := ((a_data[45 - 3] xor a_data[45 - 8]) xor a_data[45 - 14])
-    xor a_data[45 - 16];
-  a_data[46] := ((a_data[46 - 3] xor a_data[46 - 8]) xor a_data[46 - 14])
-    xor a_data[46 - 16];
-  a_data[47] := ((a_data[47 - 3] xor a_data[47 - 8]) xor a_data[47 - 14])
-    xor a_data[47 - 16];
-  a_data[48] := ((a_data[48 - 3] xor a_data[48 - 8]) xor a_data[48 - 14])
-    xor a_data[48 - 16];
-  a_data[49] := ((a_data[49 - 3] xor a_data[49 - 8]) xor a_data[49 - 14])
-    xor a_data[49 - 16];
-  a_data[50] := ((a_data[50 - 3] xor a_data[50 - 8]) xor a_data[50 - 14])
-    xor a_data[50 - 16];
-  a_data[51] := ((a_data[51 - 3] xor a_data[51 - 8]) xor a_data[51 - 14])
-    xor a_data[51 - 16];
-  a_data[52] := ((a_data[52 - 3] xor a_data[52 - 8]) xor a_data[52 - 14])
-    xor a_data[52 - 16];
-  a_data[53] := ((a_data[53 - 3] xor a_data[53 - 8]) xor a_data[53 - 14])
-    xor a_data[53 - 16];
-  a_data[54] := ((a_data[54 - 3] xor a_data[54 - 8]) xor a_data[54 - 14])
-    xor a_data[54 - 16];
-  a_data[55] := ((a_data[55 - 3] xor a_data[55 - 8]) xor a_data[55 - 14])
-    xor a_data[55 - 16];
-  a_data[56] := ((a_data[56 - 3] xor a_data[56 - 8]) xor a_data[56 - 14])
-    xor a_data[56 - 16];
-  a_data[57] := ((a_data[57 - 3] xor a_data[57 - 8]) xor a_data[57 - 14])
-    xor a_data[57 - 16];
-  a_data[58] := ((a_data[58 - 3] xor a_data[58 - 8]) xor a_data[58 - 14])
-    xor a_data[58 - 16];
-  a_data[59] := ((a_data[59 - 3] xor a_data[59 - 8]) xor a_data[59 - 14])
-    xor a_data[59 - 16];
-  a_data[60] := ((a_data[60 - 3] xor a_data[60 - 8]) xor a_data[60 - 14])
-    xor a_data[60 - 16];
-  a_data[61] := ((a_data[61 - 3] xor a_data[61 - 8]) xor a_data[61 - 14])
-    xor a_data[61 - 16];
-  a_data[62] := ((a_data[62 - 3] xor a_data[62 - 8]) xor a_data[62 - 14])
-    xor a_data[62 - 16];
-  a_data[63] := ((a_data[63 - 3] xor a_data[63 - 8]) xor a_data[63 - 14])
-    xor a_data[63 - 16];
-  a_data[64] := ((a_data[64 - 3] xor a_data[64 - 8]) xor a_data[64 - 14])
-    xor a_data[64 - 16];
-  a_data[65] := ((a_data[65 - 3] xor a_data[65 - 8]) xor a_data[65 - 14])
-    xor a_data[65 - 16];
-  a_data[66] := ((a_data[66 - 3] xor a_data[66 - 8]) xor a_data[66 - 14])
-    xor a_data[66 - 16];
-  a_data[67] := ((a_data[67 - 3] xor a_data[67 - 8]) xor a_data[67 - 14])
-    xor a_data[67 - 16];
-  a_data[68] := ((a_data[68 - 3] xor a_data[68 - 8]) xor a_data[68 - 14])
-    xor a_data[68 - 16];
-  a_data[69] := ((a_data[69 - 3] xor a_data[69 - 8]) xor a_data[69 - 14])
-    xor a_data[69 - 16];
-  a_data[70] := ((a_data[70 - 3] xor a_data[70 - 8]) xor a_data[70 - 14])
-    xor a_data[70 - 16];
-  a_data[71] := ((a_data[71 - 3] xor a_data[71 - 8]) xor a_data[71 - 14])
-    xor a_data[71 - 16];
-  a_data[72] := ((a_data[72 - 3] xor a_data[72 - 8]) xor a_data[72 - 14])
-    xor a_data[72 - 16];
-  a_data[73] := ((a_data[73 - 3] xor a_data[73 - 8]) xor a_data[73 - 14])
-    xor a_data[73 - 16];
-  a_data[74] := ((a_data[74 - 3] xor a_data[74 - 8]) xor a_data[74 - 14])
-    xor a_data[74 - 16];
-  a_data[75] := ((a_data[75 - 3] xor a_data[75 - 8]) xor a_data[75 - 14])
-    xor a_data[75 - 16];
-  a_data[76] := ((a_data[76 - 3] xor a_data[76 - 8]) xor a_data[76 - 14])
-    xor a_data[76 - 16];
-  a_data[77] := ((a_data[77 - 3] xor a_data[77 - 8]) xor a_data[77 - 14])
-    xor a_data[77 - 16];
-  a_data[78] := ((a_data[78 - 3] xor a_data[78 - 8]) xor a_data[78 - 14])
-    xor a_data[78 - 16];
-  a_data[79] := ((a_data[79 - 3] xor a_data[79 - 8]) xor a_data[79 - 14])
-    xor a_data[79 - 16];
+  AData[16] := ((AData[16 - 3] xor AData[16 - 8]) xor AData[16 - 14])
+    xor AData[0];
+  AData[17] := ((AData[17 - 3] xor AData[17 - 8]) xor AData[17 - 14])
+    xor AData[17 - 16];
+  AData[18] := ((AData[18 - 3] xor AData[18 - 8]) xor AData[18 - 14])
+    xor AData[18 - 16];
+  AData[19] := ((AData[19 - 3] xor AData[19 - 8]) xor AData[19 - 14])
+    xor AData[19 - 16];
+  AData[20] := ((AData[20 - 3] xor AData[20 - 8]) xor AData[20 - 14])
+    xor AData[20 - 16];
+  AData[21] := ((AData[21 - 3] xor AData[21 - 8]) xor AData[21 - 14])
+    xor AData[21 - 16];
+  AData[22] := ((AData[22 - 3] xor AData[22 - 8]) xor AData[22 - 14])
+    xor AData[22 - 16];
+  AData[23] := ((AData[23 - 3] xor AData[23 - 8]) xor AData[23 - 14])
+    xor AData[23 - 16];
+  AData[24] := ((AData[24 - 3] xor AData[24 - 8]) xor AData[24 - 14])
+    xor AData[24 - 16];
+  AData[25] := ((AData[25 - 3] xor AData[25 - 8]) xor AData[25 - 14])
+    xor AData[25 - 16];
+  AData[26] := ((AData[26 - 3] xor AData[26 - 8]) xor AData[26 - 14])
+    xor AData[26 - 16];
+  AData[27] := ((AData[27 - 3] xor AData[27 - 8]) xor AData[27 - 14])
+    xor AData[27 - 16];
+  AData[28] := ((AData[28 - 3] xor AData[28 - 8]) xor AData[28 - 14])
+    xor AData[28 - 16];
+  AData[29] := ((AData[29 - 3] xor AData[29 - 8]) xor AData[29 - 14])
+    xor AData[29 - 16];
+  AData[30] := ((AData[30 - 3] xor AData[30 - 8]) xor AData[30 - 14])
+    xor AData[30 - 16];
+  AData[31] := ((AData[31 - 3] xor AData[31 - 8]) xor AData[31 - 14])
+    xor AData[31 - 16];
+  AData[32] := ((AData[32 - 3] xor AData[32 - 8]) xor AData[32 - 14])
+    xor AData[32 - 16];
+  AData[33] := ((AData[33 - 3] xor AData[33 - 8]) xor AData[33 - 14])
+    xor AData[33 - 16];
+  AData[34] := ((AData[34 - 3] xor AData[34 - 8]) xor AData[34 - 14])
+    xor AData[34 - 16];
+  AData[35] := ((AData[35 - 3] xor AData[35 - 8]) xor AData[35 - 14])
+    xor AData[35 - 16];
+  AData[36] := ((AData[36 - 3] xor AData[36 - 8]) xor AData[36 - 14])
+    xor AData[36 - 16];
+  AData[37] := ((AData[37 - 3] xor AData[37 - 8]) xor AData[37 - 14])
+    xor AData[37 - 16];
+  AData[38] := ((AData[38 - 3] xor AData[38 - 8]) xor AData[38 - 14])
+    xor AData[38 - 16];
+  AData[39] := ((AData[39 - 3] xor AData[39 - 8]) xor AData[39 - 14])
+    xor AData[39 - 16];
+  AData[40] := ((AData[40 - 3] xor AData[40 - 8]) xor AData[40 - 14])
+    xor AData[40 - 16];
+  AData[41] := ((AData[41 - 3] xor AData[41 - 8]) xor AData[41 - 14])
+    xor AData[41 - 16];
+  AData[42] := ((AData[42 - 3] xor AData[42 - 8]) xor AData[42 - 14])
+    xor AData[42 - 16];
+  AData[43] := ((AData[43 - 3] xor AData[43 - 8]) xor AData[43 - 14])
+    xor AData[43 - 16];
+  AData[44] := ((AData[44 - 3] xor AData[44 - 8]) xor AData[44 - 14])
+    xor AData[44 - 16];
+  AData[45] := ((AData[45 - 3] xor AData[45 - 8]) xor AData[45 - 14])
+    xor AData[45 - 16];
+  AData[46] := ((AData[46 - 3] xor AData[46 - 8]) xor AData[46 - 14])
+    xor AData[46 - 16];
+  AData[47] := ((AData[47 - 3] xor AData[47 - 8]) xor AData[47 - 14])
+    xor AData[47 - 16];
+  AData[48] := ((AData[48 - 3] xor AData[48 - 8]) xor AData[48 - 14])
+    xor AData[48 - 16];
+  AData[49] := ((AData[49 - 3] xor AData[49 - 8]) xor AData[49 - 14])
+    xor AData[49 - 16];
+  AData[50] := ((AData[50 - 3] xor AData[50 - 8]) xor AData[50 - 14])
+    xor AData[50 - 16];
+  AData[51] := ((AData[51 - 3] xor AData[51 - 8]) xor AData[51 - 14])
+    xor AData[51 - 16];
+  AData[52] := ((AData[52 - 3] xor AData[52 - 8]) xor AData[52 - 14])
+    xor AData[52 - 16];
+  AData[53] := ((AData[53 - 3] xor AData[53 - 8]) xor AData[53 - 14])
+    xor AData[53 - 16];
+  AData[54] := ((AData[54 - 3] xor AData[54 - 8]) xor AData[54 - 14])
+    xor AData[54 - 16];
+  AData[55] := ((AData[55 - 3] xor AData[55 - 8]) xor AData[55 - 14])
+    xor AData[55 - 16];
+  AData[56] := ((AData[56 - 3] xor AData[56 - 8]) xor AData[56 - 14])
+    xor AData[56 - 16];
+  AData[57] := ((AData[57 - 3] xor AData[57 - 8]) xor AData[57 - 14])
+    xor AData[57 - 16];
+  AData[58] := ((AData[58 - 3] xor AData[58 - 8]) xor AData[58 - 14])
+    xor AData[58 - 16];
+  AData[59] := ((AData[59 - 3] xor AData[59 - 8]) xor AData[59 - 14])
+    xor AData[59 - 16];
+  AData[60] := ((AData[60 - 3] xor AData[60 - 8]) xor AData[60 - 14])
+    xor AData[60 - 16];
+  AData[61] := ((AData[61 - 3] xor AData[61 - 8]) xor AData[61 - 14])
+    xor AData[61 - 16];
+  AData[62] := ((AData[62 - 3] xor AData[62 - 8]) xor AData[62 - 14])
+    xor AData[62 - 16];
+  AData[63] := ((AData[63 - 3] xor AData[63 - 8]) xor AData[63 - 14])
+    xor AData[63 - 16];
+  AData[64] := ((AData[64 - 3] xor AData[64 - 8]) xor AData[64 - 14])
+    xor AData[64 - 16];
+  AData[65] := ((AData[65 - 3] xor AData[65 - 8]) xor AData[65 - 14])
+    xor AData[65 - 16];
+  AData[66] := ((AData[66 - 3] xor AData[66 - 8]) xor AData[66 - 14])
+    xor AData[66 - 16];
+  AData[67] := ((AData[67 - 3] xor AData[67 - 8]) xor AData[67 - 14])
+    xor AData[67 - 16];
+  AData[68] := ((AData[68 - 3] xor AData[68 - 8]) xor AData[68 - 14])
+    xor AData[68 - 16];
+  AData[69] := ((AData[69 - 3] xor AData[69 - 8]) xor AData[69 - 14])
+    xor AData[69 - 16];
+  AData[70] := ((AData[70 - 3] xor AData[70 - 8]) xor AData[70 - 14])
+    xor AData[70 - 16];
+  AData[71] := ((AData[71 - 3] xor AData[71 - 8]) xor AData[71 - 14])
+    xor AData[71 - 16];
+  AData[72] := ((AData[72 - 3] xor AData[72 - 8]) xor AData[72 - 14])
+    xor AData[72 - 16];
+  AData[73] := ((AData[73 - 3] xor AData[73 - 8]) xor AData[73 - 14])
+    xor AData[73 - 16];
+  AData[74] := ((AData[74 - 3] xor AData[74 - 8]) xor AData[74 - 14])
+    xor AData[74 - 16];
+  AData[75] := ((AData[75 - 3] xor AData[75 - 8]) xor AData[75 - 14])
+    xor AData[75 - 16];
+  AData[76] := ((AData[76 - 3] xor AData[76 - 8]) xor AData[76 - 14])
+    xor AData[76 - 16];
+  AData[77] := ((AData[77 - 3] xor AData[77 - 8]) xor AData[77 - 14])
+    xor AData[77 - 16];
+  AData[78] := ((AData[78 - 3] xor AData[78 - 8]) xor AData[78 - 14])
+    xor AData[78 - 16];
+  AData[79] := ((AData[79 - 3] xor AData[79 - 8]) xor AData[79 - 14])
+    xor AData[79 - 16];
 
 {$ELSE}
-  for j := 16 to 79 do
+  for LJdx := 16 to 79 do
   begin
-    a_data[j] := ((a_data[j - 3] xor a_data[j - 8]) xor a_data[j - 14])
-      xor a_data[j - 16];
+    AData[LJdx] := ((AData[LJdx - 3] xor AData[LJdx - 8]) xor AData[LJdx - 14])
+      xor AData[LJdx - 16];
   end;
 {$ENDIF USE_UNROLLED_VARIANT}
 end;
 
 procedure TSHA0.Finish;
 var
-  bits: UInt64;
-  padindex: Int32;
-  pad: THashLibByteArray;
+  LBits: UInt64;
+  LPadIndex: Int32;
+  LPad: THashLibByteArray;
 begin
-  bits := Fm_processed_bytes * 8;
-  if (Fm_buffer.Pos < 56) then
-
-    padindex := (56 - Fm_buffer.Pos)
+  LBits := FProcessedBytesCount * 8;
+  if (FBuffer.Position < 56) then
+  begin
+    LPadIndex := (56 - FBuffer.Position)
+  end
   else
-    padindex := (120 - Fm_buffer.Pos);
-
-  System.SetLength(pad, padindex + 8);
+  begin
+    LPadIndex := (120 - FBuffer.Position);
+  end;
 
-  pad[0] := $80;
+  System.SetLength(LPad, LPadIndex + 8);
 
-  bits := TConverters.be2me_64(bits);
+  LPad[0] := $80;
 
-  TConverters.ReadUInt64AsBytesLE(bits, pad, padindex);
+  LBits := TConverters.be2me_64(LBits);
 
-  padindex := padindex + 8;
+  TConverters.ReadUInt64AsBytesLE(LBits, LPad, LPadIndex);
 
-  TransformBytes(pad, 0, padindex);
+  LPadIndex := LPadIndex + 8;
 
+  TransformBytes(LPad, 0, LPadIndex);
 end;
 
 function TSHA0.GetResult: THashLibByteArray;
 begin
-
   System.SetLength(result, 5 * System.SizeOf(UInt32));
-  TConverters.be32_copy(PCardinal(Fm_state), 0, PByte(result), 0,
+  TConverters.be32_copy(PCardinal(FState), 0, PByte(result), 0,
     System.Length(result));
-
 end;
 
 procedure TSHA0.Initialize;
 begin
-
-  Fm_state[0] := $67452301;
-  Fm_state[1] := $EFCDAB89;
-  Fm_state[2] := $98BADCFE;
-  Fm_state[3] := $10325476;
-  Fm_state[4] := $C3D2E1F0;
-
+  FState[0] := $67452301;
+  FState[1] := $EFCDAB89;
+  FState[2] := $98BADCFE;
+  FState[3] := $10325476;
+  FState[4] := $C3D2E1F0;
   Inherited Initialize();
-
 end;
 
-procedure TSHA0.TransformBlock(a_data: PByte; a_data_length: Int32;
-  a_index: Int32);
+procedure TSHA0.TransformBlock(AData: PByte; ADataLength: Int32; AIndex: Int32);
 var
   A, B, C, D, E: UInt32;
-  data: array [0 .. 79] of UInt32;
-  ptr_data: PCardinal;
+  LData: array [0 .. 79] of UInt32;
+  LPtrData: PCardinal;
 begin
+  LPtrData := @(LData[0]);
 
-  ptr_data := @(data[0]);
-
-  TConverters.be32_copy(a_data, a_index, ptr_data, 0, a_data_length);
+  TConverters.be32_copy(AData, AIndex, LPtrData, 0, ADataLength);
 
-  Expand(ptr_data);
+  Expand(LPtrData);
 
-  A := Fm_state[0];
-  B := Fm_state[1];
-  C := Fm_state[2];
-  D := Fm_state[3];
-  E := Fm_state[4];
+  A := FState[0];
+  B := FState[1];
+  C := FState[2];
+  D := FState[3];
+  E := FState[4];
 
-  E := (data[0] + C1 + TBits.RotateLeft32(A, 5) +
+  E := (LData[0] + C1 + TBits.RotateLeft32(A, 5) +
     (D xor (B and (C xor D)))) + E;
 
   B := TBits.RotateLeft32(B, 30);
-  D := (data[1] + C1 + TBits.RotateLeft32(E, 5) +
+  D := (LData[1] + C1 + TBits.RotateLeft32(E, 5) +
     (C xor (A and (B xor C)))) + D;
 
   A := TBits.RotateLeft32(A, 30);
-  C := (data[2] + C1 + TBits.RotateLeft32(D, 5) +
+  C := (LData[2] + C1 + TBits.RotateLeft32(D, 5) +
     (B xor (E and (A xor B)))) + C;
 
   E := TBits.RotateLeft32(E, 30);
-  B := (data[3] + C1 + TBits.RotateLeft32(C, 5) +
+  B := (LData[3] + C1 + TBits.RotateLeft32(C, 5) +
     (A xor (D and (E xor A)))) + B;
 
   D := TBits.RotateLeft32(D, 30);
-  A := (data[4] + C1 + TBits.RotateLeft32(B, 5) +
+  A := (LData[4] + C1 + TBits.RotateLeft32(B, 5) +
     (E xor (C and (D xor E)))) + A;
 
   C := TBits.RotateLeft32(C, 30);
-  E := (data[5] + C1 + TBits.RotateLeft32(A, 5) +
+  E := (LData[5] + C1 + TBits.RotateLeft32(A, 5) +
     (D xor (B and (C xor D)))) + E;
 
   B := TBits.RotateLeft32(B, 30);
-  D := (data[6] + C1 + TBits.RotateLeft32(E, 5) +
+  D := (LData[6] + C1 + TBits.RotateLeft32(E, 5) +
     (C xor (A and (B xor C)))) + D;
 
   A := TBits.RotateLeft32(A, 30);
-  C := (data[7] + C1 + TBits.RotateLeft32(D, 5) +
+  C := (LData[7] + C1 + TBits.RotateLeft32(D, 5) +
     (B xor (E and (A xor B)))) + C;
 
   E := TBits.RotateLeft32(E, 30);
-  B := (data[8] + C1 + TBits.RotateLeft32(C, 5) +
+  B := (LData[8] + C1 + TBits.RotateLeft32(C, 5) +
     (A xor (D and (E xor A)))) + B;
 
   D := TBits.RotateLeft32(D, 30);
-  A := (data[9] + C1 + TBits.RotateLeft32(B, 5) +
+  A := (LData[9] + C1 + TBits.RotateLeft32(B, 5) +
     (E xor (C and (D xor E)))) + A;
 
   C := TBits.RotateLeft32(C, 30);
-  E := (data[10] + C1 + TBits.RotateLeft32(A, 5) +
+  E := (LData[10] + C1 + TBits.RotateLeft32(A, 5) +
     (D xor (B and (C xor D)))) + E;
 
   B := TBits.RotateLeft32(B, 30);
-  D := (data[11] + C1 + TBits.RotateLeft32(E, 5) +
+  D := (LData[11] + C1 + TBits.RotateLeft32(E, 5) +
     (C xor (A and (B xor C)))) + D;
 
   A := TBits.RotateLeft32(A, 30);
-  C := (data[12] + C1 + TBits.RotateLeft32(D, 5) +
+  C := (LData[12] + C1 + TBits.RotateLeft32(D, 5) +
     (B xor (E and (A xor B)))) + C;
 
   E := TBits.RotateLeft32(E, 30);
-  B := (data[13] + C1 + TBits.RotateLeft32(C, 5) +
+  B := (LData[13] + C1 + TBits.RotateLeft32(C, 5) +
     (A xor (D and (E xor A)))) + B;
 
   D := TBits.RotateLeft32(D, 30);
-  A := (data[14] + C1 + TBits.RotateLeft32(B, 5) +
+  A := (LData[14] + C1 + TBits.RotateLeft32(B, 5) +
     (E xor (C and (D xor E)))) + A;
 
   C := TBits.RotateLeft32(C, 30);
-  E := (data[15] + C1 + TBits.RotateLeft32(A, 5) +
+  E := (LData[15] + C1 + TBits.RotateLeft32(A, 5) +
     (D xor (B and (C xor D)))) + E;
 
   B := TBits.RotateLeft32(B, 30);
-  D := (data[16] + C1 + TBits.RotateLeft32(E, 5) +
+  D := (LData[16] + C1 + TBits.RotateLeft32(E, 5) +
     (C xor (A and (B xor C)))) + D;
 
   A := TBits.RotateLeft32(A, 30);
-  C := (data[17] + C1 + TBits.RotateLeft32(D, 5) +
+  C := (LData[17] + C1 + TBits.RotateLeft32(D, 5) +
     (B xor (E and (A xor B)))) + C;
 
   E := TBits.RotateLeft32(E, 30);
-  B := (data[18] + C1 + TBits.RotateLeft32(C, 5) +
+  B := (LData[18] + C1 + TBits.RotateLeft32(C, 5) +
     (A xor (D and (E xor A)))) + B;
 
   D := TBits.RotateLeft32(D, 30);
-  A := (data[19] + C1 + TBits.RotateLeft32(B, 5) +
+  A := (LData[19] + C1 + TBits.RotateLeft32(B, 5) +
     (E xor (C and (D xor E)))) + A;
 
   C := TBits.RotateLeft32(C, 30);
-  E := (data[20] + C2 + TBits.RotateLeft32(A, 5) + (B xor C xor D)) + E;
+  E := (LData[20] + C2 + TBits.RotateLeft32(A, 5) + (B xor C xor D)) + E;
 
   B := TBits.RotateLeft32(B, 30);
-  D := (data[21] + C2 + TBits.RotateLeft32(E, 5) + (A xor B xor C)) + D;
+  D := (LData[21] + C2 + TBits.RotateLeft32(E, 5) + (A xor B xor C)) + D;
 
   A := TBits.RotateLeft32(A, 30);
-  C := (data[22] + C2 + TBits.RotateLeft32(D, 5) + (E xor A xor B)) + C;
+  C := (LData[22] + C2 + TBits.RotateLeft32(D, 5) + (E xor A xor B)) + C;
 
   E := TBits.RotateLeft32(E, 30);
-  B := (data[23] + C2 + TBits.RotateLeft32(C, 5) + (D xor E xor A)) + B;
+  B := (LData[23] + C2 + TBits.RotateLeft32(C, 5) + (D xor E xor A)) + B;
 
   D := TBits.RotateLeft32(D, 30);
-  A := (data[24] + C2 + TBits.RotateLeft32(B, 5) + (C xor D xor E)) + A;
+  A := (LData[24] + C2 + TBits.RotateLeft32(B, 5) + (C xor D xor E)) + A;
 
   C := TBits.RotateLeft32(C, 30);
-  E := (data[25] + C2 + TBits.RotateLeft32(A, 5) + (B xor C xor D)) + E;
+  E := (LData[25] + C2 + TBits.RotateLeft32(A, 5) + (B xor C xor D)) + E;
 
   B := TBits.RotateLeft32(B, 30);
-  D := (data[26] + C2 + TBits.RotateLeft32(E, 5) + (A xor B xor C)) + D;
+  D := (LData[26] + C2 + TBits.RotateLeft32(E, 5) + (A xor B xor C)) + D;
 
   A := TBits.RotateLeft32(A, 30);
-  C := (data[27] + C2 + TBits.RotateLeft32(D, 5) + (E xor A xor B)) + C;
+  C := (LData[27] + C2 + TBits.RotateLeft32(D, 5) + (E xor A xor B)) + C;
 
   E := TBits.RotateLeft32(E, 30);
-  B := (data[28] + C2 + TBits.RotateLeft32(C, 5) + (D xor E xor A)) + B;
+  B := (LData[28] + C2 + TBits.RotateLeft32(C, 5) + (D xor E xor A)) + B;
 
   D := TBits.RotateLeft32(D, 30);
-  A := (data[29] + C2 + TBits.RotateLeft32(B, 5) + (C xor D xor E)) + A;
+  A := (LData[29] + C2 + TBits.RotateLeft32(B, 5) + (C xor D xor E)) + A;
 
   C := TBits.RotateLeft32(C, 30);
-  E := (data[30] + C2 + TBits.RotateLeft32(A, 5) + (B xor C xor D)) + E;
+  E := (LData[30] + C2 + TBits.RotateLeft32(A, 5) + (B xor C xor D)) + E;
 
   B := TBits.RotateLeft32(B, 30);
-  D := (data[31] + C2 + TBits.RotateLeft32(E, 5) + (A xor B xor C)) + D;
+  D := (LData[31] + C2 + TBits.RotateLeft32(E, 5) + (A xor B xor C)) + D;
 
   A := TBits.RotateLeft32(A, 30);
-  C := (data[32] + C2 + TBits.RotateLeft32(D, 5) + (E xor A xor B)) + C;
+  C := (LData[32] + C2 + TBits.RotateLeft32(D, 5) + (E xor A xor B)) + C;
 
   E := TBits.RotateLeft32(E, 30);
-  B := (data[33] + C2 + TBits.RotateLeft32(C, 5) + (D xor E xor A)) + B;
+  B := (LData[33] + C2 + TBits.RotateLeft32(C, 5) + (D xor E xor A)) + B;
 
   D := TBits.RotateLeft32(D, 30);
-  A := (data[34] + C2 + TBits.RotateLeft32(B, 5) + (C xor D xor E)) + A;
+  A := (LData[34] + C2 + TBits.RotateLeft32(B, 5) + (C xor D xor E)) + A;
 
   C := TBits.RotateLeft32(C, 30);
-  E := (data[35] + C2 + TBits.RotateLeft32(A, 5) + (B xor C xor D)) + E;
+  E := (LData[35] + C2 + TBits.RotateLeft32(A, 5) + (B xor C xor D)) + E;
 
   B := TBits.RotateLeft32(B, 30);
-  D := (data[36] + C2 + TBits.RotateLeft32(E, 5) + (A xor B xor C)) + D;
+  D := (LData[36] + C2 + TBits.RotateLeft32(E, 5) + (A xor B xor C)) + D;
 
   A := TBits.RotateLeft32(A, 30);
-  C := (data[37] + C2 + TBits.RotateLeft32(D, 5) + (E xor A xor B)) + C;
+  C := (LData[37] + C2 + TBits.RotateLeft32(D, 5) + (E xor A xor B)) + C;
 
   E := TBits.RotateLeft32(E, 30);
-  B := (data[38] + C2 + TBits.RotateLeft32(C, 5) + (D xor E xor A)) + B;
+  B := (LData[38] + C2 + TBits.RotateLeft32(C, 5) + (D xor E xor A)) + B;
 
   D := TBits.RotateLeft32(D, 30);
-  A := (data[39] + C2 + TBits.RotateLeft32(B, 5) + (C xor D xor E)) + A;
+  A := (LData[39] + C2 + TBits.RotateLeft32(B, 5) + (C xor D xor E)) + A;
 
   C := TBits.RotateLeft32(C, 30);
-  E := (data[40] + C3 + TBits.RotateLeft32(A, 5) +
+  E := (LData[40] + C3 + TBits.RotateLeft32(A, 5) +
     ((B and C) or (D and (B or C)))) + E;
 
   B := TBits.RotateLeft32(B, 30);
-  D := (data[41] + C3 + TBits.RotateLeft32(E, 5) +
+  D := (LData[41] + C3 + TBits.RotateLeft32(E, 5) +
     ((A and B) or (C and (A or B)))) + D;
 
   A := TBits.RotateLeft32(A, 30);
-  C := (data[42] + C3 + TBits.RotateLeft32(D, 5) +
+  C := (LData[42] + C3 + TBits.RotateLeft32(D, 5) +
     ((E and A) or (B and (E or A)))) + C;
 
   E := TBits.RotateLeft32(E, 30);
-  B := (data[43] + C3 + TBits.RotateLeft32(C, 5) +
+  B := (LData[43] + C3 + TBits.RotateLeft32(C, 5) +
     ((D and E) or (A and (D or E)))) + B;
 
   D := TBits.RotateLeft32(D, 30);
-  A := (data[44] + C3 + TBits.RotateLeft32(B, 5) +
+  A := (LData[44] + C3 + TBits.RotateLeft32(B, 5) +
     ((C and D) or (E and (C or D)))) + A;
 
   C := TBits.RotateLeft32(C, 30);
-  E := (data[45] + C3 + TBits.RotateLeft32(A, 5) +
+  E := (LData[45] + C3 + TBits.RotateLeft32(A, 5) +
     ((B and C) or (D and (B or C)))) + E;
 
   B := TBits.RotateLeft32(B, 30);
-  D := (data[46] + C3 + TBits.RotateLeft32(E, 5) +
+  D := (LData[46] + C3 + TBits.RotateLeft32(E, 5) +
     ((A and B) or (C and (A or B)))) + D;
 
   A := TBits.RotateLeft32(A, 30);
-  C := (data[47] + C3 + TBits.RotateLeft32(D, 5) +
+  C := (LData[47] + C3 + TBits.RotateLeft32(D, 5) +
     ((E and A) or (B and (E or A)))) + C;
 
   E := TBits.RotateLeft32(E, 30);
-  B := (data[48] + C3 + TBits.RotateLeft32(C, 5) +
+  B := (LData[48] + C3 + TBits.RotateLeft32(C, 5) +
     ((D and E) or (A and (D or E)))) + B;
 
   D := TBits.RotateLeft32(D, 30);
-  A := (data[49] + C3 + TBits.RotateLeft32(B, 5) +
+  A := (LData[49] + C3 + TBits.RotateLeft32(B, 5) +
     ((C and D) or (E and (C or D)))) + A;
 
   C := TBits.RotateLeft32(C, 30);
-  E := (data[50] + C3 + TBits.RotateLeft32(A, 5) +
+  E := (LData[50] + C3 + TBits.RotateLeft32(A, 5) +
     ((B and C) or (D and (B or C)))) + E;
 
   B := TBits.RotateLeft32(B, 30);
-  D := (data[51] + C3 + TBits.RotateLeft32(E, 5) +
+  D := (LData[51] + C3 + TBits.RotateLeft32(E, 5) +
     ((A and B) or (C and (A or B)))) + D;
 
   A := TBits.RotateLeft32(A, 30);
-  C := (data[52] + C3 + TBits.RotateLeft32(D, 5) +
+  C := (LData[52] + C3 + TBits.RotateLeft32(D, 5) +
     ((E and A) or (B and (E or A)))) + C;
 
   E := TBits.RotateLeft32(E, 30);
-  B := (data[53] + C3 + TBits.RotateLeft32(C, 5) +
+  B := (LData[53] + C3 + TBits.RotateLeft32(C, 5) +
     ((D and E) or (A and (D or E)))) + B;
 
   D := TBits.RotateLeft32(D, 30);
-  A := (data[54] + C3 + TBits.RotateLeft32(B, 5) +
+  A := (LData[54] + C3 + TBits.RotateLeft32(B, 5) +
     ((C and D) or (E and (C or D)))) + A;
 
   C := TBits.RotateLeft32(C, 30);
-  E := (data[55] + C3 + TBits.RotateLeft32(A, 5) +
+  E := (LData[55] + C3 + TBits.RotateLeft32(A, 5) +
     ((B and C) or (D and (B or C)))) + E;
 
   B := TBits.RotateLeft32(B, 30);
-  D := (data[56] + C3 + TBits.RotateLeft32(E, 5) +
+  D := (LData[56] + C3 + TBits.RotateLeft32(E, 5) +
     ((A and B) or (C and (A or B)))) + D;
 
   A := TBits.RotateLeft32(A, 30);
-  C := (data[57] + C3 + TBits.RotateLeft32(D, 5) +
+  C := (LData[57] + C3 + TBits.RotateLeft32(D, 5) +
     ((E and A) or (B and (E or A)))) + C;
 
   E := TBits.RotateLeft32(E, 30);
-  B := (data[58] + C3 + TBits.RotateLeft32(C, 5) +
+  B := (LData[58] + C3 + TBits.RotateLeft32(C, 5) +
     ((D and E) or (A and (D or E)))) + B;
 
   D := TBits.RotateLeft32(D, 30);
-  A := (data[59] + C3 + TBits.RotateLeft32(B, 5) +
+  A := (LData[59] + C3 + TBits.RotateLeft32(B, 5) +
     ((C and D) or (E and (C or D)))) + A;
 
   C := TBits.RotateLeft32(C, 30);
-  E := (data[60] + C4 + TBits.RotateLeft32(A, 5) + (B xor C xor D)) + E;
+  E := (LData[60] + C4 + TBits.RotateLeft32(A, 5) + (B xor C xor D)) + E;
 
   B := TBits.RotateLeft32(B, 30);
-  D := (data[61] + C4 + TBits.RotateLeft32(E, 5) + (A xor B xor C)) + D;
+  D := (LData[61] + C4 + TBits.RotateLeft32(E, 5) + (A xor B xor C)) + D;
 
   A := TBits.RotateLeft32(A, 30);
-  C := (data[62] + C4 + TBits.RotateLeft32(D, 5) + (E xor A xor B)) + C;
+  C := (LData[62] + C4 + TBits.RotateLeft32(D, 5) + (E xor A xor B)) + C;
 
   E := TBits.RotateLeft32(E, 30);
-  B := (data[63] + C4 + TBits.RotateLeft32(C, 5) + (D xor E xor A)) + B;
+  B := (LData[63] + C4 + TBits.RotateLeft32(C, 5) + (D xor E xor A)) + B;
 
   D := TBits.RotateLeft32(D, 30);
-  A := (data[64] + C4 + TBits.RotateLeft32(B, 5) + (C xor D xor E)) + A;
+  A := (LData[64] + C4 + TBits.RotateLeft32(B, 5) + (C xor D xor E)) + A;
 
   C := TBits.RotateLeft32(C, 30);
-  E := (data[65] + C4 + TBits.RotateLeft32(A, 5) + (B xor C xor D)) + E;
+  E := (LData[65] + C4 + TBits.RotateLeft32(A, 5) + (B xor C xor D)) + E;
 
   B := TBits.RotateLeft32(B, 30);
-  D := (data[66] + C4 + TBits.RotateLeft32(E, 5) + (A xor B xor C)) + D;
+  D := (LData[66] + C4 + TBits.RotateLeft32(E, 5) + (A xor B xor C)) + D;
 
   A := TBits.RotateLeft32(A, 30);
-  C := (data[67] + C4 + TBits.RotateLeft32(D, 5) + (E xor A xor B)) + C;
+  C := (LData[67] + C4 + TBits.RotateLeft32(D, 5) + (E xor A xor B)) + C;
 
   E := TBits.RotateLeft32(E, 30);
-  B := (data[68] + C4 + TBits.RotateLeft32(C, 5) + (D xor E xor A)) + B;
+  B := (LData[68] + C4 + TBits.RotateLeft32(C, 5) + (D xor E xor A)) + B;
 
   D := TBits.RotateLeft32(D, 30);
-  A := (data[69] + C4 + TBits.RotateLeft32(B, 5) + (C xor D xor E)) + A;
+  A := (LData[69] + C4 + TBits.RotateLeft32(B, 5) + (C xor D xor E)) + A;
 
   C := TBits.RotateLeft32(C, 30);
-  E := (data[70] + C4 + TBits.RotateLeft32(A, 5) + (B xor C xor D)) + E;
+  E := (LData[70] + C4 + TBits.RotateLeft32(A, 5) + (B xor C xor D)) + E;
 
   B := TBits.RotateLeft32(B, 30);
-  D := (data[71] + C4 + TBits.RotateLeft32(E, 5) + (A xor B xor C)) + D;
+  D := (LData[71] + C4 + TBits.RotateLeft32(E, 5) + (A xor B xor C)) + D;
 
   A := TBits.RotateLeft32(A, 30);
-  C := (data[72] + C4 + TBits.RotateLeft32(D, 5) + (E xor A xor B)) + C;
+  C := (LData[72] + C4 + TBits.RotateLeft32(D, 5) + (E xor A xor B)) + C;
 
   E := TBits.RotateLeft32(E, 30);
-  B := (data[73] + C4 + TBits.RotateLeft32(C, 5) + (D xor E xor A)) + B;
+  B := (LData[73] + C4 + TBits.RotateLeft32(C, 5) + (D xor E xor A)) + B;
 
   D := TBits.RotateLeft32(D, 30);
-  A := (data[74] + C4 + TBits.RotateLeft32(B, 5) + (C xor D xor E)) + A;
+  A := (LData[74] + C4 + TBits.RotateLeft32(B, 5) + (C xor D xor E)) + A;
 
   C := TBits.RotateLeft32(C, 30);
-  E := (data[75] + C4 + TBits.RotateLeft32(A, 5) + (B xor C xor D)) + E;
+  E := (LData[75] + C4 + TBits.RotateLeft32(A, 5) + (B xor C xor D)) + E;
 
   B := TBits.RotateLeft32(B, 30);
-  D := (data[76] + C4 + TBits.RotateLeft32(E, 5) + (A xor B xor C)) + D;
+  D := (LData[76] + C4 + TBits.RotateLeft32(E, 5) + (A xor B xor C)) + D;
 
   A := TBits.RotateLeft32(A, 30);
-  C := (data[77] + C4 + TBits.RotateLeft32(D, 5) + (E xor A xor B)) + C;
+  C := (LData[77] + C4 + TBits.RotateLeft32(D, 5) + (E xor A xor B)) + C;
 
   E := TBits.RotateLeft32(E, 30);
-  B := (data[78] + C4 + TBits.RotateLeft32(C, 5) + (D xor E xor A)) + B;
+  B := (LData[78] + C4 + TBits.RotateLeft32(C, 5) + (D xor E xor A)) + B;
 
   D := TBits.RotateLeft32(D, 30);
-  A := (data[79] + C4 + TBits.RotateLeft32(B, 5) + (C xor D xor E)) + A;
+  A := (LData[79] + C4 + TBits.RotateLeft32(B, 5) + (C xor D xor E)) + A;
 
   C := TBits.RotateLeft32(C, 30);
 
-  Fm_state[0] := Fm_state[0] + A;
-  Fm_state[1] := Fm_state[1] + B;
-  Fm_state[2] := Fm_state[2] + C;
-  Fm_state[3] := Fm_state[3] + D;
-  Fm_state[4] := Fm_state[4] + E;
-
-  System.FillChar(data, System.SizeOf(data), UInt32(0));
+  FState[0] := FState[0] + A;
+  FState[1] := FState[1] + B;
+  FState[2] := FState[2] + C;
+  FState[3] := FState[3] + D;
+  FState[4] := FState[4] + E;
 
+  System.FillChar(LData, System.SizeOf(LData), UInt32(0));
 end;
 
 end.

+ 142 - 204
src/libraries/hashlib4pascal/HlpSHA1.pas

@@ -17,7 +17,7 @@ type
   TSHA1 = class sealed(TSHA0)
 
   strict protected
-    procedure Expand(a_data: PCardinal); override;
+    procedure Expand(AData: PCardinal); override;
 
   public
     // Not really needed because there is an Intristic default constructor always
@@ -34,13 +34,13 @@ implementation
 
 function TSHA1.Clone(): IHash;
 var
-  HashInstance: TSHA1;
+  LHashInstance: TSHA1;
 begin
-  HashInstance := TSHA1.Create();
-  HashInstance.Fm_state := System.Copy(Fm_state);
-  HashInstance.Fm_buffer := Fm_buffer.Clone();
-  HashInstance.Fm_processed_bytes := Fm_processed_bytes;
-  result := HashInstance as IHash;
+  LHashInstance := TSHA1.Create();
+  LHashInstance.FState := System.Copy(FState);
+  LHashInstance.FBuffer := FBuffer.Clone();
+  LHashInstance.FProcessedBytesCount := FProcessedBytesCount;
+  result := LHashInstance as IHash;
   result.BufferSize := BufferSize;
 end;
 
@@ -49,212 +49,150 @@ begin
   Inherited Create();
 end;
 
-procedure TSHA1.Expand(a_data: PCardinal);
+procedure TSHA1.Expand(AData: PCardinal);
 var
 {$IFNDEF USE_UNROLLED_VARIANT}
-  i: Int32;
+  LIdx: Int32;
 {$ENDIF USE_UNROLLED_VARIANT}
-  T: UInt32;
+  LT: UInt32;
 begin
 
 {$IFDEF USE_UNROLLED_VARIANT}
-  T := a_data[16 - 3] xor a_data[16 - 8] xor a_data[16 - 14] xor a_data[0];
-  a_data[16] := TBits.RotateLeft32(T, 1);
-  T := a_data[17 - 3] xor a_data[17 - 8] xor a_data[17 - 14] xor a_data
-    [17 - 16];
-  a_data[17] := TBits.RotateLeft32(T, 1);
-  T := a_data[18 - 3] xor a_data[18 - 8] xor a_data[18 - 14] xor a_data
-    [18 - 16];
-  a_data[18] := TBits.RotateLeft32(T, 1);
-  T := a_data[19 - 3] xor a_data[19 - 8] xor a_data[19 - 14] xor a_data
-    [19 - 16];
-  a_data[19] := TBits.RotateLeft32(T, 1);
-  T := a_data[20 - 3] xor a_data[20 - 8] xor a_data[20 - 14] xor a_data
-    [20 - 16];
-  a_data[20] := TBits.RotateLeft32(T, 1);
-  T := a_data[21 - 3] xor a_data[21 - 8] xor a_data[21 - 14] xor a_data
-    [21 - 16];
-  a_data[21] := TBits.RotateLeft32(T, 1);
-  T := a_data[22 - 3] xor a_data[22 - 8] xor a_data[22 - 14] xor a_data
-    [22 - 16];
-  a_data[22] := TBits.RotateLeft32(T, 1);
-  T := a_data[23 - 3] xor a_data[23 - 8] xor a_data[23 - 14] xor a_data
-    [23 - 16];
-  a_data[23] := TBits.RotateLeft32(T, 1);
-  T := a_data[24 - 3] xor a_data[24 - 8] xor a_data[24 - 14] xor a_data
-    [24 - 16];
-  a_data[24] := TBits.RotateLeft32(T, 1);
-  T := a_data[25 - 3] xor a_data[25 - 8] xor a_data[25 - 14] xor a_data
-    [25 - 16];
-  a_data[25] := TBits.RotateLeft32(T, 1);
-  T := a_data[26 - 3] xor a_data[26 - 8] xor a_data[26 - 14] xor a_data
-    [26 - 16];
-  a_data[26] := TBits.RotateLeft32(T, 1);
-  T := a_data[27 - 3] xor a_data[27 - 8] xor a_data[27 - 14] xor a_data
-    [27 - 16];
-  a_data[27] := TBits.RotateLeft32(T, 1);
-  T := a_data[28 - 3] xor a_data[28 - 8] xor a_data[28 - 14] xor a_data
-    [28 - 16];
-  a_data[28] := TBits.RotateLeft32(T, 1);
-  T := a_data[29 - 3] xor a_data[29 - 8] xor a_data[29 - 14] xor a_data
-    [29 - 16];
-  a_data[29] := TBits.RotateLeft32(T, 1);
-  T := a_data[30 - 3] xor a_data[30 - 8] xor a_data[30 - 14] xor a_data
-    [30 - 16];
-  a_data[30] := TBits.RotateLeft32(T, 1);
-  T := a_data[31 - 3] xor a_data[31 - 8] xor a_data[31 - 14] xor a_data
-    [31 - 16];
-  a_data[31] := TBits.RotateLeft32(T, 1);
-  T := a_data[32 - 3] xor a_data[32 - 8] xor a_data[32 - 14] xor a_data
-    [32 - 16];
-  a_data[32] := TBits.RotateLeft32(T, 1);
-  T := a_data[33 - 3] xor a_data[33 - 8] xor a_data[33 - 14] xor a_data
-    [33 - 16];
-  a_data[33] := TBits.RotateLeft32(T, 1);
-  T := a_data[34 - 3] xor a_data[34 - 8] xor a_data[34 - 14] xor a_data
-    [34 - 16];
-  a_data[34] := TBits.RotateLeft32(T, 1);
-  T := a_data[35 - 3] xor a_data[35 - 8] xor a_data[35 - 14] xor a_data
-    [35 - 16];
-  a_data[35] := TBits.RotateLeft32(T, 1);
-  T := a_data[36 - 3] xor a_data[36 - 8] xor a_data[36 - 14] xor a_data
-    [36 - 16];
-  a_data[36] := TBits.RotateLeft32(T, 1);
-  T := a_data[37 - 3] xor a_data[37 - 8] xor a_data[37 - 14] xor a_data
-    [37 - 16];
-  a_data[37] := TBits.RotateLeft32(T, 1);
-  T := a_data[38 - 3] xor a_data[38 - 8] xor a_data[38 - 14] xor a_data
-    [38 - 16];
-  a_data[38] := TBits.RotateLeft32(T, 1);
-  T := a_data[39 - 3] xor a_data[39 - 8] xor a_data[39 - 14] xor a_data
-    [39 - 16];
-  a_data[39] := TBits.RotateLeft32(T, 1);
-  T := a_data[40 - 3] xor a_data[40 - 8] xor a_data[40 - 14] xor a_data
-    [40 - 16];
-  a_data[40] := TBits.RotateLeft32(T, 1);
-  T := a_data[41 - 3] xor a_data[41 - 8] xor a_data[41 - 14] xor a_data
-    [41 - 16];
-  a_data[41] := TBits.RotateLeft32(T, 1);
-  T := a_data[42 - 3] xor a_data[42 - 8] xor a_data[42 - 14] xor a_data
-    [42 - 16];
-  a_data[42] := TBits.RotateLeft32(T, 1);
-  T := a_data[43 - 3] xor a_data[43 - 8] xor a_data[43 - 14] xor a_data
-    [43 - 16];
-  a_data[43] := TBits.RotateLeft32(T, 1);
-  T := a_data[44 - 3] xor a_data[44 - 8] xor a_data[44 - 14] xor a_data
-    [44 - 16];
-  a_data[44] := TBits.RotateLeft32(T, 1);
-  T := a_data[45 - 3] xor a_data[45 - 8] xor a_data[45 - 14] xor a_data
-    [45 - 16];
-  a_data[45] := TBits.RotateLeft32(T, 1);
-  T := a_data[46 - 3] xor a_data[46 - 8] xor a_data[46 - 14] xor a_data
-    [46 - 16];
-  a_data[46] := TBits.RotateLeft32(T, 1);
-  T := a_data[47 - 3] xor a_data[47 - 8] xor a_data[47 - 14] xor a_data
-    [47 - 16];
-  a_data[47] := TBits.RotateLeft32(T, 1);
-  T := a_data[48 - 3] xor a_data[48 - 8] xor a_data[48 - 14] xor a_data
-    [48 - 16];
-  a_data[48] := TBits.RotateLeft32(T, 1);
-  T := a_data[49 - 3] xor a_data[49 - 8] xor a_data[49 - 14] xor a_data
-    [49 - 16];
-  a_data[49] := TBits.RotateLeft32(T, 1);
-  T := a_data[50 - 3] xor a_data[50 - 8] xor a_data[50 - 14] xor a_data
-    [50 - 16];
-  a_data[50] := TBits.RotateLeft32(T, 1);
-  T := a_data[51 - 3] xor a_data[51 - 8] xor a_data[51 - 14] xor a_data
-    [51 - 16];
-  a_data[51] := TBits.RotateLeft32(T, 1);
-  T := a_data[52 - 3] xor a_data[52 - 8] xor a_data[52 - 14] xor a_data
-    [52 - 16];
-  a_data[52] := TBits.RotateLeft32(T, 1);
-  T := a_data[53 - 3] xor a_data[53 - 8] xor a_data[53 - 14] xor a_data
-    [53 - 16];
-  a_data[53] := TBits.RotateLeft32(T, 1);
-  T := a_data[54 - 3] xor a_data[54 - 8] xor a_data[54 - 14] xor a_data
-    [54 - 16];
-  a_data[54] := TBits.RotateLeft32(T, 1);
-  T := a_data[55 - 3] xor a_data[55 - 8] xor a_data[55 - 14] xor a_data
-    [55 - 16];
-  a_data[55] := TBits.RotateLeft32(T, 1);
-  T := a_data[56 - 3] xor a_data[56 - 8] xor a_data[56 - 14] xor a_data
-    [56 - 16];
-  a_data[56] := TBits.RotateLeft32(T, 1);
-  T := a_data[57 - 3] xor a_data[57 - 8] xor a_data[57 - 14] xor a_data
-    [57 - 16];
-  a_data[57] := TBits.RotateLeft32(T, 1);
-  T := a_data[58 - 3] xor a_data[58 - 8] xor a_data[58 - 14] xor a_data
-    [58 - 16];
-  a_data[58] := TBits.RotateLeft32(T, 1);
-  T := a_data[59 - 3] xor a_data[59 - 8] xor a_data[59 - 14] xor a_data
-    [59 - 16];
-  a_data[59] := TBits.RotateLeft32(T, 1);
-  T := a_data[60 - 3] xor a_data[60 - 8] xor a_data[60 - 14] xor a_data
-    [60 - 16];
-  a_data[60] := TBits.RotateLeft32(T, 1);
-  T := a_data[61 - 3] xor a_data[61 - 8] xor a_data[61 - 14] xor a_data
-    [61 - 16];
-  a_data[61] := TBits.RotateLeft32(T, 1);
-  T := a_data[62 - 3] xor a_data[62 - 8] xor a_data[62 - 14] xor a_data
-    [62 - 16];
-  a_data[62] := TBits.RotateLeft32(T, 1);
-  T := a_data[63 - 3] xor a_data[63 - 8] xor a_data[63 - 14] xor a_data
-    [63 - 16];
-  a_data[63] := TBits.RotateLeft32(T, 1);
-  T := a_data[64 - 3] xor a_data[64 - 8] xor a_data[64 - 14] xor a_data
-    [64 - 16];
-  a_data[64] := TBits.RotateLeft32(T, 1);
-  T := a_data[65 - 3] xor a_data[65 - 8] xor a_data[65 - 14] xor a_data
-    [65 - 16];
-  a_data[65] := TBits.RotateLeft32(T, 1);
-  T := a_data[66 - 3] xor a_data[66 - 8] xor a_data[66 - 14] xor a_data
-    [66 - 16];
-  a_data[66] := TBits.RotateLeft32(T, 1);
-  T := a_data[67 - 3] xor a_data[67 - 8] xor a_data[67 - 14] xor a_data
-    [67 - 16];
-  a_data[67] := TBits.RotateLeft32(T, 1);
-  T := a_data[68 - 3] xor a_data[68 - 8] xor a_data[68 - 14] xor a_data
-    [68 - 16];
-  a_data[68] := TBits.RotateLeft32(T, 1);
-  T := a_data[69 - 3] xor a_data[69 - 8] xor a_data[69 - 14] xor a_data
-    [69 - 16];
-  a_data[69] := TBits.RotateLeft32(T, 1);
-  T := a_data[70 - 3] xor a_data[70 - 8] xor a_data[70 - 14] xor a_data
-    [70 - 16];
-  a_data[70] := TBits.RotateLeft32(T, 1);
-  T := a_data[71 - 3] xor a_data[71 - 8] xor a_data[71 - 14] xor a_data
-    [71 - 16];
-  a_data[71] := TBits.RotateLeft32(T, 1);
-  T := a_data[72 - 3] xor a_data[72 - 8] xor a_data[72 - 14] xor a_data
-    [72 - 16];
-  a_data[72] := TBits.RotateLeft32(T, 1);
-  T := a_data[73 - 3] xor a_data[73 - 8] xor a_data[73 - 14] xor a_data
-    [73 - 16];
-  a_data[73] := TBits.RotateLeft32(T, 1);
-  T := a_data[74 - 3] xor a_data[74 - 8] xor a_data[74 - 14] xor a_data
-    [74 - 16];
-  a_data[74] := TBits.RotateLeft32(T, 1);
-  T := a_data[75 - 3] xor a_data[75 - 8] xor a_data[75 - 14] xor a_data
-    [75 - 16];
-  a_data[75] := TBits.RotateLeft32(T, 1);
-  T := a_data[76 - 3] xor a_data[76 - 8] xor a_data[76 - 14] xor a_data
-    [76 - 16];
-  a_data[76] := TBits.RotateLeft32(T, 1);
-  T := a_data[77 - 3] xor a_data[77 - 8] xor a_data[77 - 14] xor a_data
-    [77 - 16];
-  a_data[77] := TBits.RotateLeft32(T, 1);
-  T := a_data[78 - 3] xor a_data[78 - 8] xor a_data[78 - 14] xor a_data
-    [78 - 16];
-  a_data[78] := TBits.RotateLeft32(T, 1);
-  T := a_data[79 - 3] xor a_data[79 - 8] xor a_data[79 - 14] xor a_data
-    [79 - 16];
-  a_data[79] := TBits.RotateLeft32(T, 1);
+  LT := AData[16 - 3] xor AData[16 - 8] xor AData[16 - 14] xor AData[0];
+  AData[16] := TBits.RotateLeft32(LT, 1);
+  LT := AData[17 - 3] xor AData[17 - 8] xor AData[17 - 14] xor AData[17 - 16];
+  AData[17] := TBits.RotateLeft32(LT, 1);
+  LT := AData[18 - 3] xor AData[18 - 8] xor AData[18 - 14] xor AData[18 - 16];
+  AData[18] := TBits.RotateLeft32(LT, 1);
+  LT := AData[19 - 3] xor AData[19 - 8] xor AData[19 - 14] xor AData[19 - 16];
+  AData[19] := TBits.RotateLeft32(LT, 1);
+  LT := AData[20 - 3] xor AData[20 - 8] xor AData[20 - 14] xor AData[20 - 16];
+  AData[20] := TBits.RotateLeft32(LT, 1);
+  LT := AData[21 - 3] xor AData[21 - 8] xor AData[21 - 14] xor AData[21 - 16];
+  AData[21] := TBits.RotateLeft32(LT, 1);
+  LT := AData[22 - 3] xor AData[22 - 8] xor AData[22 - 14] xor AData[22 - 16];
+  AData[22] := TBits.RotateLeft32(LT, 1);
+  LT := AData[23 - 3] xor AData[23 - 8] xor AData[23 - 14] xor AData[23 - 16];
+  AData[23] := TBits.RotateLeft32(LT, 1);
+  LT := AData[24 - 3] xor AData[24 - 8] xor AData[24 - 14] xor AData[24 - 16];
+  AData[24] := TBits.RotateLeft32(LT, 1);
+  LT := AData[25 - 3] xor AData[25 - 8] xor AData[25 - 14] xor AData[25 - 16];
+  AData[25] := TBits.RotateLeft32(LT, 1);
+  LT := AData[26 - 3] xor AData[26 - 8] xor AData[26 - 14] xor AData[26 - 16];
+  AData[26] := TBits.RotateLeft32(LT, 1);
+  LT := AData[27 - 3] xor AData[27 - 8] xor AData[27 - 14] xor AData[27 - 16];
+  AData[27] := TBits.RotateLeft32(LT, 1);
+  LT := AData[28 - 3] xor AData[28 - 8] xor AData[28 - 14] xor AData[28 - 16];
+  AData[28] := TBits.RotateLeft32(LT, 1);
+  LT := AData[29 - 3] xor AData[29 - 8] xor AData[29 - 14] xor AData[29 - 16];
+  AData[29] := TBits.RotateLeft32(LT, 1);
+  LT := AData[30 - 3] xor AData[30 - 8] xor AData[30 - 14] xor AData[30 - 16];
+  AData[30] := TBits.RotateLeft32(LT, 1);
+  LT := AData[31 - 3] xor AData[31 - 8] xor AData[31 - 14] xor AData[31 - 16];
+  AData[31] := TBits.RotateLeft32(LT, 1);
+  LT := AData[32 - 3] xor AData[32 - 8] xor AData[32 - 14] xor AData[32 - 16];
+  AData[32] := TBits.RotateLeft32(LT, 1);
+  LT := AData[33 - 3] xor AData[33 - 8] xor AData[33 - 14] xor AData[33 - 16];
+  AData[33] := TBits.RotateLeft32(LT, 1);
+  LT := AData[34 - 3] xor AData[34 - 8] xor AData[34 - 14] xor AData[34 - 16];
+  AData[34] := TBits.RotateLeft32(LT, 1);
+  LT := AData[35 - 3] xor AData[35 - 8] xor AData[35 - 14] xor AData[35 - 16];
+  AData[35] := TBits.RotateLeft32(LT, 1);
+  LT := AData[36 - 3] xor AData[36 - 8] xor AData[36 - 14] xor AData[36 - 16];
+  AData[36] := TBits.RotateLeft32(LT, 1);
+  LT := AData[37 - 3] xor AData[37 - 8] xor AData[37 - 14] xor AData[37 - 16];
+  AData[37] := TBits.RotateLeft32(LT, 1);
+  LT := AData[38 - 3] xor AData[38 - 8] xor AData[38 - 14] xor AData[38 - 16];
+  AData[38] := TBits.RotateLeft32(LT, 1);
+  LT := AData[39 - 3] xor AData[39 - 8] xor AData[39 - 14] xor AData[39 - 16];
+  AData[39] := TBits.RotateLeft32(LT, 1);
+  LT := AData[40 - 3] xor AData[40 - 8] xor AData[40 - 14] xor AData[40 - 16];
+  AData[40] := TBits.RotateLeft32(LT, 1);
+  LT := AData[41 - 3] xor AData[41 - 8] xor AData[41 - 14] xor AData[41 - 16];
+  AData[41] := TBits.RotateLeft32(LT, 1);
+  LT := AData[42 - 3] xor AData[42 - 8] xor AData[42 - 14] xor AData[42 - 16];
+  AData[42] := TBits.RotateLeft32(LT, 1);
+  LT := AData[43 - 3] xor AData[43 - 8] xor AData[43 - 14] xor AData[43 - 16];
+  AData[43] := TBits.RotateLeft32(LT, 1);
+  LT := AData[44 - 3] xor AData[44 - 8] xor AData[44 - 14] xor AData[44 - 16];
+  AData[44] := TBits.RotateLeft32(LT, 1);
+  LT := AData[45 - 3] xor AData[45 - 8] xor AData[45 - 14] xor AData[45 - 16];
+  AData[45] := TBits.RotateLeft32(LT, 1);
+  LT := AData[46 - 3] xor AData[46 - 8] xor AData[46 - 14] xor AData[46 - 16];
+  AData[46] := TBits.RotateLeft32(LT, 1);
+  LT := AData[47 - 3] xor AData[47 - 8] xor AData[47 - 14] xor AData[47 - 16];
+  AData[47] := TBits.RotateLeft32(LT, 1);
+  LT := AData[48 - 3] xor AData[48 - 8] xor AData[48 - 14] xor AData[48 - 16];
+  AData[48] := TBits.RotateLeft32(LT, 1);
+  LT := AData[49 - 3] xor AData[49 - 8] xor AData[49 - 14] xor AData[49 - 16];
+  AData[49] := TBits.RotateLeft32(LT, 1);
+  LT := AData[50 - 3] xor AData[50 - 8] xor AData[50 - 14] xor AData[50 - 16];
+  AData[50] := TBits.RotateLeft32(LT, 1);
+  LT := AData[51 - 3] xor AData[51 - 8] xor AData[51 - 14] xor AData[51 - 16];
+  AData[51] := TBits.RotateLeft32(LT, 1);
+  LT := AData[52 - 3] xor AData[52 - 8] xor AData[52 - 14] xor AData[52 - 16];
+  AData[52] := TBits.RotateLeft32(LT, 1);
+  LT := AData[53 - 3] xor AData[53 - 8] xor AData[53 - 14] xor AData[53 - 16];
+  AData[53] := TBits.RotateLeft32(LT, 1);
+  LT := AData[54 - 3] xor AData[54 - 8] xor AData[54 - 14] xor AData[54 - 16];
+  AData[54] := TBits.RotateLeft32(LT, 1);
+  LT := AData[55 - 3] xor AData[55 - 8] xor AData[55 - 14] xor AData[55 - 16];
+  AData[55] := TBits.RotateLeft32(LT, 1);
+  LT := AData[56 - 3] xor AData[56 - 8] xor AData[56 - 14] xor AData[56 - 16];
+  AData[56] := TBits.RotateLeft32(LT, 1);
+  LT := AData[57 - 3] xor AData[57 - 8] xor AData[57 - 14] xor AData[57 - 16];
+  AData[57] := TBits.RotateLeft32(LT, 1);
+  LT := AData[58 - 3] xor AData[58 - 8] xor AData[58 - 14] xor AData[58 - 16];
+  AData[58] := TBits.RotateLeft32(LT, 1);
+  LT := AData[59 - 3] xor AData[59 - 8] xor AData[59 - 14] xor AData[59 - 16];
+  AData[59] := TBits.RotateLeft32(LT, 1);
+  LT := AData[60 - 3] xor AData[60 - 8] xor AData[60 - 14] xor AData[60 - 16];
+  AData[60] := TBits.RotateLeft32(LT, 1);
+  LT := AData[61 - 3] xor AData[61 - 8] xor AData[61 - 14] xor AData[61 - 16];
+  AData[61] := TBits.RotateLeft32(LT, 1);
+  LT := AData[62 - 3] xor AData[62 - 8] xor AData[62 - 14] xor AData[62 - 16];
+  AData[62] := TBits.RotateLeft32(LT, 1);
+  LT := AData[63 - 3] xor AData[63 - 8] xor AData[63 - 14] xor AData[63 - 16];
+  AData[63] := TBits.RotateLeft32(LT, 1);
+  LT := AData[64 - 3] xor AData[64 - 8] xor AData[64 - 14] xor AData[64 - 16];
+  AData[64] := TBits.RotateLeft32(LT, 1);
+  LT := AData[65 - 3] xor AData[65 - 8] xor AData[65 - 14] xor AData[65 - 16];
+  AData[65] := TBits.RotateLeft32(LT, 1);
+  LT := AData[66 - 3] xor AData[66 - 8] xor AData[66 - 14] xor AData[66 - 16];
+  AData[66] := TBits.RotateLeft32(LT, 1);
+  LT := AData[67 - 3] xor AData[67 - 8] xor AData[67 - 14] xor AData[67 - 16];
+  AData[67] := TBits.RotateLeft32(LT, 1);
+  LT := AData[68 - 3] xor AData[68 - 8] xor AData[68 - 14] xor AData[68 - 16];
+  AData[68] := TBits.RotateLeft32(LT, 1);
+  LT := AData[69 - 3] xor AData[69 - 8] xor AData[69 - 14] xor AData[69 - 16];
+  AData[69] := TBits.RotateLeft32(LT, 1);
+  LT := AData[70 - 3] xor AData[70 - 8] xor AData[70 - 14] xor AData[70 - 16];
+  AData[70] := TBits.RotateLeft32(LT, 1);
+  LT := AData[71 - 3] xor AData[71 - 8] xor AData[71 - 14] xor AData[71 - 16];
+  AData[71] := TBits.RotateLeft32(LT, 1);
+  LT := AData[72 - 3] xor AData[72 - 8] xor AData[72 - 14] xor AData[72 - 16];
+  AData[72] := TBits.RotateLeft32(LT, 1);
+  LT := AData[73 - 3] xor AData[73 - 8] xor AData[73 - 14] xor AData[73 - 16];
+  AData[73] := TBits.RotateLeft32(LT, 1);
+  LT := AData[74 - 3] xor AData[74 - 8] xor AData[74 - 14] xor AData[74 - 16];
+  AData[74] := TBits.RotateLeft32(LT, 1);
+  LT := AData[75 - 3] xor AData[75 - 8] xor AData[75 - 14] xor AData[75 - 16];
+  AData[75] := TBits.RotateLeft32(LT, 1);
+  LT := AData[76 - 3] xor AData[76 - 8] xor AData[76 - 14] xor AData[76 - 16];
+  AData[76] := TBits.RotateLeft32(LT, 1);
+  LT := AData[77 - 3] xor AData[77 - 8] xor AData[77 - 14] xor AData[77 - 16];
+  AData[77] := TBits.RotateLeft32(LT, 1);
+  LT := AData[78 - 3] xor AData[78 - 8] xor AData[78 - 14] xor AData[78 - 16];
+  AData[78] := TBits.RotateLeft32(LT, 1);
+  LT := AData[79 - 3] xor AData[79 - 8] xor AData[79 - 14] xor AData[79 - 16];
+  AData[79] := TBits.RotateLeft32(LT, 1);
 
 {$ELSE}
-  for i := 16 to 79 do
+  for LIdx := 16 to 79 do
   begin
-    T := a_data[i - 3] xor a_data[i - 8] xor a_data[i - 14] xor a_data[i - 16];
-    a_data[i] := TBits.RotateLeft32(T, 1);
+    LT := AData[LIdx - 3] xor AData[LIdx - 8] xor AData[LIdx - 14] xor AData
+      [LIdx - 16];
+    AData[LIdx] := TBits.RotateLeft32(LT, 1);
   end;
 {$ENDIF USE_UNROLLED_VARIANT}
 end;

+ 15 - 17
src/libraries/hashlib4pascal/HlpSHA2_224.pas

@@ -37,13 +37,13 @@ implementation
 
 function TSHA2_224.Clone(): IHash;
 var
-  HashInstance: TSHA2_224;
+  LHashInstance: TSHA2_224;
 begin
-  HashInstance := TSHA2_224.Create();
-  HashInstance.Fm_state := System.Copy(Fm_state);
-  HashInstance.Fm_buffer := Fm_buffer.Clone();
-  HashInstance.Fm_processed_bytes := Fm_processed_bytes;
-  result := HashInstance as IHash;
+  LHashInstance := TSHA2_224.Create();
+  LHashInstance.FState := System.Copy(FState);
+  LHashInstance.FBuffer := FBuffer.Clone();
+  LHashInstance.FProcessedBytesCount := FProcessedBytesCount;
+  result := LHashInstance as IHash;
   result.BufferSize := BufferSize;
 end;
 
@@ -55,23 +55,21 @@ end;
 function TSHA2_224.GetResult: THashLibByteArray;
 begin
   System.SetLength(result, 7 * System.SizeOf(UInt32));
-  TConverters.be32_copy(PCardinal(Fm_state), 0, PByte(result), 0,
+  TConverters.be32_copy(PCardinal(FState), 0, PByte(result), 0,
     System.Length(result));
 end;
 
 procedure TSHA2_224.Initialize;
 begin
-  Fm_state[0] := $C1059ED8;
-  Fm_state[1] := $367CD507;
-  Fm_state[2] := $3070DD17;
-  Fm_state[3] := $F70E5939;
-  Fm_state[4] := $FFC00B31;
-  Fm_state[5] := $68581511;
-  Fm_state[6] := $64F98FA7;
-  Fm_state[7] := $BEFA4FA4;
-
+  FState[0] := $C1059ED8;
+  FState[1] := $367CD507;
+  FState[2] := $3070DD17;
+  FState[3] := $F70E5939;
+  FState[4] := $FFC00B31;
+  FState[5] := $68581511;
+  FState[6] := $64F98FA7;
+  FState[7] := $BEFA4FA4;
   Inherited Initialize();
-
 end;
 
 end.

+ 15 - 19
src/libraries/hashlib4pascal/HlpSHA2_256.pas

@@ -37,13 +37,13 @@ implementation
 
 function TSHA2_256.Clone(): IHash;
 var
-  HashInstance: TSHA2_256;
+  LHashInstance: TSHA2_256;
 begin
-  HashInstance := TSHA2_256.Create();
-  HashInstance.Fm_state := System.Copy(Fm_state);
-  HashInstance.Fm_buffer := Fm_buffer.Clone();
-  HashInstance.Fm_processed_bytes := Fm_processed_bytes;
-  result := HashInstance as IHash;
+  LHashInstance := TSHA2_256.Create();
+  LHashInstance.FState := System.Copy(FState);
+  LHashInstance.FBuffer := FBuffer.Clone();
+  LHashInstance.FProcessedBytesCount := FProcessedBytesCount;
+  result := LHashInstance as IHash;
   result.BufferSize := BufferSize;
 end;
 
@@ -54,26 +54,22 @@ end;
 
 function TSHA2_256.GetResult: THashLibByteArray;
 begin
-
   System.SetLength(result, 8 * System.SizeOf(UInt32));
-  TConverters.be32_copy(PCardinal(Fm_state), 0, PByte(result), 0,
+  TConverters.be32_copy(PCardinal(FState), 0, PByte(result), 0,
     System.Length(result));
-
 end;
 
 procedure TSHA2_256.Initialize;
 begin
-  Fm_state[0] := $6A09E667;
-  Fm_state[1] := $BB67AE85;
-  Fm_state[2] := $3C6EF372;
-  Fm_state[3] := $A54FF53A;
-  Fm_state[4] := $510E527F;
-  Fm_state[5] := $9B05688C;
-  Fm_state[6] := $1F83D9AB;
-  Fm_state[7] := $5BE0CD19;
-
+  FState[0] := $6A09E667;
+  FState[1] := $BB67AE85;
+  FState[2] := $3C6EF372;
+  FState[3] := $A54FF53A;
+  FState[4] := $510E527F;
+  FState[5] := $9B05688C;
+  FState[6] := $1F83D9AB;
+  FState[7] := $5BE0CD19;
   Inherited Initialize();
-
 end;
 
 end.

File diff suppressed because it is too large
+ 353 - 353
src/libraries/hashlib4pascal/HlpSHA2_256Base.pas


+ 15 - 20
src/libraries/hashlib4pascal/HlpSHA2_384.pas

@@ -37,13 +37,13 @@ implementation
 
 function TSHA2_384.Clone(): IHash;
 var
-  HashInstance: TSHA2_384;
+  LHashInstance: TSHA2_384;
 begin
-  HashInstance := TSHA2_384.Create();
-  HashInstance.Fm_state := System.Copy(Fm_state);
-  HashInstance.Fm_buffer := Fm_buffer.Clone();
-  HashInstance.Fm_processed_bytes := Fm_processed_bytes;
-  result := HashInstance as IHash;
+  LHashInstance := TSHA2_384.Create();
+  LHashInstance.FState := System.Copy(FState);
+  LHashInstance.FBuffer := FBuffer.Clone();
+  LHashInstance.FProcessedBytesCount := FProcessedBytesCount;
+  result := LHashInstance as IHash;
   result.BufferSize := BufferSize;
 end;
 
@@ -54,27 +54,22 @@ end;
 
 function TSHA2_384.GetResult: THashLibByteArray;
 begin
-
   System.SetLength(result, 6 * System.SizeOf(UInt64));
-  TConverters.be64_copy(PUInt64(Fm_state), 0, PByte(result), 0,
+  TConverters.be64_copy(PUInt64(FState), 0, PByte(result), 0,
     System.Length(result));
-
 end;
 
 procedure TSHA2_384.Initialize;
 begin
-
-  Fm_state[0] := UInt64($CBBB9D5DC1059ED8);
-  Fm_state[1] := $629A292A367CD507;
-  Fm_state[2] := UInt64($9159015A3070DD17);
-  Fm_state[3] := $152FECD8F70E5939;
-  Fm_state[4] := $67332667FFC00B31;
-  Fm_state[5] := UInt64($8EB44A8768581511);
-  Fm_state[6] := UInt64($DB0C2E0D64F98FA7);
-  Fm_state[7] := $47B5481DBEFA4FA4;
-
+  FState[0] := UInt64($CBBB9D5DC1059ED8);
+  FState[1] := $629A292A367CD507;
+  FState[2] := UInt64($9159015A3070DD17);
+  FState[3] := $152FECD8F70E5939;
+  FState[4] := $67332667FFC00B31;
+  FState[5] := UInt64($8EB44A8768581511);
+  FState[6] := UInt64($DB0C2E0D64F98FA7);
+  FState[7] := $47B5481DBEFA4FA4;
   Inherited Initialize();
-
 end;
 
 end.

+ 15 - 19
src/libraries/hashlib4pascal/HlpSHA2_512.pas

@@ -37,13 +37,13 @@ implementation
 
 function TSHA2_512.Clone(): IHash;
 var
-  HashInstance: TSHA2_512;
+  LHashInstance: TSHA2_512;
 begin
-  HashInstance := TSHA2_512.Create();
-  HashInstance.Fm_state := System.Copy(Fm_state);
-  HashInstance.Fm_buffer := Fm_buffer.Clone();
-  HashInstance.Fm_processed_bytes := Fm_processed_bytes;
-  result := HashInstance as IHash;
+  LHashInstance := TSHA2_512.Create();
+  LHashInstance.FState := System.Copy(FState);
+  LHashInstance.FBuffer := FBuffer.Clone();
+  LHashInstance.FProcessedBytesCount := FProcessedBytesCount;
+  result := LHashInstance as IHash;
   result.BufferSize := BufferSize;
 end;
 
@@ -54,26 +54,22 @@ end;
 
 function TSHA2_512.GetResult: THashLibByteArray;
 begin
-
   System.SetLength(result, 8 * System.SizeOf(UInt64));
-  TConverters.be64_copy(PUInt64(Fm_state), 0, PByte(result), 0,
+  TConverters.be64_copy(PUInt64(FState), 0, PByte(result), 0,
     System.Length(result));
 end;
 
 procedure TSHA2_512.Initialize;
 begin
-
-  Fm_state[0] := $6A09E667F3BCC908;
-  Fm_state[1] := UInt64($BB67AE8584CAA73B);
-  Fm_state[2] := $3C6EF372FE94F82B;
-  Fm_state[3] := UInt64($A54FF53A5F1D36F1);
-  Fm_state[4] := $510E527FADE682D1;
-  Fm_state[5] := UInt64($9B05688C2B3E6C1F);
-  Fm_state[6] := $1F83D9ABFB41BD6B;
-  Fm_state[7] := $5BE0CD19137E2179;
-
+  FState[0] := $6A09E667F3BCC908;
+  FState[1] := UInt64($BB67AE8584CAA73B);
+  FState[2] := $3C6EF372FE94F82B;
+  FState[3] := UInt64($A54FF53A5F1D36F1);
+  FState[4] := $510E527FADE682D1;
+  FState[5] := UInt64($9B05688C2B3E6C1F);
+  FState[6] := $1F83D9ABFB41BD6B;
+  FState[7] := $5BE0CD19137E2179;
   Inherited Initialize();
-
 end;
 
 end.

File diff suppressed because it is too large
+ 440 - 439
src/libraries/hashlib4pascal/HlpSHA2_512Base.pas


+ 15 - 20
src/libraries/hashlib4pascal/HlpSHA2_512_224.pas

@@ -37,13 +37,13 @@ implementation
 
 function TSHA2_512_224.Clone(): IHash;
 var
-  HashInstance: TSHA2_512_224;
+  LHashInstance: TSHA2_512_224;
 begin
-  HashInstance := TSHA2_512_224.Create();
-  HashInstance.Fm_state := System.Copy(Fm_state);
-  HashInstance.Fm_buffer := Fm_buffer.Clone();
-  HashInstance.Fm_processed_bytes := Fm_processed_bytes;
-  result := HashInstance as IHash;
+  LHashInstance := TSHA2_512_224.Create();
+  LHashInstance.FState := System.Copy(FState);
+  LHashInstance.FBuffer := FBuffer.Clone();
+  LHashInstance.FProcessedBytesCount := FProcessedBytesCount;
+  result := LHashInstance as IHash;
   result.BufferSize := BufferSize;
 end;
 
@@ -54,28 +54,23 @@ end;
 
 function TSHA2_512_224.GetResult: THashLibByteArray;
 begin
-
   System.SetLength(result, 4 * System.SizeOf(UInt64));
-  TConverters.be64_copy(PUInt64(Fm_state), 0, PByte(result), 0,
+  TConverters.be64_copy(PUInt64(FState), 0, PByte(result), 0,
     System.Length(result));
   System.SetLength(result, HashSize * System.SizeOf(Byte));
-
 end;
 
 procedure TSHA2_512_224.Initialize;
 begin
-
-  Fm_state[0] := UInt64($8C3D37C819544DA2);
-  Fm_state[1] := $73E1996689DCD4D6;
-  Fm_state[2] := $1DFAB7AE32FF9C82;
-  Fm_state[3] := $679DD514582F9FCF;
-  Fm_state[4] := $0F6D2B697BD44DA8;
-  Fm_state[5] := $77E36F7304C48942;
-  Fm_state[6] := $3F9D85A86A1D36C8;
-  Fm_state[7] := $1112E6AD91D692A1;
-
+  FState[0] := UInt64($8C3D37C819544DA2);
+  FState[1] := $73E1996689DCD4D6;
+  FState[2] := $1DFAB7AE32FF9C82;
+  FState[3] := $679DD514582F9FCF;
+  FState[4] := $0F6D2B697BD44DA8;
+  FState[5] := $77E36F7304C48942;
+  FState[6] := $3F9D85A86A1D36C8;
+  FState[7] := $1112E6AD91D692A1;
   Inherited Initialize();
-
 end;
 
 end.

+ 15 - 20
src/libraries/hashlib4pascal/HlpSHA2_512_256.pas

@@ -37,13 +37,13 @@ implementation
 
 function TSHA2_512_256.Clone(): IHash;
 var
-  HashInstance: TSHA2_512_256;
+  LHashInstance: TSHA2_512_256;
 begin
-  HashInstance := TSHA2_512_256.Create();
-  HashInstance.Fm_state := System.Copy(Fm_state);
-  HashInstance.Fm_buffer := Fm_buffer.Clone();
-  HashInstance.Fm_processed_bytes := Fm_processed_bytes;
-  result := HashInstance as IHash;
+  LHashInstance := TSHA2_512_256.Create();
+  LHashInstance.FState := System.Copy(FState);
+  LHashInstance.FBuffer := FBuffer.Clone();
+  LHashInstance.FProcessedBytesCount := FProcessedBytesCount;
+  result := LHashInstance as IHash;
   result.BufferSize := BufferSize;
 end;
 
@@ -54,27 +54,22 @@ end;
 
 function TSHA2_512_256.GetResult: THashLibByteArray;
 begin
-
   System.SetLength(result, 4 * System.SizeOf(UInt64));
-  TConverters.be64_copy(PUInt64(Fm_state), 0, PByte(result), 0,
+  TConverters.be64_copy(PUInt64(FState), 0, PByte(result), 0,
     System.Length(result));
-
 end;
 
 procedure TSHA2_512_256.Initialize;
 begin
-
-  Fm_state[0] := $22312194FC2BF72C;
-  Fm_state[1] := UInt64($9F555FA3C84C64C2);
-  Fm_state[2] := $2393B86B6F53B151;
-  Fm_state[3] := UInt64($963877195940EABD);
-  Fm_state[4] := UInt64($96283EE2A88EFFE3);
-  Fm_state[5] := UInt64($BE5E1E2553863992);
-  Fm_state[6] := $2B0199FC2C85B8AA;
-  Fm_state[7] := $0EB72DDC81C52CA2;
-
+  FState[0] := $22312194FC2BF72C;
+  FState[1] := UInt64($9F555FA3C84C64C2);
+  FState[2] := $2393B86B6F53B151;
+  FState[3] := UInt64($963877195940EABD);
+  FState[4] := UInt64($96283EE2A88EFFE3);
+  FState[5] := UInt64($BE5E1E2553863992);
+  FState[6] := $2B0199FC2C85B8AA;
+  FState[7] := $0EB72DDC81C52CA2;
   Inherited Initialize();
-
 end;
 
 end.

+ 242 - 254
src/libraries/hashlib4pascal/HlpSHA3.pas

@@ -5,15 +5,12 @@ unit HlpSHA3;
 interface
 
 uses
-{$IFDEF HAS_UNITSCOPE}
-  System.SysUtils,
-{$ELSE}
   SysUtils,
-{$ENDIF HAS_UNITSCOPE}
   HlpBits,
 {$IFDEF DELPHI}
-  HlpBitConverter,
   HlpHash,
+  HlpHashBuffer,
+  HlpBitConverter,
 {$ENDIF DELPHI}
   HlpIHashInfo,
   HlpIHash,
@@ -37,8 +34,8 @@ type
     THashMode = (hmKeccak = $1, hmSHA3 = $6, hmShake = $1F);
 {$SCOPEDENUMS OFF}
   strict protected
-
-    Fm_state: THashLibUInt64Array;
+  var
+    FState: THashLibUInt64Array;
     FHashSize, FBlockSize: Int32;
     FHashMode: THashMode;
 
@@ -64,12 +61,12 @@ type
     procedure KeccakF1600_StatePermute();
 
     function GetName: String; override;
-    constructor Create(a_hash_size: THashSize);
+    constructor Create(AHashSize: THashSize);
 
     procedure Finish(); override;
     function GetResult(): THashLibByteArray; override;
-    procedure TransformBlock(a_data: PByte; a_data_length: Int32;
-      a_index: Int32); override;
+    procedure TransformBlock(AData: PByte; ADataLength: Int32;
+      AIndex: Int32); override;
 
   public
     procedure Initialize; override;
@@ -172,10 +169,10 @@ type
   var
     FXOFSizeInBits: UInt32;
     function GetXOFSizeInBits: UInt32; inline;
-    procedure SetXOFSizeInBits(a_xof_size_in_bits: UInt32); inline;
-    function SetXOFSizeInBitsInternal(a_xof_size_in_bits: UInt32): IXOF;
+    procedure SetXOFSizeInBits(AXofSizeInBits: UInt32); inline;
+    function SetXOFSizeInBitsInternal(AXofSizeInBits: UInt32): IXOF;
   strict protected
-    constructor Create(a_hash_size: THashSize);
+    constructor Create(AHashSize: THashSize);
     property XOFSizeInBits: UInt32 read GetXOFSizeInBits write SetXOFSizeInBits;
 
   public
@@ -205,29 +202,26 @@ implementation
 
 { TSHA3 }
 
-constructor TSHA3.Create(a_hash_size: THashSize);
+constructor TSHA3.Create(AHashSize: THashSize);
 begin
-  Inherited Create(Int32(a_hash_size), 200 - (Int32(a_hash_size) * 2));
-
+  Inherited Create(Int32(AHashSize), 200 - (Int32(AHashSize) * 2));
   FHashSize := HashSize;
   FBlockSize := BlockSize;
-
-  System.SetLength(Fm_state, 25);
-
+  System.SetLength(FState, 25);
 end;
 
 procedure TSHA3.Finish;
 var
-  buffer_pos: Int32;
-  block: THashLibByteArray;
+  LBufferPosition: Int32;
+  LBlock: THashLibByteArray;
 begin
-  buffer_pos := Fm_buffer.Pos;
-  block := Fm_buffer.GetBytesZeroPadded();
+  LBufferPosition := FBuffer.Position;
+  LBlock := FBuffer.GetBytesZeroPadded();
 
-  block[buffer_pos] := Int32(FHashMode);
-  block[FBlockSize - 1] := block[FBlockSize - 1] xor $80;
+  LBlock[LBufferPosition] := Int32(FHashMode);
+  LBlock[FBlockSize - 1] := LBlock[FBlockSize - 1] xor $80;
 
-  TransformBlock(PByte(block), System.Length(block), 0);
+  TransformBlock(PByte(LBlock), System.Length(LBlock), 0);
 end;
 
 function TSHA3.GetName: String;
@@ -250,18 +244,15 @@ end;
 
 function TSHA3.GetResult: THashLibByteArray;
 begin
-
   System.SetLength(Result, FHashSize);
 
-  TConverters.le64_copy(PUInt64(Fm_state), 0, PByte(Result), 0,
+  TConverters.le64_copy(PUInt64(FState), 0, PByte(Result), 0,
     System.Length(Result));
-
 end;
 
 procedure TSHA3.Initialize;
 begin
-  TArrayUtils.ZeroFill(Fm_state);
-
+  TArrayUtils.ZeroFill(FState);
   Inherited Initialize();
 end;
 
@@ -273,43 +264,43 @@ var
     Ama, Ame, Ami, Amo, Amu, Asa, Ase, Asi, Aso, Asu, BCa, BCe, BCi, BCo, BCu,
     Eba, Ebe, Ebi, Ebo, Ebu, Ega, Ege, Egi, Ego, Egu, Eka, Eke, Eki, Eko, Eku,
     Ema, Eme, Emi, Emo, Emu, Esa, Ese, Esi, Eso, Esu: UInt64;
-  round: Int32;
+  LRound: Int32;
 {$ELSE}
   Ca, Ce, Ci, Co, Cu: UInt64;
-  temp: array [0 .. 24] of UInt64;
+  LTemp: array [0 .. 24] of UInt64;
   j: Int32;
 {$ENDIF USE_UNROLLED_VARIANT}
 begin
 {$IFDEF USE_UNROLLED_VARIANT}
   // copyFromState(A, state)
-  Aba := Fm_state[0];
-  Abe := Fm_state[1];
-  Abi := Fm_state[2];
-  Abo := Fm_state[3];
-  Abu := Fm_state[4];
-  Aga := Fm_state[5];
-  Age := Fm_state[6];
-  Agi := Fm_state[7];
-  Ago := Fm_state[8];
-  Agu := Fm_state[9];
-  Aka := Fm_state[10];
-  Ake := Fm_state[11];
-  Aki := Fm_state[12];
-  Ako := Fm_state[13];
-  Aku := Fm_state[14];
-  Ama := Fm_state[15];
-  Ame := Fm_state[16];
-  Ami := Fm_state[17];
-  Amo := Fm_state[18];
-  Amu := Fm_state[19];
-  Asa := Fm_state[20];
-  Ase := Fm_state[21];
-  Asi := Fm_state[22];
-  Aso := Fm_state[23];
-  Asu := Fm_state[24];
-
-  round := 0;
-  while round < 24 do
+  Aba := FState[0];
+  Abe := FState[1];
+  Abi := FState[2];
+  Abo := FState[3];
+  Abu := FState[4];
+  Aga := FState[5];
+  Age := FState[6];
+  Agi := FState[7];
+  Ago := FState[8];
+  Agu := FState[9];
+  Aka := FState[10];
+  Ake := FState[11];
+  Aki := FState[12];
+  Ako := FState[13];
+  Aku := FState[14];
+  Ama := FState[15];
+  Ame := FState[16];
+  Ami := FState[17];
+  Amo := FState[18];
+  Amu := FState[19];
+  Asa := FState[20];
+  Ase := FState[21];
+  Asi := FState[22];
+  Aso := FState[23];
+  Asu := FState[24];
+
+  LRound := 0;
+  while LRound < 24 do
   begin
     // prepareTheta
     BCa := Aba xor Aga xor Aka xor Ama xor Asa;
@@ -318,7 +309,7 @@ begin
     BCo := Abo xor Ago xor Ako xor Amo xor Aso;
     BCu := Abu xor Agu xor Aku xor Amu xor Asu;
 
-    // thetaRhoPiChiIotaPrepareTheta(round  , A, E)
+    // thetaRhoPiChiIotaPrepareTheta(LRound  , A, E)
     Da := BCu xor TBits.RotateLeft64(BCe, 1);
     De := BCa xor TBits.RotateLeft64(BCi, 1);
     Di := BCe xor TBits.RotateLeft64(BCo, 1);
@@ -336,7 +327,7 @@ begin
     Asu := Asu xor Du;
     BCu := TBits.RotateLeft64(Asu, 14);
     Eba := BCa xor ((not BCe) and BCi);
-    Eba := Eba xor UInt64(RC[round]);
+    Eba := Eba xor UInt64(RC[LRound]);
     Ebe := BCe xor ((not BCi) and BCo);
     Ebi := BCi xor ((not BCo) and BCu);
     Ebo := BCo xor ((not BCu) and BCa);
@@ -413,7 +404,7 @@ begin
     BCo := Ebo xor Ego xor Eko xor Emo xor Eso;
     BCu := Ebu xor Egu xor Eku xor Emu xor Esu;
 
-    // thetaRhoPiChiIotaPrepareTheta(round+1, E, A)
+    // thetaRhoPiChiIotaPrepareTheta(LRound+1, E, A)
     Da := BCu xor TBits.RotateLeft64(BCe, 1);
     De := BCa xor TBits.RotateLeft64(BCi, 1);
     Di := BCe xor TBits.RotateLeft64(BCo, 1);
@@ -431,7 +422,7 @@ begin
     Esu := Esu xor Du;
     BCu := TBits.RotateLeft64(Esu, 14);
     Aba := BCa xor ((not BCe) and BCi);
-    Aba := Aba xor UInt64(RC[round + 1]);
+    Aba := Aba xor UInt64(RC[LRound + 1]);
     Abe := BCe xor ((not BCi) and BCo);
     Abi := BCi xor ((not BCo) and BCu);
     Abo := BCo xor ((not BCu) and BCa);
@@ -501,142 +492,140 @@ begin
     Aso := BCo xor ((not BCu) and BCa);
     Asu := BCu xor ((not BCa) and BCe);
 
-    System.Inc(round, 2);
+    System.Inc(LRound, 2);
   end;
 
   // copyToState(state, A)
-  Fm_state[0] := Aba;
-  Fm_state[1] := Abe;
-  Fm_state[2] := Abi;
-  Fm_state[3] := Abo;
-  Fm_state[4] := Abu;
-  Fm_state[5] := Aga;
-  Fm_state[6] := Age;
-  Fm_state[7] := Agi;
-  Fm_state[8] := Ago;
-  Fm_state[9] := Agu;
-  Fm_state[10] := Aka;
-  Fm_state[11] := Ake;
-  Fm_state[12] := Aki;
-  Fm_state[13] := Ako;
-  Fm_state[14] := Aku;
-  Fm_state[15] := Ama;
-  Fm_state[16] := Ame;
-  Fm_state[17] := Ami;
-  Fm_state[18] := Amo;
-  Fm_state[19] := Amu;
-  Fm_state[20] := Asa;
-  Fm_state[21] := Ase;
-  Fm_state[22] := Asi;
-  Fm_state[23] := Aso;
-  Fm_state[24] := Asu;
+  FState[0] := Aba;
+  FState[1] := Abe;
+  FState[2] := Abi;
+  FState[3] := Abo;
+  FState[4] := Abu;
+  FState[5] := Aga;
+  FState[6] := Age;
+  FState[7] := Agi;
+  FState[8] := Ago;
+  FState[9] := Agu;
+  FState[10] := Aka;
+  FState[11] := Ake;
+  FState[12] := Aki;
+  FState[13] := Ako;
+  FState[14] := Aku;
+  FState[15] := Ama;
+  FState[16] := Ame;
+  FState[17] := Ami;
+  FState[18] := Amo;
+  FState[19] := Amu;
+  FState[20] := Asa;
+  FState[21] := Ase;
+  FState[22] := Asi;
+  FState[23] := Aso;
+  FState[24] := Asu;
 
 {$ELSE}
   for j := 0 to 23 do
   begin
-    Ca := Fm_state[00] xor Fm_state[05] xor Fm_state[10] xor Fm_state[15]
-      xor Fm_state[20];
-    Ce := Fm_state[01] xor Fm_state[06] xor Fm_state[11] xor Fm_state[16]
-      xor Fm_state[21];
-    Ci := Fm_state[02] xor Fm_state[07] xor Fm_state[12] xor Fm_state[17]
-      xor Fm_state[22];
-    Co := Fm_state[03] xor Fm_state[08] xor Fm_state[13] xor Fm_state[18]
-      xor Fm_state[23];
-    Cu := Fm_state[04] xor Fm_state[09] xor Fm_state[14] xor Fm_state[19]
-      xor Fm_state[24];
+    Ca := FState[00] xor FState[05] xor FState[10] xor FState[15]
+      xor FState[20];
+    Ce := FState[01] xor FState[06] xor FState[11] xor FState[16]
+      xor FState[21];
+    Ci := FState[02] xor FState[07] xor FState[12] xor FState[17]
+      xor FState[22];
+    Co := FState[03] xor FState[08] xor FState[13] xor FState[18]
+      xor FState[23];
+    Cu := FState[04] xor FState[09] xor FState[14] xor FState[19]
+      xor FState[24];
     Da := TBits.RotateLeft64(Ca, 1) xor Co;
     De := TBits.RotateLeft64(Ce, 1) xor Cu;
     Di := TBits.RotateLeft64(Ci, 1) xor Ca;
     &Do := TBits.RotateLeft64(Co, 1) xor Ce;
     Du := TBits.RotateLeft64(Cu, 1) xor Ci;
-    temp[00] := Fm_state[00] xor De;
-    temp[01] := TBits.RotateLeft64(Fm_state[06] xor Di, 44);
-    temp[02] := TBits.RotateLeft64(Fm_state[12] xor &Do, 43);
-    temp[03] := TBits.RotateLeft64(Fm_state[18] xor Du, 21);
-    temp[04] := TBits.RotateLeft64(Fm_state[24] xor Da, 14);
-    temp[05] := TBits.RotateLeft64(Fm_state[03] xor Du, 28);
-    temp[06] := TBits.RotateLeft64(Fm_state[09] xor Da, 20);
-    temp[07] := TBits.RotateLeft64(Fm_state[10] xor De, 3);
-    temp[08] := TBits.RotateLeft64(Fm_state[16] xor Di, 45);
-    temp[09] := TBits.RotateLeft64(Fm_state[22] xor &Do, 61);
-    temp[10] := TBits.RotateLeft64(Fm_state[01] xor Di, 1);
-    temp[11] := TBits.RotateLeft64(Fm_state[07] xor &Do, 6);
-    temp[12] := TBits.RotateLeft64(Fm_state[13] xor Du, 25);
-    temp[13] := TBits.RotateLeft64(Fm_state[19] xor Da, 8);
-    temp[14] := TBits.RotateLeft64(Fm_state[20] xor De, 18);
-    temp[15] := TBits.RotateLeft64(Fm_state[04] xor Da, 27);
-    temp[16] := TBits.RotateLeft64(Fm_state[05] xor De, 36);
-    temp[17] := TBits.RotateLeft64(Fm_state[11] xor Di, 10);
-    temp[18] := TBits.RotateLeft64(Fm_state[17] xor &Do, 15);
-    temp[19] := TBits.RotateLeft64(Fm_state[23] xor Du, 56);
-    temp[20] := TBits.RotateLeft64(Fm_state[02] xor &Do, 62);
-    temp[21] := TBits.RotateLeft64(Fm_state[08] xor Du, 55);
-    temp[22] := TBits.RotateLeft64(Fm_state[14] xor Da, 39);
-    temp[23] := TBits.RotateLeft64(Fm_state[15] xor De, 41);
-    temp[24] := TBits.RotateLeft64(Fm_state[21] xor Di, 2);
-    Fm_state[00] := temp[00] xor ((not temp[01]) and temp[02]);
-    Fm_state[01] := temp[01] xor ((not temp[02]) and temp[03]);
-    Fm_state[02] := temp[02] xor ((not temp[03]) and temp[04]);
-    Fm_state[03] := temp[03] xor ((not temp[04]) and temp[00]);
-    Fm_state[04] := temp[04] xor ((not temp[00]) and temp[01]);
-    Fm_state[05] := temp[05] xor ((not temp[06]) and temp[07]);
-    Fm_state[06] := temp[06] xor ((not temp[07]) and temp[08]);
-    Fm_state[07] := temp[07] xor ((not temp[08]) and temp[09]);
-    Fm_state[08] := temp[08] xor ((not temp[09]) and temp[05]);
-    Fm_state[09] := temp[09] xor ((not temp[05]) and temp[06]);
-    Fm_state[10] := temp[10] xor ((not temp[11]) and temp[12]);
-    Fm_state[11] := temp[11] xor ((not temp[12]) and temp[13]);
-    Fm_state[12] := temp[12] xor ((not temp[13]) and temp[14]);
-    Fm_state[13] := temp[13] xor ((not temp[14]) and temp[10]);
-    Fm_state[14] := temp[14] xor ((not temp[10]) and temp[11]);
-    Fm_state[15] := temp[15] xor ((not temp[16]) and temp[17]);
-    Fm_state[16] := temp[16] xor ((not temp[17]) and temp[18]);
-    Fm_state[17] := temp[17] xor ((not temp[18]) and temp[19]);
-    Fm_state[18] := temp[18] xor ((not temp[19]) and temp[15]);
-    Fm_state[19] := temp[19] xor ((not temp[15]) and temp[16]);
-    Fm_state[20] := temp[20] xor ((not temp[21]) and temp[22]);
-    Fm_state[21] := temp[21] xor ((not temp[22]) and temp[23]);
-    Fm_state[22] := temp[22] xor ((not temp[23]) and temp[24]);
-    Fm_state[23] := temp[23] xor ((not temp[24]) and temp[20]);
-    Fm_state[24] := temp[24] xor ((not temp[20]) and temp[21]);
-    Fm_state[00] := Fm_state[00] xor RC[j];
+    LTemp[00] := FState[00] xor De;
+    LTemp[01] := TBits.RotateLeft64(FState[06] xor Di, 44);
+    LTemp[02] := TBits.RotateLeft64(FState[12] xor &Do, 43);
+    LTemp[03] := TBits.RotateLeft64(FState[18] xor Du, 21);
+    LTemp[04] := TBits.RotateLeft64(FState[24] xor Da, 14);
+    LTemp[05] := TBits.RotateLeft64(FState[03] xor Du, 28);
+    LTemp[06] := TBits.RotateLeft64(FState[09] xor Da, 20);
+    LTemp[07] := TBits.RotateLeft64(FState[10] xor De, 3);
+    LTemp[08] := TBits.RotateLeft64(FState[16] xor Di, 45);
+    LTemp[09] := TBits.RotateLeft64(FState[22] xor &Do, 61);
+    LTemp[10] := TBits.RotateLeft64(FState[01] xor Di, 1);
+    LTemp[11] := TBits.RotateLeft64(FState[07] xor &Do, 6);
+    LTemp[12] := TBits.RotateLeft64(FState[13] xor Du, 25);
+    LTemp[13] := TBits.RotateLeft64(FState[19] xor Da, 8);
+    LTemp[14] := TBits.RotateLeft64(FState[20] xor De, 18);
+    LTemp[15] := TBits.RotateLeft64(FState[04] xor Da, 27);
+    LTemp[16] := TBits.RotateLeft64(FState[05] xor De, 36);
+    LTemp[17] := TBits.RotateLeft64(FState[11] xor Di, 10);
+    LTemp[18] := TBits.RotateLeft64(FState[17] xor &Do, 15);
+    LTemp[19] := TBits.RotateLeft64(FState[23] xor Du, 56);
+    LTemp[20] := TBits.RotateLeft64(FState[02] xor &Do, 62);
+    LTemp[21] := TBits.RotateLeft64(FState[08] xor Du, 55);
+    LTemp[22] := TBits.RotateLeft64(FState[14] xor Da, 39);
+    LTemp[23] := TBits.RotateLeft64(FState[15] xor De, 41);
+    LTemp[24] := TBits.RotateLeft64(FState[21] xor Di, 2);
+    FState[00] := LTemp[00] xor ((not LTemp[01]) and LTemp[02]);
+    FState[01] := LTemp[01] xor ((not LTemp[02]) and LTemp[03]);
+    FState[02] := LTemp[02] xor ((not LTemp[03]) and LTemp[04]);
+    FState[03] := LTemp[03] xor ((not LTemp[04]) and LTemp[00]);
+    FState[04] := LTemp[04] xor ((not LTemp[00]) and LTemp[01]);
+    FState[05] := LTemp[05] xor ((not LTemp[06]) and LTemp[07]);
+    FState[06] := LTemp[06] xor ((not LTemp[07]) and LTemp[08]);
+    FState[07] := LTemp[07] xor ((not LTemp[08]) and LTemp[09]);
+    FState[08] := LTemp[08] xor ((not LTemp[09]) and LTemp[05]);
+    FState[09] := LTemp[09] xor ((not LTemp[05]) and LTemp[06]);
+    FState[10] := LTemp[10] xor ((not LTemp[11]) and LTemp[12]);
+    FState[11] := LTemp[11] xor ((not LTemp[12]) and LTemp[13]);
+    FState[12] := LTemp[12] xor ((not LTemp[13]) and LTemp[14]);
+    FState[13] := LTemp[13] xor ((not LTemp[14]) and LTemp[10]);
+    FState[14] := LTemp[14] xor ((not LTemp[10]) and LTemp[11]);
+    FState[15] := LTemp[15] xor ((not LTemp[16]) and LTemp[17]);
+    FState[16] := LTemp[16] xor ((not LTemp[17]) and LTemp[18]);
+    FState[17] := LTemp[17] xor ((not LTemp[18]) and LTemp[19]);
+    FState[18] := LTemp[18] xor ((not LTemp[19]) and LTemp[15]);
+    FState[19] := LTemp[19] xor ((not LTemp[15]) and LTemp[16]);
+    FState[20] := LTemp[20] xor ((not LTemp[21]) and LTemp[22]);
+    FState[21] := LTemp[21] xor ((not LTemp[22]) and LTemp[23]);
+    FState[22] := LTemp[22] xor ((not LTemp[23]) and LTemp[24]);
+    FState[23] := LTemp[23] xor ((not LTemp[24]) and LTemp[20]);
+    FState[24] := LTemp[24] xor ((not LTemp[20]) and LTemp[21]);
+    FState[00] := FState[00] xor RC[j];
   end;
 
-  System.FillChar(temp, System.SizeOf(temp), UInt64(0));
+  System.FillChar(LTemp, System.SizeOf(LTemp), UInt64(0));
 {$ENDIF USE_UNROLLED_VARIANT}
 end;
 
-procedure TSHA3.TransformBlock(a_data: PByte; a_data_length: Int32;
-  a_index: Int32);
+procedure TSHA3.TransformBlock(AData: PByte; ADataLength: Int32; AIndex: Int32);
 var
-  data: array [0 .. 20] of UInt64;
-  j, upcount: Int32;
+  LData: array [0 .. 20] of UInt64;
+  LJdx, LBlockCount: Int32;
 begin
-  TConverters.le64_copy(a_data, a_index, @(data[0]), 0, a_data_length);
-
-  j := 0;
-  upcount := FBlockSize shr 3;
-  while j < upcount do
+  TConverters.le64_copy(AData, AIndex, @(LData[0]), 0, ADataLength);
+  LJdx := 0;
+  LBlockCount := FBlockSize shr 3;
+  while LJdx < LBlockCount do
   begin
-    Fm_state[j] := Fm_state[j] xor data[j];
-    System.Inc(j);
+    FState[LJdx] := FState[LJdx] xor LData[LJdx];
+    System.Inc(LJdx);
   end;
 
   KeccakF1600_StatePermute();
-  System.FillChar(data, System.SizeOf(data), UInt64(0));
+  System.FillChar(LData, System.SizeOf(LData), UInt64(0));
 end;
 
 { TSHA3_224 }
 
 function TSHA3_224.Clone(): IHash;
 var
-  HashInstance: TSHA3_224;
+  LHashInstance: TSHA3_224;
 begin
-  HashInstance := TSHA3_224.Create();
-  HashInstance.Fm_state := System.Copy(Fm_state);
-  HashInstance.Fm_buffer := Fm_buffer.Clone();
-  HashInstance.Fm_processed_bytes := Fm_processed_bytes;
-  Result := HashInstance as IHash;
+  LHashInstance := TSHA3_224.Create();
+  LHashInstance.FState := System.Copy(FState);
+  LHashInstance.FBuffer := FBuffer.Clone();
+  LHashInstance.FProcessedBytesCount := FProcessedBytesCount;
+  Result := LHashInstance as IHash;
   Result.BufferSize := BufferSize;
 end;
 
@@ -650,13 +639,13 @@ end;
 
 function TSHA3_256.Clone(): IHash;
 var
-  HashInstance: TSHA3_256;
+  LHashInstance: TSHA3_256;
 begin
-  HashInstance := TSHA3_256.Create();
-  HashInstance.Fm_state := System.Copy(Fm_state);
-  HashInstance.Fm_buffer := Fm_buffer.Clone();
-  HashInstance.Fm_processed_bytes := Fm_processed_bytes;
-  Result := HashInstance as IHash;
+  LHashInstance := TSHA3_256.Create();
+  LHashInstance.FState := System.Copy(FState);
+  LHashInstance.FBuffer := FBuffer.Clone();
+  LHashInstance.FProcessedBytesCount := FProcessedBytesCount;
+  Result := LHashInstance as IHash;
   Result.BufferSize := BufferSize;
 end;
 
@@ -670,13 +659,13 @@ end;
 
 function TSHA3_384.Clone(): IHash;
 var
-  HashInstance: TSHA3_384;
+  LHashInstance: TSHA3_384;
 begin
-  HashInstance := TSHA3_384.Create();
-  HashInstance.Fm_state := System.Copy(Fm_state);
-  HashInstance.Fm_buffer := Fm_buffer.Clone();
-  HashInstance.Fm_processed_bytes := Fm_processed_bytes;
-  Result := HashInstance as IHash;
+  LHashInstance := TSHA3_384.Create();
+  LHashInstance.FState := System.Copy(FState);
+  LHashInstance.FBuffer := FBuffer.Clone();
+  LHashInstance.FProcessedBytesCount := FProcessedBytesCount;
+  Result := LHashInstance as IHash;
   Result.BufferSize := BufferSize;
 end;
 
@@ -690,13 +679,13 @@ end;
 
 function TSHA3_512.Clone(): IHash;
 var
-  HashInstance: TSHA3_512;
+  LHashInstance: TSHA3_512;
 begin
-  HashInstance := TSHA3_512.Create();
-  HashInstance.Fm_state := System.Copy(Fm_state);
-  HashInstance.Fm_buffer := Fm_buffer.Clone();
-  HashInstance.Fm_processed_bytes := Fm_processed_bytes;
-  Result := HashInstance as IHash;
+  LHashInstance := TSHA3_512.Create();
+  LHashInstance.FState := System.Copy(FState);
+  LHashInstance.FBuffer := FBuffer.Clone();
+  LHashInstance.FProcessedBytesCount := FProcessedBytesCount;
+  Result := LHashInstance as IHash;
   Result.BufferSize := BufferSize;
 end;
 
@@ -710,13 +699,13 @@ end;
 
 function TKeccak_224.Clone(): IHash;
 var
-  HashInstance: TKeccak_224;
+  LHashInstance: TKeccak_224;
 begin
-  HashInstance := TKeccak_224.Create();
-  HashInstance.Fm_state := System.Copy(Fm_state);
-  HashInstance.Fm_buffer := Fm_buffer.Clone();
-  HashInstance.Fm_processed_bytes := Fm_processed_bytes;
-  Result := HashInstance as IHash;
+  LHashInstance := TKeccak_224.Create();
+  LHashInstance.FState := System.Copy(FState);
+  LHashInstance.FBuffer := FBuffer.Clone();
+  LHashInstance.FProcessedBytesCount := FProcessedBytesCount;
+  Result := LHashInstance as IHash;
   Result.BufferSize := BufferSize;
 end;
 
@@ -730,13 +719,13 @@ end;
 
 function TKeccak_256.Clone(): IHash;
 var
-  HashInstance: TKeccak_256;
+  LHashInstance: TKeccak_256;
 begin
-  HashInstance := TKeccak_256.Create();
-  HashInstance.Fm_state := System.Copy(Fm_state);
-  HashInstance.Fm_buffer := Fm_buffer.Clone();
-  HashInstance.Fm_processed_bytes := Fm_processed_bytes;
-  Result := HashInstance as IHash;
+  LHashInstance := TKeccak_256.Create();
+  LHashInstance.FState := System.Copy(FState);
+  LHashInstance.FBuffer := FBuffer.Clone();
+  LHashInstance.FProcessedBytesCount := FProcessedBytesCount;
+  Result := LHashInstance as IHash;
   Result.BufferSize := BufferSize;
 end;
 
@@ -750,13 +739,13 @@ end;
 
 function TKeccak_288.Clone(): IHash;
 var
-  HashInstance: TKeccak_288;
+  LHashInstance: TKeccak_288;
 begin
-  HashInstance := TKeccak_288.Create();
-  HashInstance.Fm_state := System.Copy(Fm_state);
-  HashInstance.Fm_buffer := Fm_buffer.Clone();
-  HashInstance.Fm_processed_bytes := Fm_processed_bytes;
-  Result := HashInstance as IHash;
+  LHashInstance := TKeccak_288.Create();
+  LHashInstance.FState := System.Copy(FState);
+  LHashInstance.FBuffer := FBuffer.Clone();
+  LHashInstance.FProcessedBytesCount := FProcessedBytesCount;
+  Result := LHashInstance as IHash;
   Result.BufferSize := BufferSize;
 end;
 
@@ -770,13 +759,13 @@ end;
 
 function TKeccak_384.Clone(): IHash;
 var
-  HashInstance: TKeccak_384;
+  LHashInstance: TKeccak_384;
 begin
-  HashInstance := TKeccak_384.Create();
-  HashInstance.Fm_state := System.Copy(Fm_state);
-  HashInstance.Fm_buffer := Fm_buffer.Clone();
-  HashInstance.Fm_processed_bytes := Fm_processed_bytes;
-  Result := HashInstance as IHash;
+  LHashInstance := TKeccak_384.Create();
+  LHashInstance.FState := System.Copy(FState);
+  LHashInstance.FBuffer := FBuffer.Clone();
+  LHashInstance.FProcessedBytesCount := FProcessedBytesCount;
+  Result := LHashInstance as IHash;
   Result.BufferSize := BufferSize;
 end;
 
@@ -790,13 +779,13 @@ end;
 
 function TKeccak_512.Clone(): IHash;
 var
-  HashInstance: TKeccak_512;
+  LHashInstance: TKeccak_512;
 begin
-  HashInstance := TKeccak_512.Create();
-  HashInstance.Fm_state := System.Copy(Fm_state);
-  HashInstance.Fm_buffer := Fm_buffer.Clone();
-  HashInstance.Fm_processed_bytes := Fm_processed_bytes;
-  Result := HashInstance as IHash;
+  LHashInstance := TKeccak_512.Create();
+  LHashInstance.FState := System.Copy(FState);
+  LHashInstance.FBuffer := FBuffer.Clone();
+  LHashInstance.FProcessedBytesCount := FProcessedBytesCount;
+  Result := LHashInstance as IHash;
   Result.BufferSize := BufferSize;
 end;
 
@@ -808,47 +797,46 @@ end;
 
 { TShake }
 
-function TShake.SetXOFSizeInBitsInternal(a_xof_size_in_bits: UInt32): IXOF;
+function TShake.SetXOFSizeInBitsInternal(AXofSizeInBits: UInt32): IXOF;
 begin
-  If ((a_xof_size_in_bits and $7) <> 0) then
+  If ((AXofSizeInBits and $7) <> 0) then
   begin
     raise EArgumentInvalidHashLibException.CreateRes(@SInvalidXOFSize);
   end;
-  FXOFSizeInBits := a_xof_size_in_bits;
+  FXOFSizeInBits := AXofSizeInBits;
   Result := Self;
 end;
 
-constructor TShake.Create(a_hash_size: THashSize);
+constructor TShake.Create(AHashSize: THashSize);
 begin
-  Inherited Create(a_hash_size);
+  Inherited Create(AHashSize);
   FHashMode := THashMode.hmShake;
 end;
 
 function TShake.GetResult: THashLibByteArray;
 var
-  buffer_pos: Int32;
-  Idx, LXofSizeInBytes: UInt32;
+  LBufferPosition: Int32;
+  LIdx, LXofSizeInBytes: UInt32;
 begin
-  buffer_pos := Fm_buffer.Pos;
+  LBufferPosition := FBuffer.Position;
 
   LXofSizeInBytes := FXOFSizeInBits shr 3;
-  Idx := 0;
+  LIdx := 0;
   System.SetLength(Result, LXofSizeInBytes);
 
-  while Idx < (LXofSizeInBytes shr 3) do
+  while LIdx < (LXofSizeInBytes shr 3) do
   begin
 
-    if (buffer_pos * 8) >= FBlockSize then
+    if (LBufferPosition * 8) >= FBlockSize then
     begin
       KeccakF1600_StatePermute();
-
-      buffer_pos := 0;
+      LBufferPosition := 0;
     end;
 
-    TConverters.ReadUInt64AsBytesLE(Fm_state[buffer_pos], Result, Idx * 8);
+    TConverters.ReadUInt64AsBytesLE(FState[LBufferPosition], Result, LIdx * 8);
 
-    System.Inc(buffer_pos);
-    System.Inc(Idx);
+    System.Inc(LBufferPosition);
+    System.Inc(LIdx);
   end;
 end;
 
@@ -859,39 +847,39 @@ end;
 
 function TShake.TransformFinal: IHashResult;
 var
-  tempresult: THashLibByteArray;
+  LBuffer: THashLibByteArray;
 begin
   Finish();
 {$IFDEF DEBUG}
-  System.Assert(Fm_buffer.IsEmpty);
+  System.Assert(FBuffer.IsEmpty);
 {$ENDIF DEBUG}
-  tempresult := GetResult();
+  LBuffer := GetResult();
 {$IFDEF DEBUG}
-  System.Assert(UInt32(System.Length(tempresult)) = (XOFSizeInBits shr 3));
+  System.Assert(UInt32(System.Length(LBuffer)) = (XOFSizeInBits shr 3));
 {$ENDIF DEBUG}
   Initialize();
-  Result := THashResult.Create(tempresult);
+  Result := THashResult.Create(LBuffer);
 end;
 
-procedure TShake.SetXOFSizeInBits(a_xof_size_in_bits: UInt32);
+procedure TShake.SetXOFSizeInBits(AXofSizeInBits: UInt32);
 begin
-  SetXOFSizeInBitsInternal(a_xof_size_in_bits);
+  SetXOFSizeInBitsInternal(AXofSizeInBits);
 end;
 
 { TShake_128 }
 
 function TShake_128.Clone(): IHash;
 var
-  HashInstance: TShake_128;
+  LHashInstance: TShake_128;
   LXof: IXOF;
 begin
   LXof := (TShake_128.Create() as IXOF);
   LXof.XOFSizeInBits := (Self as IXOF).XOFSizeInBits;
-  HashInstance := LXof as TShake_128;
-  HashInstance.Fm_state := System.Copy(Fm_state);
-  HashInstance.Fm_buffer := Fm_buffer.Clone();
-  HashInstance.Fm_processed_bytes := Fm_processed_bytes;
-  Result := HashInstance as IHash;
+  LHashInstance := LXof as TShake_128;
+  LHashInstance.FState := System.Copy(FState);
+  LHashInstance.FBuffer := FBuffer.Clone();
+  LHashInstance.FProcessedBytesCount := FProcessedBytesCount;
+  Result := LHashInstance as IHash;
   Result.BufferSize := BufferSize;
 end;
 
@@ -904,16 +892,16 @@ end;
 
 function TShake_256.Clone(): IHash;
 var
-  HashInstance: TShake_256;
+  LHashInstance: TShake_256;
   LXof: IXOF;
 begin
   LXof := (TShake_256.Create() as IXOF);
   LXof.XOFSizeInBits := (Self as IXOF).XOFSizeInBits;
-  HashInstance := LXof as TShake_256;
-  HashInstance.Fm_state := System.Copy(Fm_state);
-  HashInstance.Fm_buffer := Fm_buffer.Clone();
-  HashInstance.Fm_processed_bytes := Fm_processed_bytes;
-  Result := HashInstance as IHash;
+  LHashInstance := LXof as TShake_256;
+  LHashInstance.FState := System.Copy(FState);
+  LHashInstance.FBuffer := FBuffer.Clone();
+  LHashInstance.FProcessedBytesCount := FProcessedBytesCount;
+  Result := LHashInstance as IHash;
   Result.BufferSize := BufferSize;
 end;
 

+ 21 - 22
src/libraries/hashlib4pascal/HlpShiftAndXor.pas

@@ -15,14 +15,14 @@ uses
 type
   TShiftAndXor = class sealed(THash, IHash32, ITransformBlock)
   strict private
-
-    Fm_hash: UInt32;
+  var
+    FHash: UInt32;
 
   public
     constructor Create();
     procedure Initialize(); override;
-    procedure TransformBytes(const a_data: THashLibByteArray;
-      a_index, a_length: Int32); override;
+    procedure TransformBytes(const AData: THashLibByteArray;
+      AIndex, ALength: Int32); override;
     function TransformFinal(): IHashResult; override;
     function Clone(): IHash; override;
   end;
@@ -33,11 +33,11 @@ implementation
 
 function TShiftAndXor.Clone(): IHash;
 var
-  HashInstance: TShiftAndXor;
+  LHashInstance: TShiftAndXor;
 begin
-  HashInstance := TShiftAndXor.Create();
-  HashInstance.Fm_hash := Fm_hash;
-  result := HashInstance as IHash;
+  LHashInstance := TShiftAndXor.Create();
+  LHashInstance.FHash := FHash;
+  result := LHashInstance as IHash;
   result.BufferSize := BufferSize;
 end;
 
@@ -48,32 +48,31 @@ end;
 
 procedure TShiftAndXor.Initialize;
 begin
-  Fm_hash := 0;
+  FHash := 0;
 end;
 
-procedure TShiftAndXor.TransformBytes(const a_data: THashLibByteArray;
-  a_index, a_length: Int32);
+procedure TShiftAndXor.TransformBytes(const AData: THashLibByteArray;
+  AIndex, ALength: Int32);
 var
-  i: Int32;
+  LIdx: Int32;
 begin
 {$IFDEF DEBUG}
-  System.Assert(a_index >= 0);
-  System.Assert(a_length >= 0);
-  System.Assert(a_index + a_length <= System.Length(a_data));
+  System.Assert(AIndex >= 0);
+  System.Assert(ALength >= 0);
+  System.Assert(AIndex + ALength <= System.Length(AData));
 {$ENDIF DEBUG}
-  i := a_index;
-  while a_length > 0 do
+  LIdx := AIndex;
+  while ALength > 0 do
   begin
-    Fm_hash := Fm_hash xor ((Fm_hash shl 5) + (Fm_hash shr 2) + a_data[i]);
-    System.Inc(i);
-    System.Dec(a_length);
+    FHash := FHash xor ((FHash shl 5) + (FHash shr 2) + AData[LIdx]);
+    System.Inc(LIdx);
+    System.Dec(ALength);
   end;
-
 end;
 
 function TShiftAndXor.TransformFinal: IHashResult;
 begin
-  result := THashResult.Create(Fm_hash);
+  result := THashResult.Create(FHash);
   Initialize();
 end;
 

+ 159 - 166
src/libraries/hashlib4pascal/HlpSipHash.pas

@@ -38,27 +38,27 @@ type
 
 {$ENDREGION}
     procedure Compress(); inline;
-    procedure CompressTimes(a_times: Int32); inline;
-    procedure ProcessBlock(a_m: UInt64); inline;
-    procedure ByteUpdate(a_b: Byte); inline;
+    procedure CompressTimes(ATimes: Int32); inline;
+    procedure ProcessBlock(ABlock: UInt64); inline;
+    procedure ByteUpdate(AByte: Byte); inline;
     procedure Finish();
 
     function GetKeyLength(): TNullableInteger;
     function GetKey: THashLibByteArray;
-    procedure SetKey(const value: THashLibByteArray);
+    procedure SetKey(const AValue: THashLibByteArray);
 
   strict protected
-
-    Fm_v0, Fm_v1, Fm_v2, Fm_v3, Fm_key0, Fm_key1, Fm_total_length: UInt64;
-    F_cr, F_fr, Fm_idx: Int32;
-    Fm_buf: THashLibByteArray;
+  var
+    FV0, FV1, FV2, FV3, FKey0, FKey1, FTotalLength: UInt64;
+    FCompressionRounds, FFinalizationRounds, FIdx: Int32;
+    FBuffer: THashLibByteArray;
 
   public
-    constructor Create(a_compression_rounds: Int32 = 2;
-      a_finalization_rounds: Int32 = 4);
+    constructor Create(ACompressionRounds: Int32 = 2;
+      AFinalizationRounds: Int32 = 4);
     procedure Initialize(); override;
-    procedure TransformBytes(const a_data: THashLibByteArray;
-      a_index, a_length: Int32); override;
+    procedure TransformBytes(const AData: THashLibByteArray;
+      AIndex, ALength: Int32); override;
     function TransformFinal: IHashResult; override;
     property KeyLength: TNullableInteger read GetKeyLength;
     property Key: THashLibByteArray read GetKey write SetKey;
@@ -84,21 +84,21 @@ implementation
 
 function TSipHash2_4.Clone(): IHash;
 var
-  HashInstance: TSipHash2_4;
+  LHashInstance: TSipHash2_4;
 begin
-  HashInstance := TSipHash2_4.Create();
-  HashInstance.Fm_v0 := Fm_v0;
-  HashInstance.Fm_v1 := Fm_v1;
-  HashInstance.Fm_v2 := Fm_v2;
-  HashInstance.Fm_v3 := Fm_v3;
-  HashInstance.Fm_key0 := Fm_key0;
-  HashInstance.Fm_key1 := Fm_key1;
-  HashInstance.Fm_total_length := Fm_total_length;
-  HashInstance.F_cr := F_cr;
-  HashInstance.F_fr := F_fr;
-  HashInstance.Fm_idx := Fm_idx;
-  HashInstance.Fm_buf := System.Copy(Fm_buf);
-  result := HashInstance as IHash;
+  LHashInstance := TSipHash2_4.Create();
+  LHashInstance.FV0 := FV0;
+  LHashInstance.FV1 := FV1;
+  LHashInstance.FV2 := FV2;
+  LHashInstance.FV3 := FV3;
+  LHashInstance.FKey0 := FKey0;
+  LHashInstance.FKey1 := FKey1;
+  LHashInstance.FTotalLength := FTotalLength;
+  LHashInstance.FCompressionRounds := FCompressionRounds;
+  LHashInstance.FFinalizationRounds := FFinalizationRounds;
+  LHashInstance.FIdx := FIdx;
+  LHashInstance.FBuffer := System.Copy(FBuffer);
+  result := LHashInstance as IHash;
   result.BufferSize := BufferSize;
 end;
 
@@ -112,143 +112,138 @@ end;
 
 procedure TSipHash.Compress;
 begin
-  Fm_v0 := Fm_v0 + Fm_v1;
-  Fm_v2 := Fm_v2 + Fm_v3;
-  Fm_v1 := TBits.RotateLeft64(Fm_v1, 13);
-  Fm_v3 := TBits.RotateLeft64(Fm_v3, 16);
-  Fm_v1 := Fm_v1 xor Fm_v0;
-  Fm_v3 := Fm_v3 xor Fm_v2;
-  Fm_v0 := TBits.RotateLeft64(Fm_v0, 32);
-  Fm_v2 := Fm_v2 + Fm_v1;
-  Fm_v0 := Fm_v0 + Fm_v3;
-  Fm_v1 := TBits.RotateLeft64(Fm_v1, 17);
-  Fm_v3 := TBits.RotateLeft64(Fm_v3, 21);
-  Fm_v1 := Fm_v1 xor Fm_v2;
-  Fm_v3 := Fm_v3 xor Fm_v0;
-  Fm_v2 := TBits.RotateLeft64(Fm_v2, 32);
+  FV0 := FV0 + FV1;
+  FV2 := FV2 + FV3;
+  FV1 := TBits.RotateLeft64(FV1, 13);
+  FV3 := TBits.RotateLeft64(FV3, 16);
+  FV1 := FV1 xor FV0;
+  FV3 := FV3 xor FV2;
+  FV0 := TBits.RotateLeft64(FV0, 32);
+  FV2 := FV2 + FV1;
+  FV0 := FV0 + FV3;
+  FV1 := TBits.RotateLeft64(FV1, 17);
+  FV3 := TBits.RotateLeft64(FV3, 21);
+  FV1 := FV1 xor FV2;
+  FV3 := FV3 xor FV0;
+  FV2 := TBits.RotateLeft64(FV2, 32);
 end;
 
-procedure TSipHash.CompressTimes(a_times: Int32);
+procedure TSipHash.CompressTimes(ATimes: Int32);
 var
-  i: Int32;
+  LIdx: Int32;
 begin
-  i := 0;
-  while i < a_times do
+  LIdx := 0;
+  while LIdx < ATimes do
   begin
     Compress();
-    System.Inc(i);
+    System.Inc(LIdx);
   end;
 end;
 
-procedure TSipHash.ProcessBlock(a_m: UInt64);
+procedure TSipHash.ProcessBlock(ABlock: UInt64);
 begin
-  Fm_v3 := Fm_v3 xor a_m;
-  CompressTimes(F_cr);
-  Fm_v0 := Fm_v0 xor a_m;
+  FV3 := FV3 xor ABlock;
+  CompressTimes(FCompressionRounds);
+  FV0 := FV0 xor ABlock;
 end;
 
-procedure TSipHash.ByteUpdate(a_b: Byte);
+procedure TSipHash.ByteUpdate(AByte: Byte);
 var
-  ptr_Fm_buf: PByte;
-  m: UInt64;
+  LPtrBuffer: PByte;
+  LBlock: UInt64;
 begin
-
-  Fm_buf[Fm_idx] := a_b;
-  System.Inc(Fm_idx);
-  if Fm_idx >= 8 then
+  FBuffer[FIdx] := AByte;
+  System.Inc(FIdx);
+  if FIdx >= 8 then
   begin
-    ptr_Fm_buf := PByte(Fm_buf);
-    m := TConverters.ReadBytesAsUInt64LE(ptr_Fm_buf, 0);
-    ProcessBlock(m);
-    Fm_idx := 0;
+    LPtrBuffer := PByte(FBuffer);
+    LBlock := TConverters.ReadBytesAsUInt64LE(LPtrBuffer, 0);
+    ProcessBlock(LBlock);
+    FIdx := 0;
   end;
-
 end;
 
-constructor TSipHash.Create(a_compression_rounds, a_finalization_rounds: Int32);
+constructor TSipHash.Create(ACompressionRounds, AFinalizationRounds: Int32);
 begin
   Inherited Create(8, 8);
-  Fm_key0 := KEY0;
-  Fm_key1 := KEY1;
-  F_cr := a_compression_rounds;
-  F_fr := a_finalization_rounds;
-  System.SetLength(Fm_buf, 8);
+  FKey0 := KEY0;
+  FKey1 := KEY1;
+  FCompressionRounds := ACompressionRounds;
+  FFinalizationRounds := AFinalizationRounds;
+  System.SetLength(FBuffer, 8);
 end;
 
 procedure TSipHash.Finish;
 var
-  b: UInt64;
+  LFinalBlock: UInt64;
 begin
+  LFinalBlock := UInt64(FTotalLength and $FF) shl 56;
 
-  b := UInt64(Fm_total_length and $FF) shl 56;
-
-  if (Fm_idx <> 0) then
+  if (FIdx <> 0) then
   begin
-
-    case (Fm_idx) of
+    case (FIdx) of
 
       7:
         begin
-          b := b or (UInt64(Fm_buf[6]) shl 48);
-          b := b or (UInt64(Fm_buf[5]) shl 40);
-          b := b or (UInt64(Fm_buf[4]) shl 32);
-          b := b or (UInt64(Fm_buf[3]) shl 24);
-          b := b or (UInt64(Fm_buf[2]) shl 16);
-          b := b or (UInt64(Fm_buf[1]) shl 8);
-          b := b or (UInt64(Fm_buf[0]));
+          LFinalBlock := LFinalBlock or (UInt64(FBuffer[6]) shl 48);
+          LFinalBlock := LFinalBlock or (UInt64(FBuffer[5]) shl 40);
+          LFinalBlock := LFinalBlock or (UInt64(FBuffer[4]) shl 32);
+          LFinalBlock := LFinalBlock or (UInt64(FBuffer[3]) shl 24);
+          LFinalBlock := LFinalBlock or (UInt64(FBuffer[2]) shl 16);
+          LFinalBlock := LFinalBlock or (UInt64(FBuffer[1]) shl 8);
+          LFinalBlock := LFinalBlock or (UInt64(FBuffer[0]));
         end;
       6:
         begin
-          b := b or (UInt64(Fm_buf[5]) shl 40);
-          b := b or (UInt64(Fm_buf[4]) shl 32);
-          b := b or (UInt64(Fm_buf[3]) shl 24);
-          b := b or (UInt64(Fm_buf[2]) shl 16);
-          b := b or (UInt64(Fm_buf[1]) shl 8);
-          b := b or (UInt64(Fm_buf[0]));
+          LFinalBlock := LFinalBlock or (UInt64(FBuffer[5]) shl 40);
+          LFinalBlock := LFinalBlock or (UInt64(FBuffer[4]) shl 32);
+          LFinalBlock := LFinalBlock or (UInt64(FBuffer[3]) shl 24);
+          LFinalBlock := LFinalBlock or (UInt64(FBuffer[2]) shl 16);
+          LFinalBlock := LFinalBlock or (UInt64(FBuffer[1]) shl 8);
+          LFinalBlock := LFinalBlock or (UInt64(FBuffer[0]));
         end;
       5:
         begin
-          b := b or (UInt64(Fm_buf[4]) shl 32);
-          b := b or (UInt64(Fm_buf[3]) shl 24);
-          b := b or (UInt64(Fm_buf[2]) shl 16);
-          b := b or (UInt64(Fm_buf[1]) shl 8);
-          b := b or (UInt64(Fm_buf[0]));
+          LFinalBlock := LFinalBlock or (UInt64(FBuffer[4]) shl 32);
+          LFinalBlock := LFinalBlock or (UInt64(FBuffer[3]) shl 24);
+          LFinalBlock := LFinalBlock or (UInt64(FBuffer[2]) shl 16);
+          LFinalBlock := LFinalBlock or (UInt64(FBuffer[1]) shl 8);
+          LFinalBlock := LFinalBlock or (UInt64(FBuffer[0]));
         end;
 
       4:
         begin
-          b := b or (UInt64(Fm_buf[3]) shl 24);
-          b := b or (UInt64(Fm_buf[2]) shl 16);
-          b := b or (UInt64(Fm_buf[1]) shl 8);
-          b := b or (UInt64(Fm_buf[0]));
+          LFinalBlock := LFinalBlock or (UInt64(FBuffer[3]) shl 24);
+          LFinalBlock := LFinalBlock or (UInt64(FBuffer[2]) shl 16);
+          LFinalBlock := LFinalBlock or (UInt64(FBuffer[1]) shl 8);
+          LFinalBlock := LFinalBlock or (UInt64(FBuffer[0]));
         end;
 
       3:
         begin
-          b := b or (UInt64(Fm_buf[2]) shl 16);
-          b := b or (UInt64(Fm_buf[1]) shl 8);
-          b := b or (UInt64(Fm_buf[0]));
+          LFinalBlock := LFinalBlock or (UInt64(FBuffer[2]) shl 16);
+          LFinalBlock := LFinalBlock or (UInt64(FBuffer[1]) shl 8);
+          LFinalBlock := LFinalBlock or (UInt64(FBuffer[0]));
         end;
 
       2:
         begin
-          b := b or (UInt64(Fm_buf[1]) shl 8);
-          b := b or (UInt64(Fm_buf[0]));
+          LFinalBlock := LFinalBlock or (UInt64(FBuffer[1]) shl 8);
+          LFinalBlock := LFinalBlock or (UInt64(FBuffer[0]));
         end;
 
       1:
         begin
-          b := b or (UInt64(Fm_buf[0]));
+          LFinalBlock := LFinalBlock or (UInt64(FBuffer[0]));
         end;
-
     end;
   end;
 
-  Fm_v3 := Fm_v3 xor b;
-  CompressTimes(F_cr);
-  Fm_v0 := Fm_v0 xor b;
-  Fm_v2 := Fm_v2 xor $FF;
-  CompressTimes(F_fr);
+  FV3 := FV3 xor LFinalBlock;
+  CompressTimes(FCompressionRounds);
+  FV0 := FV0 xor LFinalBlock;
+  FV2 := FV2 xor $FF;
+  CompressTimes(FFinalizationRounds);
 end;
 
 function TSipHash.GetKey: THashLibByteArray;
@@ -257,8 +252,8 @@ var
 begin
   System.SetLength(LKey, KeyLength.value);
 
-  TConverters.ReadUInt64AsBytesLE(Fm_key0, LKey, 0);
-  TConverters.ReadUInt64AsBytesLE(Fm_key1, LKey, 8);
+  TConverters.ReadUInt64AsBytesLE(FKey0, LKey, 0);
+  TConverters.ReadUInt64AsBytesLE(FKey1, LKey, 8);
 
   result := LKey;
 end;
@@ -270,113 +265,111 @@ end;
 
 procedure TSipHash.Initialize;
 begin
-  Fm_v0 := V0;
-  Fm_v1 := V1;
-  Fm_v2 := V2;
-  Fm_v3 := V3;
-  Fm_total_length := 0;
-  Fm_idx := 0;
-
-  Fm_v3 := Fm_v3 xor Fm_key1;
-  Fm_v2 := Fm_v2 xor Fm_key0;
-  Fm_v1 := Fm_v1 xor Fm_key1;
-  Fm_v0 := Fm_v0 xor Fm_key0;
+  FV0 := V0;
+  FV1 := V1;
+  FV2 := V2;
+  FV3 := V3;
+  FTotalLength := 0;
+  FIdx := 0;
+
+  FV3 := FV3 xor FKey1;
+  FV2 := FV2 xor FKey0;
+  FV1 := FV1 xor FKey1;
+  FV0 := FV0 xor FKey0;
 
 end;
 
-procedure TSipHash.SetKey(const value: THashLibByteArray);
+procedure TSipHash.SetKey(const AValue: THashLibByteArray);
 begin
-  if (value = Nil) then
+  if (AValue = Nil) then
   begin
-    Fm_key0 := KEY0;
-    Fm_key1 := KEY1;
+    FKey0 := KEY0;
+    FKey1 := KEY1;
   end
-
   else
   begin
-    if System.Length(value) <> KeyLength.value then
+    if System.Length(AValue) <> KeyLength.value then
+    begin
       raise EArgumentHashLibException.CreateResFmt(@SInvalidKeyLength,
         [KeyLength.value]);
+    end;
 
-    Fm_key0 := TConverters.ReadBytesAsUInt64LE(PByte(value), 0);
-    Fm_key1 := TConverters.ReadBytesAsUInt64LE(PByte(value), 8);
+    FKey0 := TConverters.ReadBytesAsUInt64LE(PByte(AValue), 0);
+    FKey1 := TConverters.ReadBytesAsUInt64LE(PByte(AValue), 8);
   end;
 end;
 
-procedure TSipHash.TransformBytes(const a_data: THashLibByteArray;
-  a_index, a_length: Int32);
+procedure TSipHash.TransformBytes(const AData: THashLibByteArray;
+  AIndex, ALength: Int32);
 var
-  i, &length, iter, offset: Int32;
-  ptr_a_data, ptr_Fm_buf: PByte;
-  m: UInt64;
+  LIdx, LLength, LBlockCount, LOffset: Int32;
+  LPtrData, LPtrBuffer: PByte;
+  LBlock: UInt64;
 begin
 {$IFDEF DEBUG}
-  System.Assert(a_index >= 0);
-  System.Assert(a_length >= 0);
-  System.Assert(a_index + a_length <= System.Length(a_data));
+  System.Assert(AIndex >= 0);
+  System.Assert(ALength >= 0);
+  System.Assert(AIndex + ALength <= System.Length(AData));
 {$ENDIF DEBUG}
-  Length := a_length;
-  i := a_index;
+  LLength := ALength;
+  LIdx := AIndex;
 
-  ptr_a_data := PByte(a_data);
-  System.Inc(Fm_total_length, Length);
+  LPtrData := PByte(AData);
+  System.Inc(FTotalLength, LLength);
 
   // consume last pending bytes
 
-  if ((Fm_idx <> 0) and (a_length <> 0)) then
+  if ((FIdx <> 0) and (ALength <> 0)) then
   begin
-
 {$IFDEF DEBUG}
-    System.Assert(a_index = 0); // nothing would work anyways if a_index is !=0
+    System.Assert(AIndex = 0); // nothing would work anyways if AIndex is !=0
 {$ENDIF DEBUG}
-    while ((Fm_idx < 8) and (Length <> 0)) do
+    while ((FIdx < 8) and (LLength <> 0)) do
     begin
-      Fm_buf[Fm_idx] := (ptr_a_data + a_index)^;
-      System.Inc(Fm_idx);
-      System.Inc(a_index);
-      System.Dec(Length);
+      FBuffer[FIdx] := (LPtrData + AIndex)^;
+      System.Inc(FIdx);
+      System.Inc(AIndex);
+      System.Dec(LLength);
     end;
-    if (Fm_idx = 8) then
+    if (FIdx = 8) then
     begin
-      ptr_Fm_buf := PByte(Fm_buf);
-      m := TConverters.ReadBytesAsUInt64LE(ptr_Fm_buf, 0);
-      ProcessBlock(m);
-      Fm_idx := 0;
+      LPtrBuffer := PByte(FBuffer);
+      LBlock := TConverters.ReadBytesAsUInt64LE(LPtrBuffer, 0);
+      ProcessBlock(LBlock);
+      FIdx := 0;
     end;
   end
   else
   begin
-    i := 0;
+    LIdx := 0;
   end;
 
-  iter := Length shr 3;
+  LBlockCount := LLength shr 3;
 
   // body
 
-  while i < iter do
+  while LIdx < LBlockCount do
   begin
-    m := TConverters.ReadBytesAsUInt64LE(ptr_a_data, a_index + (i * 8));
-    ProcessBlock(m);
-    System.Inc(i);
+    LBlock := TConverters.ReadBytesAsUInt64LE(LPtrData, AIndex + (LIdx * 8));
+    ProcessBlock(LBlock);
+    System.Inc(LIdx);
   end;
 
   // save pending end bytes
-  offset := a_index + (i * 8);
+  LOffset := AIndex + (LIdx * 8);
 
-  while offset < (Length + a_index) do
+  while LOffset < (LLength + AIndex) do
   begin
-    ByteUpdate(a_data[offset]);
-    System.Inc(offset);
+    ByteUpdate(AData[LOffset]);
+    System.Inc(LOffset);
   end;
-
 end;
 
 function TSipHash.TransformFinal: IHashResult;
 begin
   Finish();
-  result := THashResult.Create(Fm_v0 xor Fm_v1 xor Fm_v2 xor Fm_v3);
+  result := THashResult.Create(FV0 xor FV1 xor FV2 xor FV3);
   Initialize();
 end;
 
 end.
-

+ 108 - 118
src/libraries/hashlib4pascal/HlpSnefru.pas

@@ -5,11 +5,7 @@ unit HlpSnefru;
 interface
 
 uses
-{$IFDEF HAS_UNITSCOPE}
-  System.SysUtils,
-{$ELSE}
   SysUtils,
-{$ENDIF HAS_UNITSCOPE}
   HlpHashLibTypes,
 {$IFDEF DELPHI}
   HlpHash,
@@ -36,16 +32,16 @@ type
   TSnefru = class sealed(TBlockHash, ICryptoNotBuildIn, ITransformBlock)
 
   strict private
-
-    Fm_state: THashLibUInt32Array;
-    Fm_security_level, FHashSize, FBlockSize: Int32;
+  var
+    FState: THashLibUInt32Array;
+    FSecurityLevel, FHashSize, FBlockSize: Int32;
 
   const
-    s_shifts: array [0 .. 3] of Int32 = (16, 8, 16, 24);
+    SShifts: array [0 .. 3] of Int32 = (16, 8, 16, 24);
 
     class var
 
-      Fs_boxes: THashLibMatrixUInt32Array;
+      FSBoxes: THashLibMatrixUInt32Array;
 
     class constructor Snefru();
 
@@ -55,17 +51,17 @@ type
     function GetName: String; override;
     function GetResult(): THashLibByteArray; override;
     procedure Finish(); override;
-    procedure TransformBlock(a_data: PByte; a_data_length: Int32;
-      a_index: Int32); override;
+    procedure TransformBlock(AData: PByte; ADataLength: Int32;
+      AIndex: Int32); override;
 
   public
     /// <summary>
     ///
     /// </summary>
-    /// <param name="a_security_level">any Integer value greater than 0. Standard is 8. </param>
-    /// <param name="a_hash_size">128bit, 256bit</param>
+    /// <param name="ASecurityLevel">any Integer value greater than 0. Standard is 8. </param>
+    /// <param name="AHashSize">128bit, 256bit</param>
     /// <returns></returns>
-    constructor Create(a_security_level: Int32; a_hash_size: THashSize);
+    constructor Create(ASecurityLevel: Int32; AHashSize: THashSize);
     procedure Initialize(); override;
     function Clone(): IHash; override;
 
@@ -92,171 +88,165 @@ end;
 
 function TSnefru.Clone(): IHash;
 var
-  HashInstance: TSnefru;
+  LHashInstance: TSnefru;
 begin
-  HashInstance := TSnefru.Create(Fm_security_level,
-    GetSnefruHashSize(FHashSize));
-  HashInstance.Fm_state := System.Copy(Fm_state);
-  HashInstance.Fm_buffer := Fm_buffer.Clone();
-  HashInstance.Fm_processed_bytes := Fm_processed_bytes;
-  Result := HashInstance as IHash;
+  LHashInstance := TSnefru.Create(FSecurityLevel, GetSnefruHashSize(FHashSize));
+  LHashInstance.FState := System.Copy(FState);
+  LHashInstance.FBuffer := FBuffer.Clone();
+  LHashInstance.FProcessedBytesCount := FProcessedBytesCount;
+  Result := LHashInstance as IHash;
   Result.BufferSize := BufferSize;
 end;
 
-constructor TSnefru.Create(a_security_level: Int32; a_hash_size: THashSize);
+constructor TSnefru.Create(ASecurityLevel: Int32; AHashSize: THashSize);
 begin
-
-  Inherited Create(Int32(a_hash_size), 64 - (Int32(a_hash_size)));
-  Fm_security_level := Int32(a_security_level);
+  Inherited Create(Int32(AHashSize), 64 - (Int32(AHashSize)));
+  FSecurityLevel := Int32(ASecurityLevel);
   FHashSize := HashSize;
   FBlockSize := BlockSize;
-  System.SetLength(Fm_state, FHashSize shr 2);
-
+  System.SetLength(FState, FHashSize shr 2);
 end;
 
 procedure TSnefru.Finish;
 var
-  bits: UInt64;
-  padindex: Int32;
-  pad: THashLibByteArray;
+  LBits: UInt64;
+  LPadIndex: Int32;
+  LPad: THashLibByteArray;
 begin
-  bits := Fm_processed_bytes * 8;
-  if Fm_buffer.Pos > 0 then
-    padindex := 2 * FBlockSize - Fm_buffer.Pos - 8
+  LBits := FProcessedBytesCount * 8;
+  if FBuffer.Position > 0 then
+  begin
+    LPadIndex := 2 * FBlockSize - FBuffer.Position - 8
+  end
   else
-    padindex := FBlockSize - Fm_buffer.Pos - 8;
-
-  System.SetLength(pad, padindex + 8);
+  begin
+    LPadIndex := FBlockSize - FBuffer.Position - 8;
+  end;
 
-  bits := TConverters.be2me_64(bits);
+  System.SetLength(LPad, LPadIndex + 8);
 
-  TConverters.ReadUInt64AsBytesLE(bits, pad, padindex);
+  LBits := TConverters.be2me_64(LBits);
 
-  padindex := padindex + 8;
+  TConverters.ReadUInt64AsBytesLE(LBits, LPad, LPadIndex);
 
-  TransformBytes(pad, 0, padindex);
+  LPadIndex := LPadIndex + 8;
 
+  TransformBytes(LPad, 0, LPadIndex);
 end;
 
 function TSnefru.GetName: String;
 begin
-  Result := Format('%s_%u_%u', [Self.ClassName, Fm_security_level,
+  Result := Format('%s_%u_%u', [Self.ClassName, FSecurityLevel,
     Self.HashSize * 8]);
 end;
 
 function TSnefru.GetResult: THashLibByteArray;
 begin
-  System.SetLength(Result, System.Length(Fm_state) * System.SizeOf(UInt32));
-  TConverters.be32_copy(PCardinal(Fm_state), 0, PByte(Result), 0,
+  System.SetLength(Result, System.Length(FState) * System.SizeOf(UInt32));
+  TConverters.be32_copy(PCardinal(FState), 0, PByte(Result), 0,
     System.Length(Result));
 end;
 
 procedure TSnefru.Initialize;
 begin
-  TArrayUtils.ZeroFill(Fm_state);
+  TArrayUtils.ZeroFill(FState);
   Inherited Initialize();
 end;
 
-procedure TSnefru.TransformBlock(a_data: PByte; a_data_length: Int32;
-  a_index: Int32);
+procedure TSnefru.TransformBlock(AData: PByte; ADataLength: Int32;
+  AIndex: Int32);
 var
-  sbox0, sbox1: THashLibUInt32Array;
-  i, j, k, shift: Int32;
-  work: array [0 .. 15] of UInt32;
-  ptr_work: PCardinal;
+  LSBox0, LSBox1: THashLibUInt32Array;
+  LIdx, LJdx, LKdx, LShift: Int32;
+  LWork: array [0 .. 15] of UInt32;
+  LPtrWork: PCardinal;
 begin
-
-  ptr_work := @(work[0]);
-  System.Move(Fm_state[0], work[0], System.Length(Fm_state) *
+  LPtrWork := @(LWork[0]);
+  System.Move(FState[0], LWork[0], System.Length(FState) *
     System.SizeOf(UInt32));
 
-  TConverters.be32_copy(a_data, a_index, ptr_work + System.Length(Fm_state), 0,
-    a_data_length);
-
-  i := 0;
+  TConverters.be32_copy(AData, AIndex, LPtrWork + System.Length(FState), 0,
+    ADataLength);
 
-  while i < Fm_security_level do
+  LIdx := 0;
 
+  while LIdx < FSecurityLevel do
   begin
-    sbox0 := Fs_boxes[i * 2 + 0];
-    sbox1 := Fs_boxes[i * 2 + 1];
-
-    j := 0;
-    while j < 4 do
+    LSBox0 := FSBoxes[LIdx * 2 + 0];
+    LSBox1 := FSBoxes[LIdx * 2 + 1];
 
+    LJdx := 0;
+    while LJdx < 4 do
     begin
-
-      work[15] := work[15] xor sbox0[Byte(work[0])];
-      work[1] := work[1] xor sbox0[Byte(work[0])];
-      work[0] := work[0] xor sbox0[Byte(work[1])];
-      work[2] := work[2] xor sbox0[Byte(work[1])];
-      work[1] := work[1] xor sbox1[Byte(work[2])];
-      work[3] := work[3] xor sbox1[Byte(work[2])];
-      work[2] := work[2] xor sbox1[Byte(work[3])];
-      work[4] := work[4] xor sbox1[Byte(work[3])];
-      work[3] := work[3] xor sbox0[Byte(work[4])];
-      work[5] := work[5] xor sbox0[Byte(work[4])];
-      work[4] := work[4] xor sbox0[Byte(work[5])];
-      work[6] := work[6] xor sbox0[Byte(work[5])];
-      work[5] := work[5] xor sbox1[Byte(work[6])];
-      work[7] := work[7] xor sbox1[Byte(work[6])];
-      work[6] := work[6] xor sbox1[Byte(work[7])];
-      work[8] := work[8] xor sbox1[Byte(work[7])];
-      work[7] := work[7] xor sbox0[Byte(work[8])];
-      work[9] := work[9] xor sbox0[Byte(work[8])];
-      work[8] := work[8] xor sbox0[Byte(work[9])];
-      work[10] := work[10] xor sbox0[Byte(work[9])];
-      work[9] := work[9] xor sbox1[Byte(work[10])];
-      work[11] := work[11] xor sbox1[Byte(work[10])];
-      work[10] := work[10] xor sbox1[Byte(work[11])];
-      work[12] := work[12] xor sbox1[Byte(work[11])];
-      work[11] := work[11] xor sbox0[Byte(work[12])];
-      work[13] := work[13] xor sbox0[Byte(work[12])];
-      work[12] := work[12] xor sbox0[Byte(work[13])];
-      work[14] := work[14] xor sbox0[Byte(work[13])];
-      work[13] := work[13] xor sbox1[Byte(work[14])];
-      work[15] := work[15] xor sbox1[Byte(work[14])];
-      work[14] := work[14] xor sbox1[Byte(work[15])];
-      work[0] := work[0] xor sbox1[Byte(work[15])];
-
-      shift := s_shifts[j];
-
-      k := 0;
-
-      while k < 16 do
+      LWork[15] := LWork[15] xor LSBox0[Byte(LWork[0])];
+      LWork[1] := LWork[1] xor LSBox0[Byte(LWork[0])];
+      LWork[0] := LWork[0] xor LSBox0[Byte(LWork[1])];
+      LWork[2] := LWork[2] xor LSBox0[Byte(LWork[1])];
+      LWork[1] := LWork[1] xor LSBox1[Byte(LWork[2])];
+      LWork[3] := LWork[3] xor LSBox1[Byte(LWork[2])];
+      LWork[2] := LWork[2] xor LSBox1[Byte(LWork[3])];
+      LWork[4] := LWork[4] xor LSBox1[Byte(LWork[3])];
+      LWork[3] := LWork[3] xor LSBox0[Byte(LWork[4])];
+      LWork[5] := LWork[5] xor LSBox0[Byte(LWork[4])];
+      LWork[4] := LWork[4] xor LSBox0[Byte(LWork[5])];
+      LWork[6] := LWork[6] xor LSBox0[Byte(LWork[5])];
+      LWork[5] := LWork[5] xor LSBox1[Byte(LWork[6])];
+      LWork[7] := LWork[7] xor LSBox1[Byte(LWork[6])];
+      LWork[6] := LWork[6] xor LSBox1[Byte(LWork[7])];
+      LWork[8] := LWork[8] xor LSBox1[Byte(LWork[7])];
+      LWork[7] := LWork[7] xor LSBox0[Byte(LWork[8])];
+      LWork[9] := LWork[9] xor LSBox0[Byte(LWork[8])];
+      LWork[8] := LWork[8] xor LSBox0[Byte(LWork[9])];
+      LWork[10] := LWork[10] xor LSBox0[Byte(LWork[9])];
+      LWork[9] := LWork[9] xor LSBox1[Byte(LWork[10])];
+      LWork[11] := LWork[11] xor LSBox1[Byte(LWork[10])];
+      LWork[10] := LWork[10] xor LSBox1[Byte(LWork[11])];
+      LWork[12] := LWork[12] xor LSBox1[Byte(LWork[11])];
+      LWork[11] := LWork[11] xor LSBox0[Byte(LWork[12])];
+      LWork[13] := LWork[13] xor LSBox0[Byte(LWork[12])];
+      LWork[12] := LWork[12] xor LSBox0[Byte(LWork[13])];
+      LWork[14] := LWork[14] xor LSBox0[Byte(LWork[13])];
+      LWork[13] := LWork[13] xor LSBox1[Byte(LWork[14])];
+      LWork[15] := LWork[15] xor LSBox1[Byte(LWork[14])];
+      LWork[14] := LWork[14] xor LSBox1[Byte(LWork[15])];
+      LWork[0] := LWork[0] xor LSBox1[Byte(LWork[15])];
+
+      LShift := SShifts[LJdx];
+
+      LKdx := 0;
+
+      while LKdx < 16 do
       begin
-        work[k] := TBits.RotateRight32(work[k], shift);
-        System.Inc(k);
+        LWork[LKdx] := TBits.RotateRight32(LWork[LKdx], LShift);
+        System.Inc(LKdx);
       end;
 
-      System.Inc(j);
+      System.Inc(LJdx);
     end;
 
-    System.Inc(i);
+    System.Inc(LIdx);
   end;
 
-  Fm_state[0] := Fm_state[0] xor work[15];
-  Fm_state[1] := Fm_state[1] xor work[14];
-  Fm_state[2] := Fm_state[2] xor work[13];
-  Fm_state[3] := Fm_state[3] xor work[12];
+  FState[0] := FState[0] xor LWork[15];
+  FState[1] := FState[1] xor LWork[14];
+  FState[2] := FState[2] xor LWork[13];
+  FState[3] := FState[3] xor LWork[12];
 
   if (FHashSize = 32) then
   begin
-    Fm_state[4] := Fm_state[4] xor work[11];
-    Fm_state[5] := Fm_state[5] xor work[10];
-    Fm_state[6] := Fm_state[6] xor work[9];
-    Fm_state[7] := Fm_state[7] xor work[8];
+    FState[4] := FState[4] xor LWork[11];
+    FState[5] := FState[5] xor LWork[10];
+    FState[6] := FState[6] xor LWork[9];
+    FState[7] := FState[7] xor LWork[8];
   end;
 
-  System.FillChar(work, System.SizeOf(work), UInt32(0));
-
+  System.FillChar(LWork, System.SizeOf(LWork), UInt32(0));
 end;
 
 class constructor TSnefru.Snefru;
 begin
-
 {$REGION 'Consts'}
-  Fs_boxes := THashLibMatrixUInt32Array.Create
+  FSBoxes := THashLibMatrixUInt32Array.Create
     (THashLibUInt32Array.Create($64F9001B, $FEDDCDF6, $7C8FF1E2, $11D71514,
     $8B8C18D3, $DDDF881E, $6EAB5056, $88CED8E1, $49148959, $69C56FD5, $B7994F03,
     $0FBCEE3E, $3C264940, $21557E58, $E14B3FC2, $2E5CF591, $DCEFF8CE, $092A1648,

+ 52 - 55
src/libraries/hashlib4pascal/HlpSuperFast.pas

@@ -21,7 +21,7 @@ type
     ITransformBlock)
 
   strict protected
-    function ComputeAggregatedBytes(const a_data: THashLibByteArray)
+    function ComputeAggregatedBytes(const AData: THashLibByteArray)
       : IHashResult; override;
   public
     constructor Create();
@@ -40,95 +40,92 @@ end;
 
 function TSuperFast.Clone(): IHash;
 var
-  HashInstance: TSuperFast;
+  LHashInstance: TSuperFast;
 begin
-  HashInstance := TSuperFast.Create();
+  LHashInstance := TSuperFast.Create();
   FBuffer.Position := 0;
-  HashInstance.FBuffer.CopyFrom(FBuffer, FBuffer.Size);
-  result := HashInstance as IHash;
+  LHashInstance.FBuffer.CopyFrom(FBuffer, FBuffer.Size);
+  result := LHashInstance as IHash;
   result.BufferSize := BufferSize;
 end;
 
-function TSuperFast.ComputeAggregatedBytes(const a_data: THashLibByteArray)
+function TSuperFast.ComputeAggregatedBytes(const AData: THashLibByteArray)
   : IHashResult;
 var
-  hash, tmp, u1: UInt32;
-  &length, currentIndex, i1, i2: Int32;
+  LHash, LTemp, U1: UInt32;
+  LLength, LCurrentIndex, I1, I2: Int32;
 begin
-  length := System.length(a_data);
+  LLength := System.length(AData);
 
-  if (length = 0) then
+  if (LLength = 0) then
   begin
     result := THashResult.Create(Int32(0));
     Exit;
   end;
 
-  hash := UInt32(length);
+  LHash := UInt32(LLength);
 
-  currentIndex := 0;
+  LCurrentIndex := 0;
 
-  while (length >= 4) do
+  while (LLength >= 4) do
   begin
-    i1 := a_data[currentIndex];
-    System.Inc(currentIndex);
-    i2 := a_data[currentIndex] shl 8;
-    System.Inc(currentIndex);
-    hash := UInt16(hash + UInt32(i1 or i2));
-    u1 := UInt32(a_data[currentIndex]);
-    System.Inc(currentIndex);
-    tmp := UInt32((Byte(u1) or a_data[currentIndex] shl 8) shl 11) xor hash;
-    System.Inc(currentIndex);
-    hash := (hash shl 16) xor tmp;
-    hash := hash + (hash shr 11);
-
-    System.Dec(length, 4);
+    I1 := AData[LCurrentIndex];
+    System.Inc(LCurrentIndex);
+    I2 := AData[LCurrentIndex] shl 8;
+    System.Inc(LCurrentIndex);
+    LHash := UInt16(LHash + UInt32(I1 or I2));
+    U1 := UInt32(AData[LCurrentIndex]);
+    System.Inc(LCurrentIndex);
+    LTemp := UInt32((Byte(U1) or AData[LCurrentIndex] shl 8) shl 11) xor LHash;
+    System.Inc(LCurrentIndex);
+    LHash := (LHash shl 16) xor LTemp;
+    LHash := LHash + (LHash shr 11);
+
+    System.Dec(LLength, 4);
   end;
 
-  case length of
+  case LLength of
     3:
       begin
-        i1 := a_data[currentIndex];
-        System.Inc(currentIndex);
-        i2 := a_data[currentIndex];
-        System.Inc(currentIndex);
-        hash := hash + UInt16(i1 or i2 shl 8);
-        hash := hash xor (hash shl 16);
-        hash := hash xor (UInt32(a_data[currentIndex]) shl 18);
-        hash := hash + (hash shr 11);
-
+        I1 := AData[LCurrentIndex];
+        System.Inc(LCurrentIndex);
+        I2 := AData[LCurrentIndex];
+        System.Inc(LCurrentIndex);
+        LHash := LHash + UInt16(I1 or I2 shl 8);
+        LHash := LHash xor (LHash shl 16);
+        LHash := LHash xor (UInt32(AData[LCurrentIndex]) shl 18);
+        LHash := LHash + (LHash shr 11);
       end;
 
     2:
       begin
-        i1 := a_data[currentIndex];
-        System.Inc(currentIndex);
-        i2 := a_data[currentIndex];
-        hash := hash + UInt16(i1 or i2 shl 8);
-        hash := hash xor (hash shl 11);
-        hash := hash + (hash shr 17);
-
+        I1 := AData[LCurrentIndex];
+        System.Inc(LCurrentIndex);
+        I2 := AData[LCurrentIndex];
+        LHash := LHash + UInt16(I1 or I2 shl 8);
+        LHash := LHash xor (LHash shl 11);
+        LHash := LHash + (LHash shr 17);
       end;
 
     1:
       begin
-        i1 := a_data[currentIndex];
-
-        hash := hash + UInt32(i1);
-        hash := hash xor (hash shl 10);
-        hash := hash + (hash shr 1);
+        I1 := AData[LCurrentIndex];
 
+        LHash := LHash + UInt32(I1);
+        LHash := LHash xor (LHash shl 10);
+        LHash := LHash + (LHash shr 1);
       end;
 
   end;
 
-  hash := hash xor (hash shl 3);
-  hash := hash + (hash shr 5);
-  hash := hash xor (hash shl 4);
-  hash := hash + (hash shr 17);
-  hash := hash xor (hash shl 25);
-  hash := hash + (hash shr 6);
+  LHash := LHash xor (LHash shl 3);
+  LHash := LHash + (LHash shr 5);
+  LHash := LHash xor (LHash shl 4);
+  LHash := LHash + (LHash shr 17);
+  LHash := LHash xor (LHash shl 25);
+  LHash := LHash + (LHash shr 6);
 
-  result := THashResult.Create(hash);
+  result := THashResult.Create(LHash);
 end;
 
 end.

+ 363 - 370
src/libraries/hashlib4pascal/HlpTiger.pas

@@ -5,15 +5,11 @@ unit HlpTiger;
 interface
 
 uses
-{$IFDEF HAS_UNITSCOPE}
-  System.SysUtils,
-{$ELSE}
   SysUtils,
-{$ENDIF HAS_UNITSCOPE}
 {$IFDEF DELPHI}
-  HlpBitConverter,
-  HlpHashBuffer,
   HlpHash,
+  HlpHashBuffer,
+  HlpBitConverter,
 {$ENDIF DELPHI}
   HlpHashLibTypes,
   HlpConverters,
@@ -38,7 +34,7 @@ type
     C1 = UInt64($A5A5A5A5A5A5A5A5);
     C2 = UInt64($0123456789ABCDEF);
 
-    s_T1: array [0 .. 255] of UInt64 = (UInt64($02AAB17CF7E90C5E),
+    ST1: array [0 .. 255] of UInt64 = (UInt64($02AAB17CF7E90C5E),
       UInt64($AC424B03E243A8EC), UInt64($72CD5BE30DD5FCD3),
       UInt64($6D019B93F6F97F3A), UInt64($CD9978FFD21F9193),
       UInt64($7573A1C9708029E2), UInt64($B164326B922A83C3),
@@ -168,7 +164,7 @@ type
       UInt64($E72B3BD61464D43D), UInt64($A6300F170BDC4820),
       UInt64($EBC18760ED78A77A));
 
-    s_T2: array [0 .. 255] of UInt64 = (UInt64($E6A6BE5A05A12138),
+    ST2: array [0 .. 255] of UInt64 = (UInt64($E6A6BE5A05A12138),
       UInt64($B5A122A5B4F87C98), UInt64($563C6089140B6990),
       UInt64($4C46CB2E391F5DD5), UInt64($D932ADDBC9B79434),
       UInt64($08EA70E42015AFF5), UInt64($D765A6673E478CF1),
@@ -298,7 +294,7 @@ type
       UInt64($4DF7F0B7B1498371), UInt64($D62A2EABC0977179),
       UInt64($22FAC097AA8D5C0E));
 
-    s_T3: array [0 .. 255] of UInt64 = (UInt64($F49FCC2FF1DAF39B),
+    ST3: array [0 .. 255] of UInt64 = (UInt64($F49FCC2FF1DAF39B),
       UInt64($487FD5C66FF29281), UInt64($E8A30667FCDCA83F),
       UInt64($2C9B4BE3D2FCCE63), UInt64($DA3FF74B93FBBBC2),
       UInt64($2FA165D2FE70BA66), UInt64($A103E279970E93D4),
@@ -428,7 +424,7 @@ type
       UInt64($419CF6496412691C), UInt64($D3DC3BEF265B0F70),
       UInt64($6D0E60F5C3578A9E));
 
-    s_T4: array [0 .. 255] of UInt64 = (UInt64($5B0E608526323C55),
+    ST4: array [0 .. 255] of UInt64 = (UInt64($5B0E608526323C55),
       UInt64($1A46C1A9FA1B59F5), UInt64($A9E245A17C4C8FFA),
       UInt64($65CA5159DB2955D7), UInt64($05DB0A76CE35AFC2),
       UInt64($81EAC77EA9113D45), UInt64($528EF88AB6AC0A0D),
@@ -560,16 +556,17 @@ type
 
 {$ENDREGION}
   strict protected
-    Fm_rounds: Int32;
-    Fm_hash: THashLibUInt64Array;
+  var
+    FRounds: Int32;
+    FHash: THashLibUInt64Array;
 
-    constructor Create(a_hash_size: Int32; a_rounds: THashRounds);
+    constructor Create(AHashSize: Int32; ARounds: THashRounds);
 
     function GetName: String; override;
     function GetResult(): THashLibByteArray; override;
     procedure Finish(); override;
-    procedure TransformBlock(a_data: PByte; a_data_length: Int32;
-      a_index: Int32); override;
+    procedure TransformBlock(AData: PByte; ADataLength: Int32;
+      AIndex: Int32); override;
 
     function GetHashRound(AHashRound: Int32): THashRounds; inline;
 
@@ -583,7 +580,7 @@ type
   TTiger_Base = class sealed(TTiger)
 
   public
-    constructor Create(a_hash_size: Int32; a_rounds: THashRounds);
+    constructor Create(AHashSize: Int32; ARounds: THashRounds);
     function Clone(): IHash; override;
 
   end;
@@ -646,383 +643,379 @@ begin
   end;
 end;
 
-constructor TTiger.Create(a_hash_size: Int32; a_rounds: THashRounds);
+constructor TTiger.Create(AHashSize: Int32; ARounds: THashRounds);
 begin
-  Inherited Create(a_hash_size, 64);
-  System.SetLength(Fm_hash, 3);
-  Fm_rounds := Int32(a_rounds);
+  Inherited Create(AHashSize, 64);
+  System.SetLength(FHash, 3);
+  FRounds := Int32(ARounds);
 end;
 
 procedure TTiger.Finish;
 var
-  bits: UInt64;
-  padindex: Int32;
-  pad: THashLibByteArray;
-
+  LBits: UInt64;
+  LPadIndex: Int32;
+  LPad: THashLibByteArray;
 begin
-  bits := Fm_processed_bytes * 8;
-  if Fm_buffer.Pos < 56 then
-    padindex := 56 - Fm_buffer.Pos
+  LBits := FProcessedBytesCount * 8;
+  if FBuffer.Position < 56 then
+  begin
+    LPadIndex := 56 - FBuffer.Position
+  end
   else
-    padindex := 120 - Fm_buffer.Pos;
-  System.SetLength(pad, padindex + 8);
-
-  pad[0] := 1;
+  begin
+    LPadIndex := 120 - FBuffer.Position;
+  end;
+  System.SetLength(LPad, LPadIndex + 8);
 
-  bits := TConverters.le2me_64(bits);
+  LPad[0] := 1;
 
-  TConverters.ReadUInt64AsBytesLE(bits, pad, padindex);
+  LBits := TConverters.le2me_64(LBits);
 
-  padindex := padindex + 8;
+  TConverters.ReadUInt64AsBytesLE(LBits, LPad, LPadIndex);
 
-  TransformBytes(pad, 0, padindex);
+  LPadIndex := LPadIndex + 8;
 
+  TransformBytes(LPad, 0, LPadIndex);
 end;
 
 function TTiger.GetName: String;
 begin
-  Result := Format('%s_%u_%u', [Self.ClassParent.ClassName, Fm_rounds,
+  Result := Format('%s_%u_%u', [Self.ClassParent.ClassName, FRounds,
     Self.HashSize * 8]);
 end;
 
 function TTiger.GetResult: THashLibByteArray;
 begin
   System.SetLength(Result, HashSize);
-  TConverters.le64_copy(PUInt64(Fm_hash), 0, PByte(Result), 0,
+  TConverters.le64_copy(PUInt64(FHash), 0, PByte(Result), 0,
     System.Length(Result));
 end;
 
 procedure TTiger.Initialize;
 begin
-
-  Fm_hash[0] := $0123456789ABCDEF;
-  Fm_hash[1] := UInt64($FEDCBA9876543210);
-  Fm_hash[2] := UInt64($F096A5B4C3B2E187);
-
+  FHash[0] := $0123456789ABCDEF;
+  FHash[1] := UInt64($FEDCBA9876543210);
+  FHash[2] := UInt64($F096A5B4C3B2E187);
   Inherited Initialize();
-
 end;
 
-procedure TTiger.TransformBlock(a_data: PByte; a_data_length: Int32;
-  a_index: Int32);
+procedure TTiger.TransformBlock(AData: PByte; ADataLength: Int32;
+  AIndex: Int32);
 var
-  a, b, c, temp_a: UInt64;
-  rounds: Int32;
-  data: array [0 .. 7] of UInt64;
+  LA, LB, LC, LTempA: UInt64;
+  LRounds: Int32;
+  LData: array [0 .. 7] of UInt64;
 begin
-
-  TConverters.le64_copy(a_data, a_index, @(data[0]), 0, a_data_length);
-
-  a := Fm_hash[0];
-  b := Fm_hash[1];
-  c := Fm_hash[2];
-
-  c := c xor data[0];
-  a := a - (s_T1[Byte(c)] xor s_T2[Byte(c shr 16)] xor s_T3[Byte(c shr 32)
-    ] xor s_T4[Byte(c shr 48)]);
-  b := b + (s_T4[Byte(c shr 8) and $FF] xor s_T3[Byte(c shr 24)
-    ] xor s_T2[Byte(c shr 40)] xor s_T1[Byte(c shr 56)]);
-  b := b * 5;
-
-  a := a xor data[1];
-  b := b - (s_T1[Byte(a)] xor s_T2[Byte(a shr 16)] xor s_T3[Byte(a shr 32)
-    ] xor s_T4[Byte(a shr 48)]);
-  c := c + (s_T4[Byte(a shr 8)] xor s_T3[Byte(a shr 24)] xor s_T2[Byte(a shr 40)
-    ] xor s_T1[Byte(a shr 56)]);
-  c := c * 5;
-
-  b := b xor data[2];
-  c := c - (s_T1[Byte(b)] xor s_T2[Byte(b shr 16)] xor s_T3[Byte(b shr 32)
-    ] xor s_T4[Byte(b shr 48)]);
-  a := a + (s_T4[Byte(b shr 8)] xor s_T3[Byte(b shr 24)] xor s_T2[Byte(b shr 40)
-    ] xor s_T1[Byte(b shr 56)]);
-  a := a * 5;
-
-  c := c xor data[3];
-  a := a - (s_T1[Byte(c)] xor s_T2[Byte(c shr 16)] xor s_T3[Byte(c shr 32)
-    ] xor s_T4[Byte(c shr 48)]);
-  b := b + (s_T4[Byte(c shr 8) and $FF] xor s_T3[Byte(c shr 24)
-    ] xor s_T2[Byte(c shr 40)] xor s_T1[Byte(c shr 56)]);
-  b := b * 5;
-
-  a := a xor data[4];
-  b := b - (s_T1[Byte(a)] xor s_T2[Byte(a shr 16)] xor s_T3[Byte(a shr 32)
-    ] xor s_T4[Byte(a shr 48)]);
-  c := c + (s_T4[Byte(a shr 8)] xor s_T3[Byte(a shr 24)] xor s_T2[Byte(a shr 40)
-    ] xor s_T1[Byte(a shr 56)]);
-  c := c * 5;
-
-  b := b xor data[5];
-  c := c - (s_T1[Byte(b)] xor s_T2[Byte(b shr 16)] xor s_T3[Byte(b shr 32)
-    ] xor s_T4[Byte(b shr 48)]);
-  a := a + (s_T4[Byte(b shr 8)] xor s_T3[Byte(b shr 24)] xor s_T2[Byte(b shr 40)
-    ] xor s_T1[Byte(b shr 56)]);
-  a := a * 5;
-
-  c := c xor data[6];
-  a := a - (s_T1[Byte(c)] xor s_T2[Byte(c shr 16)] xor s_T3[Byte(c shr 32)
-    ] xor s_T4[Byte(c shr 48)]);
-  b := b + (s_T4[Byte(c shr 8) and $FF] xor s_T3[Byte(c shr 24)
-    ] xor s_T2[Byte(c shr 40)] xor s_T1[Byte(c shr 56)]);
-  b := b * 5;
-
-  a := a xor data[7];
-  b := b - (s_T1[Byte(a)] xor s_T2[Byte(a shr 16)] xor s_T3[Byte(a shr 32)
-    ] xor s_T4[Byte(a shr 48)]);
-  c := c + (s_T4[Byte(a shr 8)] xor s_T3[Byte(a shr 24)] xor s_T2[Byte(a shr 40)
-    ] xor s_T1[Byte(a shr 56)]);
-  c := c * 5;
-
-  data[0] := data[0] - (data[7] xor C1);
-  data[1] := data[1] xor data[0];
-  data[2] := data[2] + data[1];
-  data[3] := data[3] - (data[2] xor (not data[1] shl 19));
-  data[4] := data[4] xor data[3];
-  data[5] := data[5] + data[4];
-  data[6] := data[6] - (data[5] xor (not data[4] shr 23));
-  data[7] := data[7] xor data[6];
-  data[0] := data[0] + data[7];
-  data[1] := data[1] - (data[0] xor (not data[7] shl 19));
-  data[2] := data[2] xor data[1];
-  data[3] := data[3] + data[2];
-  data[4] := data[4] - (data[3] xor (not data[2] shr 23));
-  data[5] := data[5] xor data[4];
-  data[6] := data[6] + data[5];
-  data[7] := data[7] - (data[6] xor C2);
-
-  b := b xor data[0];
-  c := c - (s_T1[Byte(b)] xor s_T2[Byte(b shr 16)] xor s_T3[Byte(b shr 32)
-    ] xor s_T4[Byte(b shr 48)]);
-  a := a + (s_T4[Byte(b shr 8)] xor s_T3[Byte(b shr 24)] xor s_T2[Byte(b shr 40)
-    ] xor s_T1[Byte(b shr 56)]);
-  a := a * 7;
-
-  c := c xor data[1];
-  a := a - (s_T1[Byte(c)] xor s_T2[Byte(c shr 16)] xor s_T3[Byte(c shr 32)
-    ] xor s_T4[Byte(c shr 48)]);
-  b := b + (s_T4[Byte(c shr 8) and $FF] xor s_T3[Byte(c shr 24)
-    ] xor s_T2[Byte(c shr 40)] xor s_T1[Byte(c shr 56)]);
-  b := b * 7;
-
-  a := a xor data[2];
-  b := b - (s_T1[Byte(a)] xor s_T2[Byte(a shr 16)] xor s_T3[Byte(a shr 32)
-    ] xor s_T4[Byte(a shr 48)]);
-  c := c + (s_T4[Byte(a shr 8)] xor s_T3[Byte(a shr 24)] xor s_T2[Byte(a shr 40)
-    ] xor s_T1[Byte(a shr 56)]);
-  c := c * 7;
-
-  b := b xor data[3];
-  c := c - (s_T1[Byte(b)] xor s_T2[Byte(b shr 16)] xor s_T3[Byte(b shr 32)
-    ] xor s_T4[Byte(b shr 48)]);
-  a := a + (s_T4[Byte(b shr 8)] xor s_T3[Byte(b shr 24)] xor s_T2[Byte(b shr 40)
-    ] xor s_T1[Byte(b shr 56)]);
-  a := a * 7;
-
-  c := c xor data[4];
-  a := a - (s_T1[Byte(c)] xor s_T2[Byte(c shr 16)] xor s_T3[Byte(c shr 32)
-    ] xor s_T4[Byte(c shr 48)]);
-  b := b + (s_T4[Byte(c shr 8) and $FF] xor s_T3[Byte(c shr 24)
-    ] xor s_T2[Byte(c shr 40)] xor s_T1[Byte(c shr 56)]);
-  b := b * 7;
-
-  a := a xor data[5];
-  b := b - (s_T1[Byte(a)] xor s_T2[Byte(a shr 16)] xor s_T3[Byte(a shr 32)
-    ] xor s_T4[Byte(a shr 48)]);
-  c := c + (s_T4[Byte(a shr 8)] xor s_T3[Byte(a shr 24)] xor s_T2[Byte(a shr 40)
-    ] xor s_T1[Byte(a shr 56)]);
-  c := c * 7;
-
-  b := b xor data[6];
-  c := c - (s_T1[Byte(b)] xor s_T2[Byte(b shr 16)] xor s_T3[Byte(b shr 32)
-    ] xor s_T4[Byte(b shr 48)]);
-  a := a + (s_T4[Byte(b shr 8)] xor s_T3[Byte(b shr 24)] xor s_T2[Byte(b shr 40)
-    ] xor s_T1[Byte(b shr 56)]);
-  a := a * 7;
-
-  c := c xor data[7];
-  a := a - (s_T1[Byte(c)] xor s_T2[Byte(c shr 16)] xor s_T3[Byte(c shr 32)
-    ] xor s_T4[Byte(c shr 48)]);
-  b := b + (s_T4[Byte(c shr 8) and $FF] xor s_T3[Byte(c shr 24)
-    ] xor s_T2[Byte(c shr 40)] xor s_T1[Byte(c shr 56)]);
-  b := b * 7;
-
-  data[0] := data[0] - (data[7] xor C1);
-  data[1] := data[1] xor data[0];
-  data[2] := data[2] + data[1];
-  data[3] := data[3] - (data[2] xor (not data[1] shl 19));
-  data[4] := data[4] xor data[3];
-  data[5] := data[5] + data[4];
-  data[6] := data[6] - (data[5] xor (not data[4] shr 23));
-  data[7] := data[7] xor data[6];
-  data[0] := data[0] + data[7];
-  data[1] := data[1] - (data[0] xor (not data[7] shl 19));
-  data[2] := data[2] xor data[1];
-  data[3] := data[3] + data[2];
-  data[4] := data[4] - (data[3] xor (not data[2] shr 23));
-  data[5] := data[5] xor data[4];
-  data[6] := data[6] + data[5];
-  data[7] := data[7] - (data[6] xor C2);
-
-  a := a xor data[0];
-  b := b - (s_T1[Byte(a)] xor s_T2[Byte(a shr 16)] xor s_T3[Byte(a shr 32)
-    ] xor s_T4[Byte(a shr 48)]);
-  c := c + (s_T4[Byte(a shr 8)] xor s_T3[Byte(a shr 24)] xor s_T2[Byte(a shr 40)
-    ] xor s_T1[Byte(a shr 56)]);
-  c := c * 9;
-
-  b := b xor data[1];
-  c := c - (s_T1[Byte(b)] xor s_T2[Byte(b shr 16)] xor s_T3[Byte(b shr 32)
-    ] xor s_T4[Byte(b shr 48)]);
-  a := a + (s_T4[Byte(b shr 8)] xor s_T3[Byte(b shr 24)] xor s_T2[Byte(b shr 40)
-    ] xor s_T1[Byte(b shr 56)]);
-  a := a * 9;
-
-  c := c xor data[2];
-  a := a - (s_T1[Byte(c)] xor s_T2[Byte(c shr 16)] xor s_T3[Byte(c shr 32)
-    ] xor s_T4[Byte(c shr 48)]);
-  b := b + (s_T4[Byte(c shr 8) and $FF] xor s_T3[Byte(c shr 24)
-    ] xor s_T2[Byte(c shr 40)] xor s_T1[Byte(c shr 56)]);
-  b := b * 9;
-
-  a := a xor data[3];
-  b := b - (s_T1[Byte(a)] xor s_T2[Byte(a shr 16)] xor s_T3[Byte(a shr 32)
-    ] xor s_T4[Byte(a shr 48)]);
-  c := c + (s_T4[Byte(a shr 8)] xor s_T3[Byte(a shr 24)] xor s_T2[Byte(a shr 40)
-    ] xor s_T1[Byte(a shr 56)]);
-  c := c * 9;
-
-  b := b xor data[4];
-  c := c - (s_T1[Byte(b)] xor s_T2[Byte(b shr 16)] xor s_T3[Byte(b shr 32)
-    ] xor s_T4[Byte(b shr 48)]);
-  a := a + (s_T4[Byte(b shr 8)] xor s_T3[Byte(b shr 24)] xor s_T2[Byte(b shr 40)
-    ] xor s_T1[Byte(b shr 56)]);
-  a := a * 9;
-
-  c := c xor data[5];
-  a := a - (s_T1[Byte(c)] xor s_T2[Byte(c shr 16)] xor s_T3[Byte(c shr 32)
-    ] xor s_T4[Byte(c shr 48)]);
-  b := b + (s_T4[Byte(c shr 8) and $FF] xor s_T3[Byte(c shr 24)
-    ] xor s_T2[Byte(c shr 40)] xor s_T1[Byte(c shr 56)]);
-  b := b * 9;
-
-  a := a xor data[6];
-  b := b - (s_T1[Byte(a)] xor s_T2[Byte(a shr 16)] xor s_T3[Byte(a shr 32)
-    ] xor s_T4[Byte(a shr 48)]);
-  c := c + (s_T4[Byte(a shr 8)] xor s_T3[Byte(a shr 24)] xor s_T2[Byte(a shr 40)
-    ] xor s_T1[Byte(a shr 56)]);
-  c := c * 9;
-
-  b := b xor data[7];
-  c := c - (s_T1[Byte(b)] xor s_T2[Byte(b shr 16)] xor s_T3[Byte(b shr 32)
-    ] xor s_T4[Byte(b shr 48)]);
-  a := a + (s_T4[Byte(b shr 8)] xor s_T3[Byte(b shr 24)] xor s_T2[Byte(b shr 40)
-    ] xor s_T1[Byte(b shr 56)]);
-  a := a * 9;
-
-  rounds := 3;
-  while rounds < Fm_rounds do
+  TConverters.le64_copy(AData, AIndex, @(LData[0]), 0, ADataLength);
+
+  LA := FHash[0];
+  LB := FHash[1];
+  LC := FHash[2];
+
+  LC := LC xor LData[0];
+  LA := LA - (ST1[Byte(LC)] xor ST2[Byte(LC shr 16)] xor ST3[Byte(LC shr 32)
+    ] xor ST4[Byte(LC shr 48)]);
+  LB := LB + (ST4[Byte(LC shr 8) and $FF] xor ST3[Byte(LC shr 24)
+    ] xor ST2[Byte(LC shr 40)] xor ST1[Byte(LC shr 56)]);
+  LB := LB * 5;
+
+  LA := LA xor LData[1];
+  LB := LB - (ST1[Byte(LA)] xor ST2[Byte(LA shr 16)] xor ST3[Byte(LA shr 32)
+    ] xor ST4[Byte(LA shr 48)]);
+  LC := LC + (ST4[Byte(LA shr 8)] xor ST3[Byte(LA shr 24)
+    ] xor ST2[Byte(LA shr 40)] xor ST1[Byte(LA shr 56)]);
+  LC := LC * 5;
+
+  LB := LB xor LData[2];
+  LC := LC - (ST1[Byte(LB)] xor ST2[Byte(LB shr 16)] xor ST3[Byte(LB shr 32)
+    ] xor ST4[Byte(LB shr 48)]);
+  LA := LA + (ST4[Byte(LB shr 8)] xor ST3[Byte(LB shr 24)
+    ] xor ST2[Byte(LB shr 40)] xor ST1[Byte(LB shr 56)]);
+  LA := LA * 5;
+
+  LC := LC xor LData[3];
+  LA := LA - (ST1[Byte(LC)] xor ST2[Byte(LC shr 16)] xor ST3[Byte(LC shr 32)
+    ] xor ST4[Byte(LC shr 48)]);
+  LB := LB + (ST4[Byte(LC shr 8) and $FF] xor ST3[Byte(LC shr 24)
+    ] xor ST2[Byte(LC shr 40)] xor ST1[Byte(LC shr 56)]);
+  LB := LB * 5;
+
+  LA := LA xor LData[4];
+  LB := LB - (ST1[Byte(LA)] xor ST2[Byte(LA shr 16)] xor ST3[Byte(LA shr 32)
+    ] xor ST4[Byte(LA shr 48)]);
+  LC := LC + (ST4[Byte(LA shr 8)] xor ST3[Byte(LA shr 24)
+    ] xor ST2[Byte(LA shr 40)] xor ST1[Byte(LA shr 56)]);
+  LC := LC * 5;
+
+  LB := LB xor LData[5];
+  LC := LC - (ST1[Byte(LB)] xor ST2[Byte(LB shr 16)] xor ST3[Byte(LB shr 32)
+    ] xor ST4[Byte(LB shr 48)]);
+  LA := LA + (ST4[Byte(LB shr 8)] xor ST3[Byte(LB shr 24)
+    ] xor ST2[Byte(LB shr 40)] xor ST1[Byte(LB shr 56)]);
+  LA := LA * 5;
+
+  LC := LC xor LData[6];
+  LA := LA - (ST1[Byte(LC)] xor ST2[Byte(LC shr 16)] xor ST3[Byte(LC shr 32)
+    ] xor ST4[Byte(LC shr 48)]);
+  LB := LB + (ST4[Byte(LC shr 8) and $FF] xor ST3[Byte(LC shr 24)
+    ] xor ST2[Byte(LC shr 40)] xor ST1[Byte(LC shr 56)]);
+  LB := LB * 5;
+
+  LA := LA xor LData[7];
+  LB := LB - (ST1[Byte(LA)] xor ST2[Byte(LA shr 16)] xor ST3[Byte(LA shr 32)
+    ] xor ST4[Byte(LA shr 48)]);
+  LC := LC + (ST4[Byte(LA shr 8)] xor ST3[Byte(LA shr 24)
+    ] xor ST2[Byte(LA shr 40)] xor ST1[Byte(LA shr 56)]);
+  LC := LC * 5;
+
+  LData[0] := LData[0] - (LData[7] xor C1);
+  LData[1] := LData[1] xor LData[0];
+  LData[2] := LData[2] + LData[1];
+  LData[3] := LData[3] - (LData[2] xor (not LData[1] shl 19));
+  LData[4] := LData[4] xor LData[3];
+  LData[5] := LData[5] + LData[4];
+  LData[6] := LData[6] - (LData[5] xor (not LData[4] shr 23));
+  LData[7] := LData[7] xor LData[6];
+  LData[0] := LData[0] + LData[7];
+  LData[1] := LData[1] - (LData[0] xor (not LData[7] shl 19));
+  LData[2] := LData[2] xor LData[1];
+  LData[3] := LData[3] + LData[2];
+  LData[4] := LData[4] - (LData[3] xor (not LData[2] shr 23));
+  LData[5] := LData[5] xor LData[4];
+  LData[6] := LData[6] + LData[5];
+  LData[7] := LData[7] - (LData[6] xor C2);
+
+  LB := LB xor LData[0];
+  LC := LC - (ST1[Byte(LB)] xor ST2[Byte(LB shr 16)] xor ST3[Byte(LB shr 32)
+    ] xor ST4[Byte(LB shr 48)]);
+  LA := LA + (ST4[Byte(LB shr 8)] xor ST3[Byte(LB shr 24)
+    ] xor ST2[Byte(LB shr 40)] xor ST1[Byte(LB shr 56)]);
+  LA := LA * 7;
+
+  LC := LC xor LData[1];
+  LA := LA - (ST1[Byte(LC)] xor ST2[Byte(LC shr 16)] xor ST3[Byte(LC shr 32)
+    ] xor ST4[Byte(LC shr 48)]);
+  LB := LB + (ST4[Byte(LC shr 8) and $FF] xor ST3[Byte(LC shr 24)
+    ] xor ST2[Byte(LC shr 40)] xor ST1[Byte(LC shr 56)]);
+  LB := LB * 7;
+
+  LA := LA xor LData[2];
+  LB := LB - (ST1[Byte(LA)] xor ST2[Byte(LA shr 16)] xor ST3[Byte(LA shr 32)
+    ] xor ST4[Byte(LA shr 48)]);
+  LC := LC + (ST4[Byte(LA shr 8)] xor ST3[Byte(LA shr 24)
+    ] xor ST2[Byte(LA shr 40)] xor ST1[Byte(LA shr 56)]);
+  LC := LC * 7;
+
+  LB := LB xor LData[3];
+  LC := LC - (ST1[Byte(LB)] xor ST2[Byte(LB shr 16)] xor ST3[Byte(LB shr 32)
+    ] xor ST4[Byte(LB shr 48)]);
+  LA := LA + (ST4[Byte(LB shr 8)] xor ST3[Byte(LB shr 24)
+    ] xor ST2[Byte(LB shr 40)] xor ST1[Byte(LB shr 56)]);
+  LA := LA * 7;
+
+  LC := LC xor LData[4];
+  LA := LA - (ST1[Byte(LC)] xor ST2[Byte(LC shr 16)] xor ST3[Byte(LC shr 32)
+    ] xor ST4[Byte(LC shr 48)]);
+  LB := LB + (ST4[Byte(LC shr 8) and $FF] xor ST3[Byte(LC shr 24)
+    ] xor ST2[Byte(LC shr 40)] xor ST1[Byte(LC shr 56)]);
+  LB := LB * 7;
+
+  LA := LA xor LData[5];
+  LB := LB - (ST1[Byte(LA)] xor ST2[Byte(LA shr 16)] xor ST3[Byte(LA shr 32)
+    ] xor ST4[Byte(LA shr 48)]);
+  LC := LC + (ST4[Byte(LA shr 8)] xor ST3[Byte(LA shr 24)
+    ] xor ST2[Byte(LA shr 40)] xor ST1[Byte(LA shr 56)]);
+  LC := LC * 7;
+
+  LB := LB xor LData[6];
+  LC := LC - (ST1[Byte(LB)] xor ST2[Byte(LB shr 16)] xor ST3[Byte(LB shr 32)
+    ] xor ST4[Byte(LB shr 48)]);
+  LA := LA + (ST4[Byte(LB shr 8)] xor ST3[Byte(LB shr 24)
+    ] xor ST2[Byte(LB shr 40)] xor ST1[Byte(LB shr 56)]);
+  LA := LA * 7;
+
+  LC := LC xor LData[7];
+  LA := LA - (ST1[Byte(LC)] xor ST2[Byte(LC shr 16)] xor ST3[Byte(LC shr 32)
+    ] xor ST4[Byte(LC shr 48)]);
+  LB := LB + (ST4[Byte(LC shr 8) and $FF] xor ST3[Byte(LC shr 24)
+    ] xor ST2[Byte(LC shr 40)] xor ST1[Byte(LC shr 56)]);
+  LB := LB * 7;
+
+  LData[0] := LData[0] - (LData[7] xor C1);
+  LData[1] := LData[1] xor LData[0];
+  LData[2] := LData[2] + LData[1];
+  LData[3] := LData[3] - (LData[2] xor (not LData[1] shl 19));
+  LData[4] := LData[4] xor LData[3];
+  LData[5] := LData[5] + LData[4];
+  LData[6] := LData[6] - (LData[5] xor (not LData[4] shr 23));
+  LData[7] := LData[7] xor LData[6];
+  LData[0] := LData[0] + LData[7];
+  LData[1] := LData[1] - (LData[0] xor (not LData[7] shl 19));
+  LData[2] := LData[2] xor LData[1];
+  LData[3] := LData[3] + LData[2];
+  LData[4] := LData[4] - (LData[3] xor (not LData[2] shr 23));
+  LData[5] := LData[5] xor LData[4];
+  LData[6] := LData[6] + LData[5];
+  LData[7] := LData[7] - (LData[6] xor C2);
+
+  LA := LA xor LData[0];
+  LB := LB - (ST1[Byte(LA)] xor ST2[Byte(LA shr 16)] xor ST3[Byte(LA shr 32)
+    ] xor ST4[Byte(LA shr 48)]);
+  LC := LC + (ST4[Byte(LA shr 8)] xor ST3[Byte(LA shr 24)
+    ] xor ST2[Byte(LA shr 40)] xor ST1[Byte(LA shr 56)]);
+  LC := LC * 9;
+
+  LB := LB xor LData[1];
+  LC := LC - (ST1[Byte(LB)] xor ST2[Byte(LB shr 16)] xor ST3[Byte(LB shr 32)
+    ] xor ST4[Byte(LB shr 48)]);
+  LA := LA + (ST4[Byte(LB shr 8)] xor ST3[Byte(LB shr 24)
+    ] xor ST2[Byte(LB shr 40)] xor ST1[Byte(LB shr 56)]);
+  LA := LA * 9;
+
+  LC := LC xor LData[2];
+  LA := LA - (ST1[Byte(LC)] xor ST2[Byte(LC shr 16)] xor ST3[Byte(LC shr 32)
+    ] xor ST4[Byte(LC shr 48)]);
+  LB := LB + (ST4[Byte(LC shr 8) and $FF] xor ST3[Byte(LC shr 24)
+    ] xor ST2[Byte(LC shr 40)] xor ST1[Byte(LC shr 56)]);
+  LB := LB * 9;
+
+  LA := LA xor LData[3];
+  LB := LB - (ST1[Byte(LA)] xor ST2[Byte(LA shr 16)] xor ST3[Byte(LA shr 32)
+    ] xor ST4[Byte(LA shr 48)]);
+  LC := LC + (ST4[Byte(LA shr 8)] xor ST3[Byte(LA shr 24)
+    ] xor ST2[Byte(LA shr 40)] xor ST1[Byte(LA shr 56)]);
+  LC := LC * 9;
+
+  LB := LB xor LData[4];
+  LC := LC - (ST1[Byte(LB)] xor ST2[Byte(LB shr 16)] xor ST3[Byte(LB shr 32)
+    ] xor ST4[Byte(LB shr 48)]);
+  LA := LA + (ST4[Byte(LB shr 8)] xor ST3[Byte(LB shr 24)
+    ] xor ST2[Byte(LB shr 40)] xor ST1[Byte(LB shr 56)]);
+  LA := LA * 9;
+
+  LC := LC xor LData[5];
+  LA := LA - (ST1[Byte(LC)] xor ST2[Byte(LC shr 16)] xor ST3[Byte(LC shr 32)
+    ] xor ST4[Byte(LC shr 48)]);
+  LB := LB + (ST4[Byte(LC shr 8) and $FF] xor ST3[Byte(LC shr 24)
+    ] xor ST2[Byte(LC shr 40)] xor ST1[Byte(LC shr 56)]);
+  LB := LB * 9;
+
+  LA := LA xor LData[6];
+  LB := LB - (ST1[Byte(LA)] xor ST2[Byte(LA shr 16)] xor ST3[Byte(LA shr 32)
+    ] xor ST4[Byte(LA shr 48)]);
+  LC := LC + (ST4[Byte(LA shr 8)] xor ST3[Byte(LA shr 24)
+    ] xor ST2[Byte(LA shr 40)] xor ST1[Byte(LA shr 56)]);
+  LC := LC * 9;
+
+  LB := LB xor LData[7];
+  LC := LC - (ST1[Byte(LB)] xor ST2[Byte(LB shr 16)] xor ST3[Byte(LB shr 32)
+    ] xor ST4[Byte(LB shr 48)]);
+  LA := LA + (ST4[Byte(LB shr 8)] xor ST3[Byte(LB shr 24)
+    ] xor ST2[Byte(LB shr 40)] xor ST1[Byte(LB shr 56)]);
+  LA := LA * 9;
+
+  LRounds := 3;
+  while LRounds < FRounds do
   begin
-
-    data[0] := data[0] - (data[7] xor C1);
-    data[1] := data[1] xor data[0];
-    data[2] := data[2] + data[1];
-    data[3] := data[3] - (data[2] xor (not data[1] shl 19));
-    data[4] := data[4] xor data[3];
-    data[5] := data[5] + data[4];
-    data[6] := data[6] - (data[5] xor (not data[4] shr 23));
-    data[7] := data[7] xor data[6];
-    data[0] := data[0] + data[7];
-    data[1] := data[1] - (data[0] xor (not data[7] shl 19));
-    data[2] := data[2] xor data[1];
-    data[3] := data[3] + data[2];
-    data[4] := data[4] - (data[3] xor (not data[2] shr 23));
-    data[5] := data[5] xor data[4];
-    data[6] := data[6] + data[5];
-    data[7] := data[7] - (data[6] xor C2);
-
-    c := c xor data[0];
-    a := a - (s_T1[Byte(c)] xor s_T2[Byte(c shr 16)] xor s_T3[Byte(c shr 32)
-      ] xor s_T4[Byte(c shr 48)]);
-    b := b + (s_T4[Byte(c shr 8) and $FF] xor s_T3[Byte(c shr 24)
-      ] xor s_T2[Byte(c shr 40)] xor s_T1[Byte(c shr 56)]);
-    b := b * 9;
-
-    a := a xor data[1];
-    b := b - (s_T1[Byte(a)] xor s_T2[Byte(a shr 16)] xor s_T3[Byte(a shr 32)
-      ] xor s_T4[Byte(a shr 48)]);
-    c := c + (s_T4[Byte(a shr 8)] xor s_T3[Byte(a shr 24)] xor s_T2
-      [Byte(a shr 40)] xor s_T1[Byte(a shr 56)]);
-    c := c * 9;
-
-    b := b xor data[2];
-    c := c - (s_T1[Byte(b)] xor s_T2[Byte(b shr 16)] xor s_T3[Byte(b shr 32)
-      ] xor s_T4[Byte(b shr 48)]);
-    a := a + (s_T4[Byte(b shr 8)] xor s_T3[Byte(b shr 24)] xor s_T2
-      [Byte(b shr 40)] xor s_T1[Byte(b shr 56)]);
-    a := a * 9;
-
-    c := c xor data[3];
-    a := a - (s_T1[Byte(c)] xor s_T2[Byte(c shr 16)] xor s_T3[Byte(c shr 32)
-      ] xor s_T4[Byte(c shr 48)]);
-    b := b + (s_T4[Byte(c shr 8) and $FF] xor s_T3[Byte(c shr 24)
-      ] xor s_T2[Byte(c shr 40)] xor s_T1[Byte(c shr 56)]);
-    b := b * 9;
-
-    a := a xor data[4];
-    b := b - (s_T1[Byte(a)] xor s_T2[Byte(a shr 16)] xor s_T3[Byte(a shr 32)
-      ] xor s_T4[Byte(a shr 48)]);
-    c := c + (s_T4[Byte(a shr 8)] xor s_T3[Byte(a shr 24)] xor s_T2
-      [Byte(a shr 40)] xor s_T1[Byte(a shr 56)]);
-    c := c * 9;
-
-    b := b xor data[5];
-    c := c - (s_T1[Byte(b)] xor s_T2[Byte(b shr 16)] xor s_T3[Byte(b shr 32)
-      ] xor s_T4[Byte(b shr 48)]);
-    a := a + (s_T4[Byte(b shr 8)] xor s_T3[Byte(b shr 24)] xor s_T2
-      [Byte(b shr 40)] xor s_T1[Byte(b shr 56)]);
-    a := a * 9;
-
-    c := c xor data[6];
-    a := a - (s_T1[Byte(c)] xor s_T2[Byte(c shr 16)] xor s_T3[Byte(c shr 32)
-      ] xor s_T4[Byte(c shr 48)]);
-    b := b + (s_T4[Byte(c shr 8) and $FF] xor s_T3[Byte(c shr 24)
-      ] xor s_T2[Byte(c shr 40)] xor s_T1[Byte(c shr 56)]);
-    b := b * 9;
-
-    a := a xor data[7];
-    b := b - (s_T1[Byte(a)] xor s_T2[Byte(a shr 16)] xor s_T3[Byte(a shr 32)
-      ] xor s_T4[Byte(a shr 48)]);
-    c := c + (s_T4[Byte(a shr 8)] xor s_T3[Byte(a shr 24)] xor s_T2
-      [Byte(a shr 40)] xor s_T1[Byte(a shr 56)]);
-    c := c * 9;
-
-    temp_a := a;
-    a := c;
-    c := b;
-    b := temp_a;
-
-    System.Inc(rounds);
+    LData[0] := LData[0] - (LData[7] xor C1);
+    LData[1] := LData[1] xor LData[0];
+    LData[2] := LData[2] + LData[1];
+    LData[3] := LData[3] - (LData[2] xor (not LData[1] shl 19));
+    LData[4] := LData[4] xor LData[3];
+    LData[5] := LData[5] + LData[4];
+    LData[6] := LData[6] - (LData[5] xor (not LData[4] shr 23));
+    LData[7] := LData[7] xor LData[6];
+    LData[0] := LData[0] + LData[7];
+    LData[1] := LData[1] - (LData[0] xor (not LData[7] shl 19));
+    LData[2] := LData[2] xor LData[1];
+    LData[3] := LData[3] + LData[2];
+    LData[4] := LData[4] - (LData[3] xor (not LData[2] shr 23));
+    LData[5] := LData[5] xor LData[4];
+    LData[6] := LData[6] + LData[5];
+    LData[7] := LData[7] - (LData[6] xor C2);
+
+    LC := LC xor LData[0];
+    LA := LA - (ST1[Byte(LC)] xor ST2[Byte(LC shr 16)] xor ST3[Byte(LC shr 32)
+      ] xor ST4[Byte(LC shr 48)]);
+    LB := LB + (ST4[Byte(LC shr 8) and $FF] xor ST3[Byte(LC shr 24)
+      ] xor ST2[Byte(LC shr 40)] xor ST1[Byte(LC shr 56)]);
+    LB := LB * 9;
+
+    LA := LA xor LData[1];
+    LB := LB - (ST1[Byte(LA)] xor ST2[Byte(LA shr 16)] xor ST3[Byte(LA shr 32)
+      ] xor ST4[Byte(LA shr 48)]);
+    LC := LC + (ST4[Byte(LA shr 8)] xor ST3[Byte(LA shr 24)
+      ] xor ST2[Byte(LA shr 40)] xor ST1[Byte(LA shr 56)]);
+    LC := LC * 9;
+
+    LB := LB xor LData[2];
+    LC := LC - (ST1[Byte(LB)] xor ST2[Byte(LB shr 16)] xor ST3[Byte(LB shr 32)
+      ] xor ST4[Byte(LB shr 48)]);
+    LA := LA + (ST4[Byte(LB shr 8)] xor ST3[Byte(LB shr 24)
+      ] xor ST2[Byte(LB shr 40)] xor ST1[Byte(LB shr 56)]);
+    LA := LA * 9;
+
+    LC := LC xor LData[3];
+    LA := LA - (ST1[Byte(LC)] xor ST2[Byte(LC shr 16)] xor ST3[Byte(LC shr 32)
+      ] xor ST4[Byte(LC shr 48)]);
+    LB := LB + (ST4[Byte(LC shr 8) and $FF] xor ST3[Byte(LC shr 24)
+      ] xor ST2[Byte(LC shr 40)] xor ST1[Byte(LC shr 56)]);
+    LB := LB * 9;
+
+    LA := LA xor LData[4];
+    LB := LB - (ST1[Byte(LA)] xor ST2[Byte(LA shr 16)] xor ST3[Byte(LA shr 32)
+      ] xor ST4[Byte(LA shr 48)]);
+    LC := LC + (ST4[Byte(LA shr 8)] xor ST3[Byte(LA shr 24)
+      ] xor ST2[Byte(LA shr 40)] xor ST1[Byte(LA shr 56)]);
+    LC := LC * 9;
+
+    LB := LB xor LData[5];
+    LC := LC - (ST1[Byte(LB)] xor ST2[Byte(LB shr 16)] xor ST3[Byte(LB shr 32)
+      ] xor ST4[Byte(LB shr 48)]);
+    LA := LA + (ST4[Byte(LB shr 8)] xor ST3[Byte(LB shr 24)
+      ] xor ST2[Byte(LB shr 40)] xor ST1[Byte(LB shr 56)]);
+    LA := LA * 9;
+
+    LC := LC xor LData[6];
+    LA := LA - (ST1[Byte(LC)] xor ST2[Byte(LC shr 16)] xor ST3[Byte(LC shr 32)
+      ] xor ST4[Byte(LC shr 48)]);
+    LB := LB + (ST4[Byte(LC shr 8) and $FF] xor ST3[Byte(LC shr 24)
+      ] xor ST2[Byte(LC shr 40)] xor ST1[Byte(LC shr 56)]);
+    LB := LB * 9;
+
+    LA := LA xor LData[7];
+    LB := LB - (ST1[Byte(LA)] xor ST2[Byte(LA shr 16)] xor ST3[Byte(LA shr 32)
+      ] xor ST4[Byte(LA shr 48)]);
+    LC := LC + (ST4[Byte(LA shr 8)] xor ST3[Byte(LA shr 24)
+      ] xor ST2[Byte(LA shr 40)] xor ST1[Byte(LA shr 56)]);
+    LC := LC * 9;
+
+    LTempA := LA;
+    LA := LC;
+    LC := LB;
+    LB := LTempA;
+
+    System.Inc(LRounds);
   end;
 
-  Fm_hash[0] := Fm_hash[0] xor a;
-  Fm_hash[1] := b - Fm_hash[1];
-  Fm_hash[2] := Fm_hash[2] + c;
-
-  System.FillChar(data, System.SizeOf(data), UInt64(0));
+  FHash[0] := FHash[0] xor LA;
+  FHash[1] := LB - FHash[1];
+  FHash[2] := FHash[2] + LC;
 
+  System.FillChar(LData, System.SizeOf(LData), UInt64(0));
 end;
 
 { TTiger_128 }
 
 function TTiger_128.Clone(): IHash;
 var
-  HashInstance: TTiger_128;
+  LHashInstance: TTiger_128;
 begin
-  HashInstance := TTiger_128.Create(HashSize, GetHashRound(Fm_rounds));
-  HashInstance.Fm_hash := System.Copy(Fm_hash);
-  HashInstance.Fm_buffer := Fm_buffer.Clone();
-  HashInstance.Fm_processed_bytes := Fm_processed_bytes;
-  Result := HashInstance as IHash;
+  LHashInstance := TTiger_128.Create(HashSize, GetHashRound(FRounds));
+  LHashInstance.FHash := System.Copy(FHash);
+  LHashInstance.FBuffer := FBuffer.Clone();
+  LHashInstance.FProcessedBytesCount := FProcessedBytesCount;
+  Result := LHashInstance as IHash;
   Result.BufferSize := BufferSize;
 end;
 
@@ -1045,13 +1038,13 @@ end;
 
 function TTiger_160.Clone(): IHash;
 var
-  HashInstance: TTiger_160;
+  LHashInstance: TTiger_160;
 begin
-  HashInstance := TTiger_160.Create(HashSize, GetHashRound(Fm_rounds));
-  HashInstance.Fm_hash := System.Copy(Fm_hash);
-  HashInstance.Fm_buffer := Fm_buffer.Clone();
-  HashInstance.Fm_processed_bytes := Fm_processed_bytes;
-  Result := HashInstance as IHash;
+  LHashInstance := TTiger_160.Create(HashSize, GetHashRound(FRounds));
+  LHashInstance.FHash := System.Copy(FHash);
+  LHashInstance.FBuffer := FBuffer.Clone();
+  LHashInstance.FProcessedBytesCount := FProcessedBytesCount;
+  Result := LHashInstance as IHash;
   Result.BufferSize := BufferSize;
 end;
 
@@ -1074,13 +1067,13 @@ end;
 
 function TTiger_192.Clone(): IHash;
 var
-  HashInstance: TTiger_192;
+  LHashInstance: TTiger_192;
 begin
-  HashInstance := TTiger_192.Create(HashSize, GetHashRound(Fm_rounds));
-  HashInstance.Fm_hash := System.Copy(Fm_hash);
-  HashInstance.Fm_buffer := Fm_buffer.Clone();
-  HashInstance.Fm_processed_bytes := Fm_processed_bytes;
-  Result := HashInstance as IHash;
+  LHashInstance := TTiger_192.Create(HashSize, GetHashRound(FRounds));
+  LHashInstance.FHash := System.Copy(FHash);
+  LHashInstance.FBuffer := FBuffer.Clone();
+  LHashInstance.FProcessedBytesCount := FProcessedBytesCount;
+  Result := LHashInstance as IHash;
   Result.BufferSize := BufferSize;
 end;
 
@@ -1103,19 +1096,19 @@ end;
 
 function TTiger_Base.Clone(): IHash;
 var
-  HashInstance: TTiger_Base;
+  LHashInstance: TTiger_Base;
 begin
-  HashInstance := TTiger_Base.Create(HashSize, GetHashRound(Fm_rounds));
-  HashInstance.Fm_hash := System.Copy(Fm_hash);
-  HashInstance.Fm_buffer := Fm_buffer.Clone();
-  HashInstance.Fm_processed_bytes := Fm_processed_bytes;
-  Result := HashInstance as IHash;
+  LHashInstance := TTiger_Base.Create(HashSize, GetHashRound(FRounds));
+  LHashInstance.FHash := System.Copy(FHash);
+  LHashInstance.FBuffer := FBuffer.Clone();
+  LHashInstance.FProcessedBytesCount := FProcessedBytesCount;
+  Result := LHashInstance as IHash;
   Result.BufferSize := BufferSize;
 end;
 
-constructor TTiger_Base.Create(a_hash_size: Int32; a_rounds: THashRounds);
+constructor TTiger_Base.Create(AHashSize: Int32; ARounds: THashRounds);
 begin
-  Inherited Create(a_hash_size, a_rounds);
+  Inherited Create(AHashSize, ARounds);
 end;
 
 end.

Some files were not shown because too many files changed in this diff