hedgewars/uSHA.pas
changeset 2157 a2fa7f594842
parent 1066 1f1b3686a2b0
child 2630 079ef82eac75
--- a/hedgewars/uSHA.pas	Fri Jun 12 08:50:20 2009 +0000
+++ b/hedgewars/uSHA.pas	Fri Jun 12 08:52:31 2009 +0000
@@ -29,6 +29,7 @@
 
 procedure SHA1Init(var Context: TSHA1Context);
 procedure SHA1Update(var Context: TSHA1Context; Buf: PByteArray; Length: LongWord);
+procedure SHA1UpdateLongwords(var Context: TSHA1Context; Buf: PLongwordArray; Length: LongWord);
 function  SHA1Final(Context: TSHA1Context): TSHA1Digest;
 
 implementation
@@ -116,6 +117,22 @@
     end
 end;
 
+procedure SHA1UpdateLongwords(var Context: TSHA1Context; Buf: PLongwordArray; Length: LongWord);
+var i: Longword;
+begin
+for i:= 0 to Pred(Length div 4) do
+    begin
+    SDLNet_Write32(Buf^[i], @Context.Buf[Context.CurrLength]);
+    inc(Context.CurrLength, 4);
+    if Context.CurrLength = 64 then
+       begin
+       SHA1Hash(Context);
+       inc(Context.Length, 512);
+       Context.CurrLength:= 0
+       end
+    end
+end;
+
 function  SHA1Final(Context: TSHA1Context): TSHA1Digest;
 var i: LongWord;
 begin