mirror of
https://github.com/vishapoberon/compiler.git
synced 2026-04-05 23:22:25 +00:00
md5sum test will now work with binary files as well.
This commit is contained in:
parent
75c155f8ec
commit
e376e59f58
1 changed files with 10 additions and 5 deletions
|
|
@ -19,25 +19,30 @@ PROCEDURE main;
|
|||
hexDigest: ARRAY 33 OF CHAR;
|
||||
F: Files.File;
|
||||
R: Files.Rider;
|
||||
input: ARRAY 512 OF CHAR;
|
||||
input: POINTER TO ARRAY OF CHAR;
|
||||
ilen: LONGINT;
|
||||
ch: CHAR;
|
||||
i: INTEGER;
|
||||
BEGIN
|
||||
F := Files.Old("hello.txt");
|
||||
F := Files.Old("SETs.pdf");
|
||||
IF F # NIL THEN
|
||||
Files.Set(R, F, 0);
|
||||
ilen := Files.Length(F);
|
||||
Out.String("file length is "); Out.Int(ilen, 0); Out.Ln;
|
||||
NEW(input, ilen+1);
|
||||
i := 0;
|
||||
REPEAT
|
||||
Files.Read(R, ch);
|
||||
input[i] := ch;
|
||||
input^[i] := ch;
|
||||
INC(i)
|
||||
UNTIL R.eof;
|
||||
dump(input);
|
||||
(*dump(input^);*)
|
||||
END;
|
||||
|
||||
context := MD5.New(); (* Initialize MD5 context *)
|
||||
|
||||
MD5.WriteBytes(context, input, Strings.Length(input)); (* Process input string *)
|
||||
(*MD5.WriteBytes(context, input^, Strings.Length(input^));*) (* Process input string *)
|
||||
MD5.WriteBytes(context, input^, LEN(input^)-1); (* Process input string *)
|
||||
MD5.Close(context, digest); (* Finalize and get digest *)
|
||||
|
||||
MD5.ToString(digest, hexDigest); (* Convert digest to hex string *)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue