]> mj.ucw.cz Git - libucw.git/blobdiff - ucw/md5.c
Opt: Introduced contexts
[libucw.git] / ucw / md5.c
index b04278bc4b0b3c3f4ed382af9d38f0d94076bbee..3f8384ba8cc43036826018ddbcda29110b7fee2d 100644 (file)
--- a/ucw/md5.c
+++ b/ucw/md5.c
@@ -252,3 +252,28 @@ void md5_hash_buffer(byte *outbuf, const byte *buffer, uns length)
   md5_update(&c, buffer, length);
   memcpy(outbuf, md5_final(&c), MD5_SIZE);
 }
+
+#ifdef TEST
+
+#include <stdio.h>
+#include <unistd.h>
+#include <ucw/string.h>
+
+int main(void)
+{
+  md5_context hd;
+  byte buf[3];
+  int cnt;
+
+  md5_init(&hd);
+  while ((cnt = read(0, buf, sizeof(buf))) > 0)
+    md5_update(&hd, buf, cnt);
+
+  char text[MD5_HEX_SIZE];
+  mem_to_hex(text, md5_final(&hd), MD5_SIZE, 0);
+  puts(text);
+
+  return 0;
+}
+
+#endif