summaryrefslogtreecommitdiffstats
path: root/tests/helpers/test_sha1.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 13:14:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 13:14:44 +0000
commit30ff6afe596eddafacf22b1a5b2d1a3d6254ea15 (patch)
tree9b788335f92174baf7ee18f03ca8330b8c19ce2b /tests/helpers/test_sha1.c
parentInitial commit. (diff)
downloadutil-linux-30ff6afe596eddafacf22b1a5b2d1a3d6254ea15.tar.xz
util-linux-30ff6afe596eddafacf22b1a5b2d1a3d6254ea15.zip
Adding upstream version 2.36.1.upstream/2.36.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--tests/helpers/test_sha1.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/helpers/test_sha1.c b/tests/helpers/test_sha1.c
new file mode 100644
index 0000000..ad96da4
--- /dev/null
+++ b/tests/helpers/test_sha1.c
@@ -0,0 +1,29 @@
+
+#include <stdio.h>
+#include <unistd.h>
+
+#include "sha1.h"
+
+int main(void)
+{
+ int i, ret;
+ UL_SHA1_CTX ctx;
+ unsigned char digest[UL_SHA1LENGTH];
+ unsigned char buf[BUFSIZ];
+
+ ul_SHA1Init( &ctx );
+
+ while(!feof(stdin) && !ferror(stdin)) {
+ ret = fread(buf, 1, sizeof(buf), stdin);
+ if (ret)
+ ul_SHA1Update( &ctx, buf, ret );
+ }
+
+ fclose(stdin);
+ ul_SHA1Final( digest, &ctx );
+
+ for (i = 0; i < UL_SHA1LENGTH; i++)
+ printf( "%02x", digest[i] );
+ printf("\n");
+ return 0;
+}