summaryrefslogtreecommitdiffstats
path: root/tests/helpers/test_md5.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 14:30:35 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 14:30:35 +0000
commit378c18e5f024ac5a8aef4cb40d7c9aa9633d144c (patch)
tree44dfb6ca500d32cabd450649b322a42e70a30683 /tests/helpers/test_md5.c
parentInitial commit. (diff)
downloadutil-linux-378c18e5f024ac5a8aef4cb40d7c9aa9633d144c.tar.xz
util-linux-378c18e5f024ac5a8aef4cb40d7c9aa9633d144c.zip
Adding upstream version 2.38.1.upstream/2.38.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/helpers/test_md5.c')
-rw-r--r--tests/helpers/test_md5.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/helpers/test_md5.c b/tests/helpers/test_md5.c
new file mode 100644
index 0000000..6f8dec4
--- /dev/null
+++ b/tests/helpers/test_md5.c
@@ -0,0 +1,29 @@
+
+#include <stdio.h>
+#include <unistd.h>
+
+#include "md5.h"
+
+int main(void)
+{
+ int i, ret;
+ struct UL_MD5Context ctx;
+ unsigned char digest[UL_MD5LENGTH];
+ unsigned char buf[BUFSIZ];
+
+ ul_MD5Init( &ctx );
+
+ while(!feof(stdin) && !ferror(stdin)) {
+ ret = fread(buf, 1, sizeof(buf), stdin);
+ if (ret)
+ ul_MD5Update( &ctx, buf, ret );
+ }
+
+ fclose(stdin);
+ ul_MD5Final( digest, &ctx );
+
+ for (i = 0; i < UL_MD5LENGTH; i++)
+ printf( "%02x", digest[i] );
+ printf("\n");
+ return 0;
+}